Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Do not restore last URL to login if we're in single-room mode
  • Loading branch information
psrpinto committed Jun 5, 2023
commit dd39fe0364b95e44576fc4bfdb4809169c47e2d4
4 changes: 4 additions & 0 deletions frontend/iframe/platform/History.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export class History extends BaseHistory {
super.replaceUrlSilently(url);
}

getLastSessionUrl() {
return super.getLastSessionUrl();
}

private get urlHashKey(): string {
return `chatrix_${this._instanceId}_last_url_hash`;
}
Expand Down
13 changes: 11 additions & 2 deletions frontend/iframe/viewmodels/RootViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,24 @@ export class RootViewModel extends ViewModel<SegmentType, Options> {
}

private async _showInitialScreen(shouldRestoreLastUrl: boolean) {
if (shouldRestoreLastUrl && this._resolvedSingleRoomId) {
// Do not restore last URL to Login if we're in single-room mode.
// We do this so that we can try guest login when appropriate.
const willShowLogin = this.platform.history.getLastSessionUrl() === "#/login";
if (willShowLogin) {
shouldRestoreLastUrl = false;
}
}

if (shouldRestoreLastUrl && this.urlRouter.tryRestoreLastUrl()) {
// Restored last URL.
// By the time we get here, _applyNavigation() has run for the restored URL, so we have nothing else
// to do here.
// to do.
return;
}

// We were not able to restore the last URL.
// So we send the user to the screen that makes most sense, according to how many sessions they have.
// So we send the user to the screen that makes the most sense, according to how many sessions they have.
const sessionInfos = await this.platform.sessionInfoStorage.getAll();

// Go to Login or, when in single-room mode, try registering guest user.
Expand Down