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.

fix(platform): move out notification provider, to disable modal when not authed (#2228)

teoc8a9fbcb9c3f
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsx
index da73151c93..a0d424a814 100644
--- a/js/app/packages/app/component/Root.tsx
+++ b/js/app/packages/app/component/Root.tsx
@@ -26,6 +26,7 @@ import {
createNotificationSource,
type UnifiedNotification,
usePlatformNotificationState,
+ PlatformNotificationProvider,
} from '@notifications';
import { maybeHandlePlatformNotification } from '@notifications/notification-platform';
import { useObserveRouting } from '@observability';
@@ -450,38 +451,40 @@ export function Root() {
<PosthogProvider>
<EntityProvider>
<UserContextProvider>
- <QuerySyncProviderWithUserId />
- <UserInfoSideEffects />
- <ConfiguredGlobalAppStateProvider>
- <ChannelsContextProvider>
- <QuickAccessProvider>
- <SearchProvider>
- <TabAttachmentsInit />
- <ReactiveFavicon />
- <Title>{tabTitle()}</Title>
- <MacroJump />
- <Visor />
- <SuspenseContextComp
- fallback={<RootSuspenseFallback />}
- >
- <IsomorphicRouter
- transformUrl={transformShortIdInUrlPathname}
- root={Layout}
- rootPreload={rootPreload}
- base={ROUTER_BASE}
+ <PlatformNotificationProvider>
+ <QuerySyncProviderWithUserId />
+ <UserInfoSideEffects />
+ <ConfiguredGlobalAppStateProvider>
+ <ChannelsContextProvider>
+ <QuickAccessProvider>
+ <SearchProvider>
+ <TabAttachmentsInit />
+ <ReactiveFavicon />
+ <Title>{tabTitle()}</Title>
+ <MacroJump />
+ <Visor />
+ <SuspenseContextComp
+ fallback={<RootSuspenseFallback />}
>
- {{
- path: '/',
- component: TauriRouteListener,
- children: ROUTES,
- }}
- </IsomorphicRouter>
- </SuspenseContextComp>
- <ToastRegion />
- </SearchProvider>
- </QuickAccessProvider>
- </ChannelsContextProvider>
- </ConfiguredGlobalAppStateProvider>
+ <IsomorphicRouter
+ transformUrl={transformShortIdInUrlPathname}
+ root={Layout}
+ rootPreload={rootPreload}
+ base={ROUTER_BASE}
+ >
+ {{
+ path: '/',
+ component: TauriRouteListener,
+ children: ROUTES,
+ }}
+ </IsomorphicRouter>
+ </SuspenseContextComp>
+ <ToastRegion />
+ </SearchProvider>
+ </QuickAccessProvider>
+ </ChannelsContextProvider>
+ </ConfiguredGlobalAppStateProvider>
+ </PlatformNotificationProvider>
</UserContextProvider>
</EntityProvider>
</PosthogProvider>
diff --git a/js/app/packages/notifications/components/BrowserNotificationModal.tsx b/js/app/packages/notifications/components/BrowserNotificationModal.tsx
index a9bf0530a0..f261ecae7d 100644
--- a/js/app/packages/notifications/components/BrowserNotificationModal.tsx
+++ b/js/app/packages/notifications/components/BrowserNotificationModal.tsx
@@ -1,16 +1,17 @@
import { Dialog } from '@kobalte/core/dialog';
import { createMemo } from 'solid-js';
import { useNotificationSettings } from '../notification-settings';
+import { useIsAuthenticated } from '@queries/auth';
export const BrowserNotificationModal = () => {
const settings = useNotificationSettings();
+ const isAuthenticated = useIsAuthenticated();
+
if (!settings.isSupported) return null;
- // Note: Auth check removed - this component renders outside UserContextProvider.
- // The modal only shows after shouldPrompt() which requires user interaction anyway.
const shouldShow = createMemo(
- () => !import.meta.env.DEV && settings.shouldPrompt()
+ () => !import.meta.env.DEV && settings.shouldPrompt() && isAuthenticated()
);
const handleEnable = async () => {
diff --git a/js/app/packages/notifications/components/PlatformNotificationProvider.tsx b/js/app/packages/notifications/components/PlatformNotificationProvider.tsx
index e26f504f77..38885134a1 100644
--- a/js/app/packages/notifications/components/PlatformNotificationProvider.tsx
+++ b/js/app/packages/notifications/components/PlatformNotificationProvider.tsx
@@ -14,6 +14,7 @@ import type {
PlatformNotificationData,
PlatformNotificationHandle,
} from '../notification-platform';
+import { BrowserNotificationModal } from './BrowserNotificationModal';
type NotGranted = 'not-granted';
@@ -225,6 +226,7 @@ export function PlatformNotificationProvider(props: {
manuallyDisabled={manuallyDisabled}
setManuallyDisabled={setManuallyDisabled}
>
+ <BrowserNotificationModal />
{props.children}
</PlatformNotificationState>
</NotificationInterfaceContext.Provider>
diff --git a/js/app/packages/tauri/src/TauriProvider.tsx b/js/app/packages/tauri/src/TauriProvider.tsx
index 047b0116de..9e507c9281 100644
--- a/js/app/packages/tauri/src/TauriProvider.tsx
+++ b/js/app/packages/tauri/src/TauriProvider.tsx
@@ -1,8 +1,4 @@
import { isTauri } from '@core/util/platform';
-import {
- BrowserNotificationModal,
- PlatformNotificationProvider,
-} from '@notifications';
import type { RouteSectionProps } from '@solidjs/router';
import { type OsType, type as osType } from '@tauri-apps/plugin-os';
import {
@@ -88,12 +84,7 @@ export function MaybeTauriProvider(props: { children: JSX.Element }) {
);
}
- return (
- <PlatformNotificationProvider>
- <BrowserNotificationModal />
- {props.children}
- </PlatformNotificationProvider>
- );
+ return props.children;
}
/// return the value of the tauri context