mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat: enable workspace cloud
This commit is contained in:
@@ -8,7 +8,6 @@ const defaultOutLineWorkspaceId = 'affine';
|
||||
export const useEnsureWorkspace = () => {
|
||||
const [workspaceLoaded, setWorkspaceLoaded] = useState(false);
|
||||
const { workspaceList, loadWorkspace, user } = useAppState();
|
||||
console.log('workspaceList: ', workspaceList);
|
||||
const router = useRouter();
|
||||
|
||||
// const defaultOutLineWorkspaceId = '99ce7eb7';
|
||||
@@ -41,6 +40,7 @@ export const useEnsureWorkspace = () => {
|
||||
: (router.query.workspaceId as string) || defaultOutLineWorkspaceId;
|
||||
|
||||
loadWorkspace(workspaceId).finally(() => {
|
||||
console.log('workspaceId: ', workspaceId);
|
||||
setWorkspaceLoaded(true);
|
||||
});
|
||||
}, [loadWorkspace, router, user, workspaceList]);
|
||||
|
||||
@@ -10,6 +10,7 @@ const WorkspaceIndex = () => {
|
||||
const { currentWorkspaceId, currentWorkspace } = useAppState();
|
||||
const { createPage } = usePageHelper();
|
||||
const { workspaceLoaded } = useEnsureWorkspace();
|
||||
console.log('workspaceLoaded: ', workspaceLoaded);
|
||||
|
||||
useEffect(() => {
|
||||
const initPage = async () => {
|
||||
@@ -17,6 +18,7 @@ const WorkspaceIndex = () => {
|
||||
return;
|
||||
}
|
||||
const savedPageId = currentWorkspace?.meta.pageMetas[0]?.id;
|
||||
console.log('savedPageId: ', savedPageId);
|
||||
if (savedPageId) {
|
||||
router.replace(`/workspace/${currentWorkspaceId}/${savedPageId}`);
|
||||
return;
|
||||
|
||||
@@ -11,6 +11,7 @@ export const WorkspaceIndex = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (workspaceLoaded) {
|
||||
console.log('workspaceLoaded: ', workspaceLoaded);
|
||||
router.push(`/workspace/${currentWorkspaceId}`);
|
||||
}
|
||||
}, [currentWorkspaceId, router, workspaceLoaded]);
|
||||
|
||||
@@ -28,6 +28,7 @@ export const AppStateProvider = ({
|
||||
if (dataCenter.workspaces.length === 0) {
|
||||
await createDefaultWorkspace(dataCenter);
|
||||
}
|
||||
|
||||
const currentWorkspace = await dataCenter.loadWorkspace(
|
||||
dataCenter.workspaces[0].id
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user