diff --git a/src/lib/sidebar-apps.ts b/src/lib/sidebar-apps.ts new file mode 100644 index 00000000..f3e76e3e --- /dev/null +++ b/src/lib/sidebar-apps.ts @@ -0,0 +1,23 @@ +import { Linking } from 'react-native'; +import { useSettingsStore, type SidebarApp } from '../stores/settings-store'; + +/** + * Sidebar apps the user marked "show on mobile". The drawer (SidebarDrawer) + * is expected to render these below the folder list; the settings pane only + * edits them. Mirrors the webmail's navigation-rail filter on `showOnMobile`. + */ +export function useMobileSidebarApps(): SidebarApp[] { + return useSettingsStore((s) => s.sidebarApps.filter((app) => app.showOnMobile)); +} + +/** + * Open a sidebar app. Inline (iframe) apps have no native equivalent yet, so + * both open modes hand the URL to the system browser. + */ +export async function openSidebarApp(app: SidebarApp): Promise { + try { + await Linking.openURL(app.url); + } catch { + // unsupported scheme - nothing to do + } +}