Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 27 additions & 3 deletions client/src/router/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
// Parsec Cloud (https://parsec.cloud) Copyright (c) BUSL-1.1 2016-present Scille SAS

import { ConnectionHandle, EntryName, FsPath, ParsecAccount, ParsecWorkspacePathAddr, WorkspaceHandle, WorkspaceName } from '@/parsec';
import {
ConnectionHandle,
EntryName,
FsPath,
getClientInfo,
ParsecAccount,
ParsecWorkspacePathAddr,
WorkspaceHandle,
WorkspaceName,
} from '@/parsec';
import { DeviceID, OrganizationID } from '@/plugins/libparsec';
import { Env } from '@/services/environment';
import { ServerType } from '@/services/parsecServers';
Expand All @@ -9,7 +18,7 @@ import { InvitationView } from '@/views/invitations/types';
import { WorkspaceMenu } from '@/views/workspaces/types';
import { createRouter, createWebHistory } from '@ionic/vue-router';
import { Ref } from 'vue';
import { RouteLocationNormalizedLoaded, RouteRecordRaw, Router } from 'vue-router';
import { RouteLocationNormalizedLoaded, Router, RouteRecordRaw } from 'vue-router';

export enum Routes {
Home = 'home',
Expand Down Expand Up @@ -240,7 +249,7 @@ export function getRouteBeforeFileHandler(): RouteBackup | undefined {
return routeBeforeFileHandler;
}

router.beforeEach((to, from) => {
router.beforeEach(async (to, from) => {
// Clearing history if we come from a page that has no handle.
// Not taking any risk.
if (!to.params.handle || !from.params.handle) {
Expand All @@ -250,6 +259,21 @@ router.beforeEach((to, from) => {
routeBeforeFileHandler = undefined;
return;
}
// Switching handles, either after logout/login or multi-org shenanigans
if (from.params.handle && from.params.handle !== to.params.handle) {
// `return false` brings a few errors and navigation glitches, returning
// the `from` route seems much more stable
return from;
} else if (!from.params.handle && !import.meta.env.PARSEC_APP_TESTBED_SERVER) {
// From non-logged page
// Check if the handle matches a logged org
const result = await getClientInfo(Number(to.params.handle));
if (!result.ok) {
// `return false` brings a few errors and navigation glitches, returning
// the `from` route seems much more stable
return from;
}
}
const routeName = to.name as Routes;
if (visitedLastHistory.has(to.name as Routes)) {
visitedLastHistory.delete(routeName);
Expand Down
1 change: 1 addition & 0 deletions newsfragments/11150.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent navigating on the previous page after a logout, which resulted in a blank screen
Loading