fix: reload the page when login token expired (#1839)

This commit is contained in:
Himself65
2023-04-06 18:26:53 -05:00
committed by GitHub
parent 5ac36b6f0a
commit efe5444816
10 changed files with 80 additions and 16 deletions

View File

@@ -21,9 +21,10 @@ import { PageNotFoundError } from '../../components/affine/affine-error-eoundary
import { WorkspaceSettingDetail } from '../../components/affine/workspace-setting-detail';
import { BlockSuitePageList } from '../../components/blocksuite/block-suite-page-list';
import { PageDetailEditor } from '../../components/page-detail-editor';
import { useAffineRefreshAuthToken } from '../../hooks/affine/use-affine-refresh-auth-token';
import { AffineSWRConfigProvider } from '../../providers/AffineSWRConfigProvider';
import { BlockSuiteWorkspace } from '../../shared';
import { affineApis } from '../../shared/apis';
import { affineApis, prefixUrl } from '../../shared/apis';
import { initPage, toast } from '../../utils';
import type { WorkspacePlugin } from '..';
import { QueryKey } from './fetcher';
@@ -65,7 +66,7 @@ const getPersistenceAllWorkspace = () => {
return allWorkspaces;
};
export const affineAuth = createAffineAuth();
export const affineAuth = createAffineAuth(prefixUrl);
export const AffinePlugin: WorkspacePlugin<WorkspaceFlavour.AFFINE> = {
flavour: WorkspaceFlavour.AFFINE,
@@ -231,6 +232,7 @@ export const AffinePlugin: WorkspacePlugin<WorkspaceFlavour.AFFINE> = {
},
UI: {
Provider: ({ children }) => {
useAffineRefreshAuthToken();
return <AffineSWRConfigProvider>{children}</AffineSWRConfigProvider>;
},
PageDetail: ({ currentWorkspace, currentPageId }) => {