mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-23 21:38:44 +08:00
refactor: workspace provider (#2218)
This commit is contained in:
@@ -22,6 +22,7 @@ export function useRouterWithWorkspaceIdDefense(router: NextRouter) {
|
||||
}
|
||||
const exist = metadata.find(m => m.id === currentWorkspaceId);
|
||||
if (!exist) {
|
||||
console.warn('workspace not exist, redirect to first one');
|
||||
// clean up
|
||||
setCurrentWorkspaceId(null);
|
||||
setCurrentPageId(null);
|
||||
|
||||
@@ -45,8 +45,9 @@ export function useSyncRouterWithCurrentWorkspaceId(router: NextRouter) {
|
||||
window.apis?.onWorkspaceChange(targetWorkspace.id);
|
||||
}
|
||||
void router.push({
|
||||
pathname: '/workspace/[workspaceId]/all',
|
||||
pathname: router.pathname,
|
||||
query: {
|
||||
...router.query,
|
||||
workspaceId: targetWorkspace.id,
|
||||
},
|
||||
});
|
||||
@@ -56,8 +57,9 @@ export function useSyncRouterWithCurrentWorkspaceId(router: NextRouter) {
|
||||
console.log('set workspace id', workspaceId);
|
||||
setCurrentWorkspaceId(targetWorkspace.id);
|
||||
void router.push({
|
||||
pathname: '/workspace/[workspaceId]/all',
|
||||
pathname: router.pathname,
|
||||
query: {
|
||||
...router.query,
|
||||
workspaceId: targetWorkspace.id,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user