Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/components/structures/MatrixChat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
private readonly stores: SdkContextClass;
private loadSessionAbortController = new AbortController();

private sessionLoadStarted = false;

public constructor(props: IProps) {
super(props);
this.stores = SdkContextClass.instance;
Expand Down Expand Up @@ -470,15 +472,20 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
this.fontWatcher.start();

initSentry(SdkConfig.get("sentry"));
window.addEventListener("resize", this.onWindowResized);

if (!checkSessionLockFree()) {
// another instance holds the lock; confirm its theft before proceeding
setTimeout(() => this.setState({ view: Views.CONFIRM_LOCK_THEFT }), 0);
} else {
this.startInitSession();
// Once we start loading the MatrixClient, we can't stop, even if MatrixChat gets unmounted (as it does
// in React's Strict Mode). So, start loading the session now, but only if this MatrixChat was not previously
// mounted.
if (!this.sessionLoadStarted) {
this.sessionLoadStarted = true;
if (!checkSessionLockFree()) {
// another instance holds the lock; confirm its theft before proceeding
setTimeout(() => this.setState({ view: Views.CONFIRM_LOCK_THEFT }), 0);
} else {
this.startInitSession();
}
}

window.addEventListener("resize", this.onWindowResized);
}

public componentDidUpdate(prevProps: IProps, prevState: IState): void {
Expand Down
Loading