diff --git a/mobile/src/app/(tabs)/capture.tsx b/mobile/src/app/(tabs)/capture.tsx index 51888b3..65fac6d 100644 --- a/mobile/src/app/(tabs)/capture.tsx +++ b/mobile/src/app/(tabs)/capture.tsx @@ -21,7 +21,9 @@ export default function CaptureScreen() { Quick capture - Create a lightweight mobile draft in {activeWorkspaceName}. Offline queue wiring comes in a later batch. + {activeWorkspaceId + ? `Create a lightweight mobile draft in ${activeWorkspaceName}. Offline queue wiring comes in a later batch.` + : 'Choose a workspace to save this mobile draft. Offline queue wiring comes in a later batch.'} {workspaces.map((workspace: MobileWorkspace) => { @@ -72,9 +74,10 @@ export default function CaptureScreen() { setTitle(''); setBody(''); }} - style={styles.button} + disabled={!activeWorkspaceId} + style={[styles.button, !activeWorkspaceId ? styles.buttonDisabled : null]} > - Save draft + {activeWorkspaceId ? 'Save draft' : 'Select workspace'} {saved ? Draft saved to the product backend. : null} @@ -125,6 +128,9 @@ const styles = StyleSheet.create({ color: colors.textPrimary, fontWeight: '700', }, + buttonDisabled: { + opacity: 0.6, + }, saved: { color: colors.success, fontSize: 14, diff --git a/mobile/src/app/(tabs)/index.tsx b/mobile/src/app/(tabs)/index.tsx index 6b98ec2..d0e2bb7 100644 --- a/mobile/src/app/(tabs)/index.tsx +++ b/mobile/src/app/(tabs)/index.tsx @@ -40,6 +40,14 @@ export default function HomeScreen() { {visibleCount} visible notes ready for quick retrieval + setActiveWorkspace(null)} + style={[styles.workspaceChip, activeWorkspaceId === null ? styles.workspaceChipActive : null]} + > + + All + + {workspaces.map((workspace: MobileWorkspace) => { const isActive = workspace.id === activeWorkspaceId; diff --git a/mobile/src/store/workspace-store.ts b/mobile/src/store/workspace-store.ts index dc5e8f8..7e6351d 100644 --- a/mobile/src/store/workspace-store.ts +++ b/mobile/src/store/workspace-store.ts @@ -5,20 +5,26 @@ export type WorkspaceState = { workspaces: MobileWorkspace[]; activeWorkspaceId: string | null; hydrate: () => Promise; - setActiveWorkspace: (id: string) => void; + setActiveWorkspace: (id: string | null) => void; }; -export const useWorkspaceStore = create((set) => ({ +export const useWorkspaceStore = create((set, get) => ({ workspaces: [], activeWorkspaceId: null, async hydrate() { const workspaces = await listWorkspaces(); + const currentActiveWorkspaceId = get().activeWorkspaceId; set({ workspaces, - activeWorkspaceId: workspaces[0]?.id ?? null, + activeWorkspaceId: + currentActiveWorkspaceId === null + ? null + : workspaces.some((workspace) => workspace.id === currentActiveWorkspaceId) + ? currentActiveWorkspaceId + : workspaces[0]?.id ?? null, }); }, - setActiveWorkspace(id: string) { + setActiveWorkspace(id: string | null) { set({ activeWorkspaceId: id }); }, }));