- Cache queries and songs across mobile and web - Show cached content and skeletons during loading - Move shared playback and cache utilities into Convex client
22 lines
599 B
TypeScript
22 lines
599 B
TypeScript
import type { useRouter } from "expo-router"
|
|
|
|
import { resetPlaybackStores } from "@otunes/convex/client/playback-store"
|
|
import { clearPersistentCache } from "@/lib/persistent-cache"
|
|
|
|
type AppRouter = ReturnType<typeof useRouter>
|
|
|
|
/** Forgets this device's cached library and playback state. */
|
|
export async function clearLocalData() {
|
|
resetPlaybackStores()
|
|
await clearPersistentCache()
|
|
}
|
|
|
|
export async function signOutToSignIn(
|
|
router: Pick<AppRouter, "replace">,
|
|
invalidateSession: () => Promise<void>
|
|
) {
|
|
await invalidateSession()
|
|
await clearLocalData()
|
|
router.replace("/signin")
|
|
}
|