diff --git a/apps/mobile/app.json b/apps/mobile/app.json
index c43ce32..371f94d 100644
--- a/apps/mobile/app.json
+++ b/apps/mobile/app.json
@@ -54,6 +54,7 @@
"expo-status-bar",
"expo-app-intents",
"./plugins/with-android-colors",
+ "./plugins/with-android-fast-fade",
[
"expo-navigation-bar",
{
diff --git a/apps/mobile/app/(app)/(tabs)/home/settings.tsx b/apps/mobile/app/(app)/(tabs)/home/settings.tsx
index 30a0cfb..e3181df 100644
--- a/apps/mobile/app/(app)/(tabs)/home/settings.tsx
+++ b/apps/mobile/app/(app)/(tabs)/home/settings.tsx
@@ -27,6 +27,7 @@ import {
} from "@/lib/artwork-color-preference"
import { initialsFromName } from "@/lib/format"
import { useCachedQuery } from "@/hooks/use-cached-query"
+import { clearCoverPaletteCache } from "@/hooks/use-cover-palette"
import { changeServer, signOut } from "@/lib/session"
import { radius, spacing, useThemeColors } from "@/lib/theme"
import { showError } from "@/lib/toast"
@@ -186,6 +187,7 @@ function AppearanceSection() {
setSaving(true)
try {
await setArtworkColorsEnabled(checked)
+ clearCoverPaletteCache()
} catch {
showError("Could not save artwork colors preference.")
} finally {
diff --git a/apps/mobile/hooks/use-cover-palette.ts b/apps/mobile/hooks/use-cover-palette.ts
index 7280c45..778060c 100644
--- a/apps/mobile/hooks/use-cover-palette.ts
+++ b/apps/mobile/hooks/use-cover-palette.ts
@@ -3,7 +3,11 @@ import {
artworkColorsEnabled,
useArtworkColorsEnabled,
} from "@/lib/artwork-color-preference"
-import { prefetchLegacyCoverPalette, useLegacyCoverPalette } from "@/hooks/use-legacy-cover-palette"
+import {
+ clearLegacyCoverPaletteCache,
+ prefetchLegacyCoverPalette,
+ useLegacyCoverPalette,
+} from "@/hooks/use-legacy-cover-palette"
import { extractCoverSwatches } from "@/lib/artwork-colors"
import {
@@ -55,6 +59,16 @@ function extractSwatches(key: string) {
return request
}
+/**
+ * Forget every extracted palette, in memory and on device, so covers are
+ * re-extracted. Both algorithms share the `palette:` cache prefix.
+ */
+export function clearCoverPaletteCache() {
+ swatchesByKey.clear()
+ pending.clear()
+ clearLegacyCoverPaletteCache()
+}
+
/** Warm visible artwork colors before a detail page is pushed. */
export function prefetchCoverPalette(uri: string) {
if (!artworkColorsEnabled()) {
diff --git a/apps/mobile/hooks/use-legacy-cover-palette.ts b/apps/mobile/hooks/use-legacy-cover-palette.ts
index 49a7350..6276f3d 100644
--- a/apps/mobile/hooks/use-legacy-cover-palette.ts
+++ b/apps/mobile/hooks/use-legacy-cover-palette.ts
@@ -6,7 +6,7 @@ import {
type CoverPalette,
} from "@/lib/cover-palette"
import { deriveCoverPalette, type LegacyCoverSwatches as CoverSwatches } from "@/lib/legacy-cover-palette"
-import { readCache, writeCache } from "@/lib/persistent-cache"
+import { clearCachePrefix, readCache, writeCache } from "@/lib/persistent-cache"
import { useIsDark, useThemeColors } from "@/lib/theme"
import { withCoverImageSize } from "@/lib/urls"
@@ -99,6 +99,13 @@ function extractSwatches(key: string) {
}
/** Warm visible artwork colors before a detail page is pushed. */
+/** Forget extracted legacy swatches, in memory and on device. */
+export function clearLegacyCoverPaletteCache() {
+ swatchesByKey.clear()
+ pending.clear()
+ clearCachePrefix("palette")
+}
+
export function prefetchLegacyCoverPalette(uri: string) {
const key = withCoverImageSize(uri, 64)
if (cachedSwatches(key) !== undefined) return
diff --git a/apps/mobile/lib/navigation.ts b/apps/mobile/lib/navigation.ts
index 3340a10..e5dd5f8 100644
--- a/apps/mobile/lib/navigation.ts
+++ b/apps/mobile/lib/navigation.ts
@@ -28,7 +28,7 @@ export function useStackScreenOptions(
headerBackButtonDisplayMode: "minimal",
...(Platform.OS === "android"
? {
- animation: "slide_from_right",
+ animation: "fade",
headerLargeTitle: false,
headerTransparent: false,
headerStyle: { backgroundColor: theme.background },
diff --git a/apps/mobile/plugins/with-android-fast-fade.js b/apps/mobile/plugins/with-android-fast-fade.js
new file mode 100644
index 0000000..6554c56
--- /dev/null
+++ b/apps/mobile/plugins/with-android-fast-fade.js
@@ -0,0 +1,36 @@
+const fs = require("fs")
+const path = require("path")
+const { withDangerousMod } = require("expo/config-plugins")
+
+// Overrides react-native-screens' 150ms crossfade for `animation: "fade"`.
+// App resources win over library resources with the same name, so the stack
+// fades through black in 100ms: the old page out, then the new page in.
+const anims = {
+ "rns_fade_out.xml": `
+`,
+ "rns_fade_in.xml": `
+`,
+}
+
+module.exports = (config) =>
+ withDangerousMod(config, [
+ "android",
+ (config) => {
+ const dir = path.join(
+ config.modRequest.platformProjectRoot,
+ "app/src/main/res/anim"
+ )
+ fs.mkdirSync(dir, { recursive: true })
+ for (const [name, xml] of Object.entries(anims)) {
+ fs.writeFileSync(path.join(dir, name), `\n${xml}`)
+ }
+ return config
+ },
+ ])
diff --git a/packages/convex/client/persistent-cache.ts b/packages/convex/client/persistent-cache.ts
index 15bebac..6704297 100644
--- a/packages/convex/client/persistent-cache.ts
+++ b/packages/convex/client/persistent-cache.ts
@@ -198,6 +198,15 @@ export async function clearPersistentCache() {
}
}
+/** Deletes every entry whose key starts with `:`. */
+export function clearCachePrefix(prefix: string) {
+ for (const key of [...memory.keys()]) {
+ if (entryPrefix(key) !== prefix) continue
+ removeFromMemory(key)
+ scheduleWrite(key, null)
+ }
+}
+
export function subscribeCache(key: string, listener: () => void) {
let keyListeners = listeners.get(key)
if (!keyListeners) {