From acdedbcb9a9e7a83859898a4efff8ab73ddf72c7 Mon Sep 17 00:00:00 2001 From: saravanakumardb1 Date: Mon, 30 Mar 2026 23:58:03 -0700 Subject: [PATCH] feat(mobile): add kill switch gate in root layout --- mobile/src/app/_layout.tsx | 51 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/mobile/src/app/_layout.tsx b/mobile/src/app/_layout.tsx index 2f648e1..81d5b4c 100644 --- a/mobile/src/app/_layout.tsx +++ b/mobile/src/app/_layout.tsx @@ -1,19 +1,43 @@ -import { useEffect } from 'react'; +import { useEffect, useState } from 'react'; import { Stack } from 'expo-router'; import { StatusBar } from 'expo-status-bar'; +import { Text, View } from 'react-native'; import { useAuthStore, type AuthState } from '../store/auth-store'; import { useInboxStore, type InboxState } from '../store/inbox-store'; import { useNotesStore, type NotesState } from '../store/notes-store'; import { useWorkspaceStore, type WorkspaceState } from '../store/workspace-store'; -import { initPlatform } from '../lib/platform'; +import { checkKillSwitch, initPlatform } from '../lib/platform'; +import { colors } from '../theme'; export default function RootLayout() { + const [killSwitchState, setKillSwitchState] = useState<{ + checked: boolean; + disabled: boolean; + message: string | null; + }>({ + checked: false, + disabled: false, + message: null, + }); + const bootstrapAuth = useAuthStore((state: AuthState) => state.bootstrap); const hydrateInbox = useInboxStore((state: InboxState) => state.hydrate); const hydrateNotes = useNotesStore((state: NotesState) => state.hydrate); const hydrateWorkspaces = useWorkspaceStore((state: WorkspaceState) => state.hydrate); useEffect(() => { + void checkKillSwitch() + .then((state) => { + setKillSwitchState({ + checked: true, + disabled: state.disabled, + message: state.message, + }); + }) + .catch(() => { + setKillSwitchState({ checked: true, disabled: false, message: null }); + }); + void bootstrapAuth(); void initPlatform(); void hydrateNotes(); @@ -21,6 +45,29 @@ export default function RootLayout() { void hydrateInbox(); }, [bootstrapAuth, hydrateInbox, hydrateNotes, hydrateWorkspaces]); + if (killSwitchState.checked && killSwitchState.disabled) { + return ( + + + + NoteLett is temporarily unavailable + + + {killSwitchState.message ?? 'Service access is currently paused by the platform team. Please try again later.'} + + + ); + } + return ( <>