⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
feat(mobile): add whats new sheet
daniel31x13083935a2568f
diff --git a/apps/mobile/app/(tabs)/dashboard/index.tsx b/apps/mobile/app/(tabs)/dashboard/index.tsxindex 9d41b076..a028ef2a 100644--- a/apps/mobile/app/(tabs)/dashboard/index.tsx+++ b/apps/mobile/app/(tabs)/dashboard/index.tsx@@ -11,6 +11,7 @@ import { useQueryClient } from "@tanstack/react-query";import { useDashboardData } from "@linkwarden/router/dashboardData";import { isAtLeastInstanceVersion, useConfig } from "@linkwarden/router/config";import useAuthStore from "@/store/auth";+import { showWhatsNewIfNeeded } from "@/lib/whatsNew";import { DashboardSection as DashboardSectionType } from "@linkwarden/prisma/client";import { useUser } from "@linkwarden/router/user";import { useCollections } from "@linkwarden/router/collections";@@ -25,6 +26,10 @@ const DASHBOARD_TAG_COUNT_VERSION = "2.14.0";export default function DashboardScreen() {const { auth } = useAuthStore();const queryClient = useQueryClient();++ useEffect(() => {+ if (auth.status === "authenticated") showWhatsNewIfNeeded();+ }, [auth.status]);const {data: {links = [],diff --git a/apps/mobile/components/ActionSheets/Sheets.tsx b/apps/mobile/components/ActionSheets/Sheets.tsxindex 5c55c06f..2119642b 100644--- a/apps/mobile/components/ActionSheets/Sheets.tsx+++ b/apps/mobile/components/ActionSheets/Sheets.tsx@@ -17,6 +17,7 @@ import LoginSheet from "./LoginSheet";import SignUpSheet from "./SignUpSheet";import SelfHostedServerSheet from "./SelfHostedServerSheet";import DeleteAccountSheet from "./DeleteAccountSheet";+import WhatsNewSheet from "./WhatsNewSheet";import { LinkIncludingShortenedCollectionAndTags } from "@linkwarden/types/global";registerSheet("support-sheet", SupportSheet);@@ -31,6 +32,7 @@ registerSheet("readable-highlight-sheet", ReadableHighlightSheet);registerSheet("readable-highlights-sheet", ReadableHighlightsSheet);registerSheet("reader-settings-sheet", ReaderSettingsSheet);registerSheet("delete-account-sheet", DeleteAccountSheet);+registerSheet("whats-new-sheet", WhatsNewSheet);declare module "react-native-actions-sheet" {interface Sheets {@@ -74,6 +76,7 @@ declare module "react-native-actions-sheet" {}>;"reader-settings-sheet": SheetDefinition;"delete-account-sheet": SheetDefinition;+ "whats-new-sheet": SheetDefinition;}}diff --git a/apps/mobile/components/ActionSheets/WhatsNewSheet.tsx b/apps/mobile/components/ActionSheets/WhatsNewSheet.tsxnew file mode 100644index 00000000..332c85a4--- /dev/null+++ b/apps/mobile/components/ActionSheets/WhatsNewSheet.tsx@@ -0,0 +1,88 @@+import { Dimensions, Linking, ScrollView, Text, View } from "react-native";+import ActionSheet, { SheetManager } from "react-native-actions-sheet";+import { useColorScheme } from "nativewind";+import { useSafeAreaInsets } from "react-native-safe-area-context";+import { rawTheme, ThemeName } from "@/lib/colors";+import {+ WHATS_NEW_ITEMS,+ WHATS_NEW_LEARN_MORE_URL,+ WHATS_NEW_TITLE,+} from "@/lib/whatsNew";+import { Button } from "../ui/Button";+import SheetHeader from "./SheetHeader";++export default function WhatsNewSheet() {+ const { colorScheme } = useColorScheme();+ const theme = rawTheme[colorScheme as ThemeName];+ const insets = useSafeAreaInsets();++ const closeSheet = () => {+ SheetManager.hide("whats-new-sheet");+ };++ const openLearnMore = () => {+ if (WHATS_NEW_LEARN_MORE_URL) Linking.openURL(WHATS_NEW_LEARN_MORE_URL);+ };++ return (+ <ActionSheet+ gestureEnabled+ indicatorStyle={{+ display: "none",+ }}+ containerStyle={{+ backgroundColor: theme["base-100"],+ }}+ safeAreaInsets={insets}+ >+ <SheetHeader+ title={WHATS_NEW_TITLE}+ onClose={closeSheet}+ titleClassName="text-2xl"+ align="left"+ />++ <ScrollView+ showsVerticalScrollIndicator={false}+ style={{+ maxHeight: Dimensions.get("window").height * 0.7,+ }}+ contentContainerClassName="px-8 pb-5 flex-col gap-5"+ >+ {WHATS_NEW_ITEMS.map((item, index) => {+ const Icon = item.icon;+ return (+ <View key={index} className="flex-row gap-4 items-start">+ <View+ className="mt-0.5 h-10 w-10 items-center justify-center rounded-full"+ style={{ backgroundColor: theme["base-200"] }}+ >+ <Icon size={20} color={theme.primary} />+ </View>+ <View className="flex-1">+ <Text className="text-base-content text-lg font-semibold">+ {item.title}+ </Text>+ <Text className="text-neutral text-base mt-0.5">+ {item.description}+ </Text>+ </View>+ </View>+ );+ })}++ <View className="flex-col gap-3">+ <Button variant="accent" size="lg" onPress={closeSheet}>+ <Text className="text-white text-xl">Got it</Text>+ </Button>++ {WHATS_NEW_LEARN_MORE_URL && (+ <Button variant="outline" size="lg" onPress={openLearnMore}>+ <Text className="text-base-content text-xl">Read the blog</Text>+ </Button>+ )}+ </View>+ </ScrollView>+ </ActionSheet>+ );+}diff --git a/apps/mobile/lib/whatsNew.ts b/apps/mobile/lib/whatsNew.tsnew file mode 100644index 00000000..7bc58891--- /dev/null+++ b/apps/mobile/lib/whatsNew.ts@@ -0,0 +1,93 @@+import {+ BookOpen,+ Highlighter,+ Info,+ WifiOff,+ type LucideIcon,+} from "lucide-react-native";+import { SheetManager } from "react-native-actions-sheet";+import AsyncStorage from "@react-native-async-storage/async-storage";++/**+ * Bump this whenever you want the "What's New" sheet to be shown again.+ *+ * It is intentionally decoupled from the app binary version (app.config.ts) so+ * that patch/minor releases without anything to announce don't re-trigger the+ * sheet. Set it to the release that introduces the features listed below.+ *+ * How the "show once" logic works:+ * - The last version a user has seen is stored in `data.lastSeenWhatsNew`.+ * - Existing users keep their session token across app updates and land+ * straight on the dashboard, where the sheet is shown because their stored+ * value (null) !== WHATS_NEW_VERSION.+ * - Brand-new users go through login/sign-up, which seeds `lastSeenWhatsNew`+ * to the current version (see store/auth.ts) so they don't see it.+ */+export const WHATS_NEW_VERSION = "1.3.0";++export const WHATS_NEW_TITLE = "What's New";++/**+ * Optional URL for a "Learn more" button shown below the "Got it" button.+ * Leave as `null` to hide the button.+ */+export const WHATS_NEW_LEARN_MORE_URL: string | null = null;++export type WhatsNewItem = {+ icon: LucideIcon;+ title: string;+ description: string;+};++/**+ * Edit this list for each release. Leaving it empty disables the sheet.+ */+export const WHATS_NEW_ITEMS: WhatsNewItem[] = [+ {+ icon: Highlighter,+ title: "Highlight & Annotate",+ description:+ "Highlight passages and add your own notes inside the reader view.",+ },+ {+ icon: BookOpen,+ title: "Customizable reader view",+ description:+ "Tune fonts, sizes, and other display settings for a more comfortable reading experience.",+ },+ {+ icon: WifiOff,+ title: "True offline mode",+ description:+ "View the contents of your saved links with no connection at all. Configurable from the settings.",+ },+ {+ icon: Info,+ title: "Link details sheet",+ description: "View a link's details in a quick bottom sheet.",+ },+];++const LAST_SEEN_STORAGE_KEY = "whatsNewLastSeen";++let presented = false;++export const markWhatsNewSeen = () =>+ AsyncStorage.setItem(LAST_SEEN_STORAGE_KEY, WHATS_NEW_VERSION);++/**+ * Shows the "What's New" sheet at most once per release, then records it as+ * seen. Safe to call on every launch: it no-ops if there's nothing to show or+ * the current version was already seen, and only ever presents once per app+ * session.+ */+export async function showWhatsNewIfNeeded() {+ if (presented || WHATS_NEW_ITEMS.length === 0) return;+ presented = true;++ const lastSeen = await AsyncStorage.getItem(LAST_SEEN_STORAGE_KEY);+ if (lastSeen === WHATS_NEW_VERSION) return;++ await markWhatsNewSeen();+ SheetManager.show("whats-new-sheet");+}diff --git a/apps/mobile/store/auth.ts b/apps/mobile/store/auth.tsindex 59536b9d..1dee9136 100644--- a/apps/mobile/store/auth.ts+++ b/apps/mobile/store/auth.ts@@ -14,6 +14,7 @@ import { queryClient } from "@/lib/queryClient";import { mmkvPersister } from "@/lib/queryPersister";import { clearCache } from "@/lib/cache";import useDataStore from "@/store/data";+import { markWhatsNewSeen } from "@/lib/whatsNew";import { useOfflineSyncStore } from "@/lib/offlineSync";import { hasInactiveSubscription } from "@/lib/subscription";import { ensureCloudIsReachable } from "@/lib/ensureCloudIsReachable";@@ -92,6 +93,8 @@ type AuthStore = {const cleanInstance = (instance?: string | null) =>(instance || cloudInstance).trim().replace(/\/+$/, "");+const markWhatsNewSeenForNewUser = () => markWhatsNewSeen();+const getFallbackConfig = (instance: string) =>instance === cloudInstance ? cloudConfig : null;@@ -358,6 +361,7 @@ const useAuthStore = create<AuthStore>((set, get) => ({status: "authenticated",},});+ markWhatsNewSeenForNewUser();router.replace(route);return true;} else {@@ -399,6 +403,7 @@ const useAuthStore = create<AuthStore>((set, get) => ({await SecureStore.setItemAsync("TOKEN", session);await SecureStore.setItemAsync("INSTANCE", instance);set({ auth: { session, instance, status: "authenticated" } });+ markWhatsNewSeenForNewUser();router.replace(route);return true;} else {@@ -472,6 +477,7 @@ const useAuthStore = create<AuthStore>((set, get) => ({await SecureStore.setItemAsync("TOKEN", session);await SecureStore.setItemAsync("INSTANCE", instance);set({ auth: { session, instance, status: "authenticated" } });+ markWhatsNewSeenForNewUser();router.replace(route);} else {Alert.alert("Error", data?.response || "Could not sign in with Apple.");@@ -540,6 +546,7 @@ const useAuthStore = create<AuthStore>((set, get) => ({await SecureStore.setItemAsync("TOKEN", session);await SecureStore.setItemAsync("INSTANCE", instance);set({ auth: { session, instance, status: "authenticated" } });+ markWhatsNewSeenForNewUser();router.replace(route);} else {Alert.alert(diff --git a/apps/mobile/store/data.ts b/apps/mobile/store/data.tsindex 56660222..ef25c0ec 100644--- a/apps/mobile/store/data.ts+++ b/apps/mobile/store/data.ts@@ -5,8 +5,8 @@ import { colorScheme } from "nativewind";type DataStore = {data: MobileData;- updateData: (newData: Partial<MobileData>) => void;- setData: () => void;+ updateData: (newData: Partial<MobileData>) => Promise<void>;+ setData: () => Promise<void>;};const useDataStore = create<DataStore>((set, get) => ({@@ -25,8 +25,7 @@ const useDataStore = create<DataStore>((set, get) => ({colorScheme.set(dataString.theme || "system");- if (dataString)- set((state) => ({ data: { ...state.data, ...dataString } }));+ set((state) => ({ data: { ...state.data, ...dataString } }));},updateData: async (patch) => {const merged = { ...get().data, ...patch };