Merge pull request #601 from vector-im/dbkr/yet_another_splitbrain_fix
Fix another cause of split-brain rooms
This commit is contained in:
commit
7720770c67
1 changed files with 22 additions and 2 deletions
|
@ -22,8 +22,9 @@ import {
|
||||||
} from "matrix-js-sdk/src/webrtc/groupCall";
|
} from "matrix-js-sdk/src/webrtc/groupCall";
|
||||||
import { GroupCallEventHandlerEvent } from "matrix-js-sdk/src/webrtc/groupCallEventHandler";
|
import { GroupCallEventHandlerEvent } from "matrix-js-sdk/src/webrtc/groupCallEventHandler";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
import { ClientEvent, MatrixClient } from "matrix-js-sdk/src/client";
|
||||||
|
import { SyncState } from "matrix-js-sdk/src/sync";
|
||||||
|
|
||||||
import type { MatrixClient } from "matrix-js-sdk/src/client";
|
|
||||||
import type { Room } from "matrix-js-sdk/src/models/room";
|
import type { Room } from "matrix-js-sdk/src/models/room";
|
||||||
import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
|
import type { GroupCall } from "matrix-js-sdk/src/webrtc/groupCall";
|
||||||
import { isLocalRoomId, createRoom, roomNameFromRoomId } from "../matrix-utils";
|
import { isLocalRoomId, createRoom, roomNameFromRoomId } from "../matrix-utils";
|
||||||
|
@ -126,7 +127,26 @@ export const useLoadGroupCall = (
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchOrCreateGroupCall()
|
const waitForClientSyncing = async () => {
|
||||||
|
if (client.getSyncState() !== SyncState.Syncing) {
|
||||||
|
logger.debug(
|
||||||
|
"useLoadGroupCall: waiting for client to start syncing..."
|
||||||
|
);
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
const onSync = () => {
|
||||||
|
if (client.getSyncState() === SyncState.Syncing) {
|
||||||
|
client.off(ClientEvent.Sync, onSync);
|
||||||
|
return resolve();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
client.on(ClientEvent.Sync, onSync);
|
||||||
|
});
|
||||||
|
logger.debug("useLoadGroupCall: client is now syncing.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
waitForClientSyncing()
|
||||||
|
.then(fetchOrCreateGroupCall)
|
||||||
.then((groupCall) =>
|
.then((groupCall) =>
|
||||||
setState((prevState) => ({ ...prevState, loading: false, groupCall }))
|
setState((prevState) => ({ ...prevState, loading: false, groupCall }))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue