A self-hostable bookmark-everything app (links, notes and images) with AI-based automatic tagging and full text search
fix(mobile): don't silently swallow mutations fired while offline
Mohamed Bassem9188958cd6b2
diff --git a/apps/mobile/app/sharing.tsx b/apps/mobile/app/sharing.tsxindex ffa52694..2c28804b 100644--- a/apps/mobile/app/sharing.tsx+++ b/apps/mobile/app/sharing.tsx@@ -94,12 +94,31 @@ function SaveBookmark({ setMode }: { setMode: (mode: Mode) => void }) {return null;}+// Saving normally settles in well under a second. If we're still idle after+// this long the save is wedged -- an empty share intent leaves nothing to+// mutate, and a request against an unreachable server can hang far longer --+// so offer a way out rather than an indefinite spinner.+const IDLE_ESCAPE_HATCH_MS = 5000;+export default function Sharing() {const router = useRouter();const [mode, setMode] = useState<Mode>({ type: "idle" });+ const [showIdleEscapeHatch, setShowIdleEscapeHatch] = useState(false);const autoCloseTimeoutId = useRef<ReturnType<typeof setTimeout> | null>(null);+ useEffect(() => {+ if (mode.type !== "idle") {+ setShowIdleEscapeHatch(false);+ return;+ }+ const timeoutId = setTimeout(+ () => setShowIdleEscapeHatch(true),+ IDLE_ESCAPE_HATCH_MS,+ );+ return () => clearTimeout(timeoutId);+ }, [mode.type]);+// Auto dismiss the modal after saving.useEffect(() => {if (mode.type === "idle") {@@ -142,7 +161,27 @@ export default function Sharing() {{mode.type === "idle" && <SaveBookmark setMode={setMode} />}{/* Loading State */}- {mode.type === "idle" && <LoadingAnimation />}+ {mode.type === "idle" && (+ <View className="items-center gap-6">+ <LoadingAnimation />+ {showIdleEscapeHatch && (+ <Animated.View+ entering={FadeIn.duration(200)}+ className="items-center gap-2"+ >+ <Text variant="body" className="text-muted-foreground">+ Still saving...+ </Text>+ <Pressable+ onPress={handleDismiss}+ className="px-4 py-2 active:opacity-60"+ >+ <Text className="text-muted-foreground">Dismiss</Text>+ </Pressable>+ </Animated.View>+ )}+ </View>+ )}{/* Success State */}{(mode.type === "success" || mode.type === "alreadyExists") && (diff --git a/apps/mobile/lib/offlineCache.ts b/apps/mobile/lib/offlineCache.tsindex 78c34c93..8b6c3928 100644--- a/apps/mobile/lib/offlineCache.ts+++ b/apps/mobile/lib/offlineCache.ts@@ -24,6 +24,17 @@ export function makeMobileQueryClient() {staleTime: 60_000,gcTime: CACHE_MAX_AGE,},+ mutations: {+ // Now that onlineManager reports the real connectivity state, the+ // default "online" mode would *pause* mutations fired while offline:+ // onError never runs, isPending stays true forever, and because+ // shouldDehydrateMutation is false they aren't persisted either -- so+ // the write is silently lost on app kill with the UI still showing it+ // as succeeded. Fail fast instead, so the existing onError handlers+ // surface a toast. Revisit if we ever implement real offline queuing+ // (persisted mutations + setMutationDefaults + resumePausedMutations).+ networkMode: "always",+ },},});}