Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat: add page loading for public workspace page view

tzhangchicd2495e4e069
diff --git a/packages/app/src/pages/public-workspace/[workspaceId]/[pageId].tsx b/packages/app/src/pages/public-workspace/[workspaceId]/[pageId].tsx
index a3629580b5..81ae823295 100644
--- a/packages/app/src/pages/public-workspace/[workspaceId]/[pageId].tsx
+++ b/packages/app/src/pages/public-workspace/[workspaceId]/[pageId].tsx
@@ -5,6 +5,10 @@ import { styled } from '@/styles';
import dynamic from 'next/dynamic';
import { useRouter } from 'next/router';
import { Page as PageStore, Workspace } from '@blocksuite/store';
+import { PageLoading } from '@/components/loading';
+
+import { useTranslation } from '@affine/i18n';
+
const DynamicBlocksuite = dynamic(() => import('@/components/editor'), {
ssr: false,
});
@@ -13,6 +17,8 @@ const Page: NextPageWithLayout = () => {
const [page, setPage] = useState<PageStore>();
const { dataCenter } = useAppState();
const router = useRouter();
+ const [loaded, setLoaded] = useState(false);
+ const { t } = useTranslation();
useEffect(() => {
dataCenter
.loadPublicWorkspace(router.query.workspaceId as string)
@@ -39,17 +45,21 @@ const Page: NextPageWithLayout = () => {
});
}, [router, dataCenter]);
return (
- <PageContainer>
- {workspace && page && (
- <DynamicBlocksuite
- page={page}
- workspace={workspace}
- setEditor={editor => {
- editor.readonly = true;
- }}
- />
- )}
- </PageContainer>
+ <>
+ {!loaded && <PageLoading />}
+ <PageContainer>
+ {workspace && page && (
+ <DynamicBlocksuite
+ page={page}
+ workspace={workspace}
+ setEditor={editor => {
+ editor.readonly = true;
+ setLoaded(true);
+ }}
+ />
+ )}
+ </PageContainer>
+ </>
);
};