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