Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Get invites transitioning correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Mar 29, 2022
1 parent 12fa287 commit dbc0d57
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/SlidingSyncManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,19 @@ export class SlidingSyncManager {
this.slidingSync.modifyRoomSubscriptions(subscriptions);

return new Promise((resolve, reject) => {
const resolveOnSubscribed = (state, resp, err) => {
if (state === SlidingSyncState.Complete) {
if (visible && !resp.room_subscriptions[roomId]) {
// we want roomId but this /sync response doesn't include it yet.
return;
}
if (this.client.getRoom(roomId)) {
resolve(roomId); // we have data already for this room, show immediately e.g it's in a list
return;
}
const resolveOnSubscribed = (gotRoomId: string) => {
if (roomId === gotRoomId) {
// we processed a /sync response which returned this subscription
this.slidingSync.off(SlidingSyncEvent.Lifecycle, resolveOnSubscribed);
this.slidingSync.off(SlidingSyncEvent.RoomData, resolveOnSubscribed);
resolve(roomId);
}
};
// wait until the next sync before returning as RoomView may need to know the current state
this.slidingSync.on(SlidingSyncEvent.Lifecycle, resolveOnSubscribed);
this.slidingSync.on(SlidingSyncEvent.RoomData, resolveOnSubscribed);
});
}

Expand Down
1 change: 1 addition & 0 deletions src/components/structures/RoomView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
}

const roomId = RoomViewStore.getRoomId();

if (initial && SettingsStore.getValue("slidingSync")) {
// set this room as the room subscription. We need to await for it as this will fetch
// all room state for this room, which is required before we get the state below.
Expand Down
3 changes: 3 additions & 0 deletions src/stores/room-list/RoomListStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ export class RoomListStoreClass extends AsyncStoreWithClient<IState> {
*/
private handleRVSUpdate({ trigger = true }) {
if (!this.matrixClient) return; // We assume there won't be RVS updates without a client
if (SettingsStore.getValue("slidingSync")) {
return; // we don't need any of this in sliding sync mode.
}

const activeRoomId = RoomViewStore.getRoomId();
if (!activeRoomId && this.algorithm.stickyRoom) {
Expand Down

0 comments on commit dbc0d57

Please sign in to comment.