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.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
fix(core): fix infinite retry when workspace not found (#8679)
EYHN73d0e64c2064
diff --git a/packages/frontend/core/src/desktop/pages/workspace/index.tsx b/packages/frontend/core/src/desktop/pages/workspace/index.tsxindex 7e7da7d543..a973556d35 100644--- a/packages/frontend/core/src/desktop/pages/workspace/index.tsx+++ b/packages/frontend/core/src/desktop/pages/workspace/index.tsx@@ -10,7 +10,7 @@ import {WorkspacesService,} from '@toeverything/infra';import type { ReactElement } from 'react';-import { useEffect, useLayoutEffect, useMemo, useState } from 'react';+import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';import { matchPath, useLocation, useParams } from 'react-router-dom';import { AffineErrorBoundary } from '../../../components/affine/affine-error-boundary';@@ -84,13 +84,19 @@ export const Component = (): ReactElement => {}}, [listLoading, meta, workspacesService]);- // if workspace is not found, we should revalidate in interval+ // if workspace is not found, we should retry+ const retryTimesRef = useRef(3);+ useEffect(() => {+ retryTimesRef.current = 3; // reset retry times+ }, [params.workspaceId]);useEffect(() => {if (listLoading === false && meta === undefined) {- const timer = setInterval(- () => workspacesService.list.revalidate(),- 5000- );+ const timer = setInterval(() => {+ if (retryTimesRef.current > 0) {+ workspacesService.list.revalidate();+ retryTimesRef.current--;+ }+ }, 5000);return () => clearInterval(timer);}return;diff --git a/packages/frontend/core/src/mobile/pages/workspace/index.tsx b/packages/frontend/core/src/mobile/pages/workspace/index.tsxindex 9604627895..e172ce9ecb 100644--- a/packages/frontend/core/src/mobile/pages/workspace/index.tsx+++ b/packages/frontend/core/src/mobile/pages/workspace/index.tsx@@ -12,6 +12,7 @@ import {Suspense,useEffect,useMemo,+ useRef,useState,} from 'react';import {@@ -113,13 +114,19 @@ export const Component = () => {}}, [listLoading, meta, workspacesService]);- // if workspace is not found, we should revalidate in interval+ // if workspace is not found, we should retry+ const retryTimesRef = useRef(3);+ useEffect(() => {+ retryTimesRef.current = 3; // reset retry times+ }, [params.workspaceId]);useEffect(() => {if (listLoading === false && meta === undefined) {- const timer = setInterval(- () => workspacesService.list.revalidate(),- 5000- );+ const timer = setInterval(() => {+ if (retryTimesRef.current > 0) {+ workspacesService.list.revalidate();+ retryTimesRef.current--;+ }+ }, 5000);return () => clearInterval(timer);}return;