feat: Disable session lock when running in element-desktop (#30643)

* feat: Disable session lock when running in element-desktop

* feat: Use Platform abstractions over direct invocation for session lock.

* fix: Remove window.electron checks from session lock methods.

* docs: Remove extraneous doc comments.

* feat: Convert BasePlatform session methods to abstract methods.

* fix: Check for PlatformPeg instance in session lock.

* fix: Remove async marker from checkSessionLockFree
This commit is contained in:
Skye Elliot
2025-09-23 15:46:01 +01:00
committed by GitHub
parent ca3060af69
commit c8d937655b
6 changed files with 51 additions and 3 deletions

View File

@@ -130,7 +130,6 @@ import { NotificationLevel } from "../../stores/notifications/NotificationLevel"
import { type UserTab } from "../views/dialogs/UserTab";
import { shouldSkipSetupEncryption } from "../../utils/crypto/shouldSkipSetupEncryption";
import { Filter } from "../views/dialogs/spotlight/Filter";
import { checkSessionLockFree, getSessionLock } from "../../utils/SessionLock";
import { SessionLockStolenView } from "./auth/SessionLockStolenView";
import { ConfirmSessionLockTheftView } from "./auth/ConfirmSessionLockTheftView";
import { LoginSplashView } from "./auth/LoginSplashView";
@@ -314,7 +313,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
private async initSession(): Promise<void> {
// The Rust Crypto SDK will break if two Element instances try to use the same datastore at once, so
// make sure we are the only Element instance in town (on this browser/domain).
if (!(await getSessionLock(() => this.onSessionLockStolen()))) {
const platform = PlatformPeg.get();
if (platform && !(await platform.getSessionLock(() => this.onSessionLockStolen()))) {
// we failed to get the lock. onSessionLockStolen should already have been called, so nothing left to do.
return;
}
@@ -479,7 +479,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
// mounted.
if (!this.sessionLoadStarted) {
this.sessionLoadStarted = true;
if (!checkSessionLockFree()) {
const platform = PlatformPeg.get();
if (platform && !platform.checkSessionLockFree()) {
// another instance holds the lock; confirm its theft before proceeding
setTimeout(() => this.setState({ view: Views.CONFIRM_LOCK_THEFT }), 0);
} else {