Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore: remove unnecessary suspense context (#2354)

dev-rbe04aefb6b2d8
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsx
index f886288b99..cb69881dcf 100644
--- a/js/app/packages/app/component/Root.tsx
+++ b/js/app/packages/app/component/Root.tsx
@@ -58,6 +58,7 @@ import {
onCleanup,
onMount,
type ParentProps,
+ Suspense,
Switch,
} from 'solid-js';
import { currentThemeId } from '../../block-theme/signals/themeSignals';
@@ -76,7 +77,6 @@ import { SearchProvider } from './next-soup/search-context';
import { Layout } from './Layout';
import MacroJump from './MacroJump';
import { ReactiveFavicon } from './ReactiveFavicon';
-import { SuspenseContextComp } from './SuspenseContext';
import { lazy } from 'solid-js';
import { LAYOUT_ROUTE } from './split-layout/SplitLayoutRoute';
@@ -417,24 +417,6 @@ export function Root() {
const [tabInfo] = tabTitleSignal;
const tabTitle = () => formatTabTitle(tabInfo());
- let runRootWarningLog = false;
- const RootSuspenseFallback = () => {
- const runWarningLog = () => {
- if (!runRootWarningLog) {
- setTimeout(() => {
- runRootWarningLog = true;
- });
- return;
- }
-
- console.warn('Root Suspsense Triggered');
- };
-
- runWarningLog();
-
- return '';
- };
-
return (
<MaybeTauriProvider>
<MetaProvider>
@@ -454,9 +436,7 @@ export function Root() {
<Title>{tabTitle()}</Title>
<MacroJump />
<Visor />
- <SuspenseContextComp
- fallback={<RootSuspenseFallback />}
- >
+ <Suspense>
<IsomorphicRouter
transformUrl={transformShortIdInUrlPathname}
root={Layout}
@@ -469,7 +449,7 @@ export function Root() {
children: ROUTES,
}}
</IsomorphicRouter>
- </SuspenseContextComp>
+ </Suspense>
<ToastRegion />
</SearchProvider>
</QuickAccessProvider>
diff --git a/js/app/packages/app/component/SuspenseContext.tsx b/js/app/packages/app/component/SuspenseContext.tsx
deleted file mode 100644
index 8dbd062eeb..0000000000
--- a/js/app/packages/app/component/SuspenseContext.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-import {
- type Accessor,
- createContext,
- createSignal,
- createUniqueId,
- type JSX,
- onCleanup,
- type ParentComponent,
- Suspense,
- useContext,
-} from 'solid-js';
-
-const SuspenseContext = createContext<{
- isPending: Accessor<boolean>;
-}>();
-
-export const useSuspenseContext = () => {
- const context = useContext(SuspenseContext);
- if (!context) {
- throw new Error(
- `SuspenseContext is not found. Make sure you're calling it within a SuspenseContextProvider.`
- );
- }
-
- return context;
-};
-
-const [isPending, setIsPending] = createSignal(false);
-
-export const SuspenseContextComp: ParentComponent<{
- id?: string;
- fallback?: JSX.Element;
-}> = (props) => {
- const _id = props.id ?? createUniqueId(); // for debugging
-
- const Fallback: ParentComponent = () => {
- setIsPending(true);
- onCleanup(() => {
- setTimeout(() => {
- setIsPending(false);
- });
- });
- return <>{props.fallback}</>;
- };
-
- return (
- <SuspenseContext.Provider value={{ isPending }}>
- <Suspense fallback={<Fallback />}>{props.children}</Suspense>
- </SuspenseContext.Provider>
- );
-};