diff --git a/frontend/appflowy_web_app/server.cjs b/frontend/appflowy_web_app/server.cjs index 5c0f8449ed..faf7230223 100644 --- a/frontend/appflowy_web_app/server.cjs +++ b/frontend/appflowy_web_app/server.cjs @@ -62,26 +62,28 @@ const createServer = async (req) => { const reqUrl = new URL(req.url); logger.info(`Request URL: ${reqUrl.pathname}`); - + const [ namespace, publishName, ] = reqUrl.pathname.slice(1).split('/'); - logger.info(`Namespace: ${namespace}, Puganblish Name: ${publishName}`); - - if (namespace === '' || !publishName) { - timer(); - return new Response(null, { - status: 302, - headers: { - 'Location': 'https://appflowy.io', - }, - }); - } + logger.info(`Namespace: ${namespace}, Publish Name: ${publishName}`); if (req.method === 'GET') { + + if (namespace === '' || !publishName) { + timer(); + return new Response(null, { + status: 302, + headers: { + 'Location': 'https://appflowy.io', + }, + }); + } + let metaData; + try { metaData = await fetchMetaData(`${BASE_URL}/api/workspace/published/${namespace}/${publishName}`); } catch (error) { diff --git a/frontend/appflowy_web_app/src/application/db/index.ts b/frontend/appflowy_web_app/src/application/db/index.ts index 425063e89d..6c7ae21264 100644 --- a/frontend/appflowy_web_app/src/application/db/index.ts +++ b/frontend/appflowy_web_app/src/application/db/index.ts @@ -42,3 +42,17 @@ export async function openCollabDB(docName: string): Promise { return doc as YDoc; } + +export async function closeCollabDB(docName: string) { + const name = `${databasePrefix}_${docName}`; + + if (openedSet.has(name)) { + openedSet.delete(name); + } + + const doc = new Y.Doc(); + + const provider = new IndexeddbPersistence(name, doc); + + await provider.destroy(); +} diff --git a/frontend/appflowy_web_app/src/application/services/js-services/cache/index.ts b/frontend/appflowy_web_app/src/application/services/js-services/cache/index.ts index f2a07f614a..a4db114630 100644 --- a/frontend/appflowy_web_app/src/application/services/js-services/cache/index.ts +++ b/frontend/appflowy_web_app/src/application/services/js-services/cache/index.ts @@ -7,7 +7,7 @@ import { YSharedRoot, } from '@/application/collab.type'; import { applyYDoc } from '@/application/ydoc/apply'; -import { db, openCollabDB } from '@/application/db'; +import { closeCollabDB, db, openCollabDB } from '@/application/db'; import { Fetcher, StrategyType } from '@/application/services/js-services/cache/types'; export function collabTypeToDBType(type: CollabType) { @@ -226,3 +226,13 @@ export async function getBatchCollabs(names: string[]) { return collabs; } + +export async function deleteViewMeta(name: string) { + await db.view_metas.delete(name); +} + +export async function deleteView(name: string) { + console.log('deleteView', name); + await deleteViewMeta(name); + await closeCollabDB(name); +} diff --git a/frontend/appflowy_web_app/src/application/services/js-services/index.ts b/frontend/appflowy_web_app/src/application/services/js-services/index.ts index 6a9fe2a5ab..e2939aa79a 100644 --- a/frontend/appflowy_web_app/src/application/services/js-services/index.ts +++ b/frontend/appflowy_web_app/src/application/services/js-services/index.ts @@ -1,5 +1,11 @@ import { YDoc } from '@/application/collab.type'; -import { getBatchCollabs, getPublishView, getPublishViewMeta } from '@/application/services/js-services/cache'; +import { + deleteView, + getBatchCollabs, + getPublishView, + getPublishViewMeta, + hasViewMetaCache, +} from '@/application/services/js-services/cache'; import { StrategyType } from '@/application/services/js-services/cache/types'; import { fetchPublishView, fetchPublishViewMeta, fetchViewInfo } from '@/application/services/js-services/fetch'; import { AFService, AFServiceConfig } from '@/application/services/services.type'; @@ -56,8 +62,20 @@ export class AFClientService implements AFService { const isLoaded = this.publishViewLoaded.has(name); const doc = await getPublishView( - () => { - return fetchPublishView(namespace, publishName); + async () => { + try { + return await fetchPublishView(namespace, publishName); + } catch (e) { + void (async () => { + if (await hasViewMetaCache(name)) { + this.publishViewLoaded.delete(name); + void deleteView(name); + window.location.reload(); + } + })(); + + return Promise.reject(e); + } }, { namespace, diff --git a/frontend/appflowy_web_app/src/components/app/App.tsx b/frontend/appflowy_web_app/src/components/app/App.tsx index 75acb09842..c66556d8f7 100644 --- a/frontend/appflowy_web_app/src/components/app/App.tsx +++ b/frontend/appflowy_web_app/src/components/app/App.tsx @@ -8,6 +8,7 @@ const AppMain = withAppWrapper(() => { return ( } /> + } /> } /> ); diff --git a/frontend/appflowy_web_app/src/components/editor/components/blocks/link-preview/LinkPreview.tsx b/frontend/appflowy_web_app/src/components/editor/components/blocks/link-preview/LinkPreview.tsx index 98ebfba57c..84b6883256 100644 --- a/frontend/appflowy_web_app/src/components/editor/components/blocks/link-preview/LinkPreview.tsx +++ b/frontend/appflowy_web_app/src/components/editor/components/blocks/link-preview/LinkPreview.tsx @@ -41,7 +41,7 @@ export const LinkPreview = memo( {data ? (
{data.title} -
-
{data.title}
-
{data.description}
-
{url}
+
+
+ {data.title} +
+
+ {data.description} +
+
{url}
) : ( diff --git a/frontend/appflowy_web_app/src/components/editor/components/blocks/table/table.scss b/frontend/appflowy_web_app/src/components/editor/components/blocks/table/table.scss index 1aa812f6c5..f437d49742 100644 --- a/frontend/appflowy_web_app/src/components/editor/components/blocks/table/table.scss +++ b/frontend/appflowy_web_app/src/components/editor/components/blocks/table/table.scss @@ -1,4 +1,9 @@ .table-block { + ::-webkit-scrollbar { + width: 8px !important; + height: 8px !important; + } + [id^=table-] { width: fit-content; @apply border-t border-l border-line-border; diff --git a/frontend/appflowy_web_app/src/components/publish/PublishView.tsx b/frontend/appflowy_web_app/src/components/publish/PublishView.tsx index 7a17ee2df0..38e194f641 100644 --- a/frontend/appflowy_web_app/src/components/publish/PublishView.tsx +++ b/frontend/appflowy_web_app/src/components/publish/PublishView.tsx @@ -19,6 +19,7 @@ const drawerWidth = 268; export function PublishView({ namespace, publishName }: PublishViewProps) { const [doc, setDoc] = useState(); const [notFound, setNotFound] = useState(false); + const service = useContext(AFConfigContext)?.service; const openPublishView = useCallback(async () => { let doc; @@ -58,6 +59,7 @@ export function PublishView({ namespace, publishName }: PublishViewProps) { window.removeEventListener('keydown', onKeyDown); }; }, [onKeyDown]); + if (notFound && !doc) { return ; } diff --git a/frontend/appflowy_web_app/src/components/publish/header/BreadcrumbItem.tsx b/frontend/appflowy_web_app/src/components/publish/header/BreadcrumbItem.tsx index 4cadd4c1d6..880656e194 100644 --- a/frontend/appflowy_web_app/src/components/publish/header/BreadcrumbItem.tsx +++ b/frontend/appflowy_web_app/src/components/publish/header/BreadcrumbItem.tsx @@ -57,7 +57,9 @@ function BreadcrumbItem({ crumb, disableClick = false }: { crumb: Crumb; disable ) : ( - {icon || } + + {icon || } + )} { - void openUrl('', '_blank'); + void openUrl('https://report.appflowy.io/', '_blank'); }, }, ]; @@ -85,6 +87,16 @@ function MoreActions() { {action.label} ))} +
{ + window.open('https://appflowy.io', '_blank'); + }} + className={'flex w-full cursor-pointer items-center justify-center py-2 text-sm text-text-title opacity-50'} + > + Powered by + + +
diff --git a/frontend/appflowy_web_app/src/components/publish/useViewMeta.ts b/frontend/appflowy_web_app/src/components/publish/useViewMeta.ts index 9cd63f25bd..18122ef445 100644 --- a/frontend/appflowy_web_app/src/components/publish/useViewMeta.ts +++ b/frontend/appflowy_web_app/src/components/publish/useViewMeta.ts @@ -21,7 +21,7 @@ export function useViewMeta() { lineHeightLayout: extra?.lineHeightLayout, }; }, [extra]); - + const layout = viewMeta?.layout; const style = useMemo(() => { const fontSizeMap = {