mirror of
https://github.com/anultravioletaurora/Jellify.git
synced 2025-12-21 13:30:11 -06:00
MMKV to V4 (#823)
* fix: plugins * fix: plugins * update locks --------- Co-authored-by: Violet Caulfield <violet@cosmonautical.cloud>
This commit is contained in:
4
bun.lock
4
bun.lock
@@ -43,7 +43,7 @@
|
||||
"react-native-google-cast": "^4.9.1",
|
||||
"react-native-haptic-feedback": "^2.3.3",
|
||||
"react-native-linear-gradient": "^2.8.3",
|
||||
"react-native-mmkv": "3.3.3",
|
||||
"react-native-mmkv": "^4.1.0",
|
||||
"react-native-nitro-fetch": "^0.1.6",
|
||||
"react-native-nitro-modules": "0.31.10",
|
||||
"react-native-nitro-ota": "0.7.2",
|
||||
@@ -1926,7 +1926,7 @@
|
||||
|
||||
"react-native-linear-gradient": ["react-native-linear-gradient@2.8.3", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-KflAXZcEg54PXkLyflaSZQ3PJp4uC4whM7nT/Uot9m0e/qxFV3p6uor1983D1YOBJbJN7rrWdqIjq0T42jOJyA=="],
|
||||
|
||||
"react-native-mmkv": ["react-native-mmkv@3.3.3", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-GMsfOmNzx0p5+CtrCFRVtpOOMYNJXuksBVARSQrCFaZwjUyHJdQzcN900GGaFFNTxw2fs8s5Xje//RDKj9+PZA=="],
|
||||
"react-native-mmkv": ["react-native-mmkv@4.1.0", "", { "peerDependencies": { "react": "*", "react-native": "*", "react-native-nitro-modules": "*" } }, "sha512-ia76WnU6dkLZxFkSSflxqFgHT2pIaML763aucEu7nMglF41oEWTdTtBu0o8a1cxbhZOaONk6KF8RQp5fLvPitA=="],
|
||||
|
||||
"react-native-nitro-fetch": ["react-native-nitro-fetch@0.1.6", "", { "peerDependencies": { "react": "*", "react-native": "*", "react-native-nitro-modules": "^0.29.2", "react-native-worklets-core": "^1.6.0" }, "optionalPeers": ["react-native-worklets-core"] }, "sha512-DbE/vN5B67SJM8Q0myHOwSSc7ASqJPaKYXVsWdNGIPS+csr9gygCKILT4RQ+xZ92iJGKn4bfyq+rRsacRWBV9A=="],
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ PODS:
|
||||
- hermes-engine (0.14.0):
|
||||
- hermes-engine/Pre-built (= 0.14.0)
|
||||
- hermes-engine/Pre-built (0.14.0)
|
||||
- MMKVCore (2.2.4)
|
||||
- NitroFetch (0.1.6):
|
||||
- boost
|
||||
- DoubleConversion
|
||||
@@ -42,6 +43,37 @@ PODS:
|
||||
- ReactCommon/turbomodule/core
|
||||
- SocketRocket
|
||||
- Yoga
|
||||
- NitroMmkv (4.1.0):
|
||||
- boost
|
||||
- DoubleConversion
|
||||
- fast_float
|
||||
- fmt
|
||||
- glog
|
||||
- hermes-engine
|
||||
- MMKVCore (= 2.2.4)
|
||||
- NitroModules
|
||||
- RCT-Folly
|
||||
- RCT-Folly/Fabric
|
||||
- RCTRequired
|
||||
- RCTTypeSafety
|
||||
- React-callinvoker
|
||||
- React-Core
|
||||
- React-debug
|
||||
- React-Fabric
|
||||
- React-featureflags
|
||||
- React-graphics
|
||||
- React-ImageManager
|
||||
- React-jsi
|
||||
- React-NativeModulesApple
|
||||
- React-RCTFabric
|
||||
- React-renderercss
|
||||
- React-rendererdebug
|
||||
- React-utils
|
||||
- ReactCodegen
|
||||
- ReactCommon/turbomodule/bridging
|
||||
- ReactCommon/turbomodule/core
|
||||
- SocketRocket
|
||||
- Yoga
|
||||
- NitroModules (0.31.10):
|
||||
- boost
|
||||
- DoubleConversion
|
||||
@@ -2084,34 +2116,6 @@ PODS:
|
||||
- google-cast-sdk
|
||||
- PromisesObjC
|
||||
- React
|
||||
- react-native-mmkv (3.3.3):
|
||||
- boost
|
||||
- DoubleConversion
|
||||
- fast_float
|
||||
- fmt
|
||||
- glog
|
||||
- hermes-engine
|
||||
- RCT-Folly
|
||||
- RCT-Folly/Fabric
|
||||
- RCTRequired
|
||||
- RCTTypeSafety
|
||||
- React-Core
|
||||
- React-debug
|
||||
- React-Fabric
|
||||
- React-featureflags
|
||||
- React-graphics
|
||||
- React-ImageManager
|
||||
- React-jsi
|
||||
- React-NativeModulesApple
|
||||
- React-RCTFabric
|
||||
- React-renderercss
|
||||
- React-rendererdebug
|
||||
- React-utils
|
||||
- ReactCodegen
|
||||
- ReactCommon/turbomodule/bridging
|
||||
- ReactCommon/turbomodule/core
|
||||
- SocketRocket
|
||||
- Yoga
|
||||
- react-native-netinfo (11.4.1):
|
||||
- React-Core
|
||||
- react-native-pager-view (7.0.2):
|
||||
@@ -3251,6 +3255,7 @@ DEPENDENCIES:
|
||||
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
|
||||
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
|
||||
- NitroFetch (from `../node_modules/react-native-nitro-fetch`)
|
||||
- NitroMmkv (from `../node_modules/react-native-mmkv`)
|
||||
- NitroModules (from `../node_modules/react-native-nitro-modules`)
|
||||
- NitroOta (from `../node_modules/react-native-nitro-ota`)
|
||||
- NitroOtaBundleManager (from `../node_modules/react-native-nitro-ota`)
|
||||
@@ -3297,7 +3302,6 @@ DEPENDENCIES:
|
||||
- react-native-carplay (from `../node_modules/react-native-carplay`)
|
||||
- react-native-config (from `../node_modules/react-native-config`)
|
||||
- react-native-google-cast (from `../node_modules/react-native-google-cast`)
|
||||
- react-native-mmkv (from `../node_modules/react-native-mmkv`)
|
||||
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
|
||||
- react-native-pager-view (from `../node_modules/react-native-pager-view`)
|
||||
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
|
||||
@@ -3355,6 +3359,7 @@ DEPENDENCIES:
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- google-cast-sdk
|
||||
- MMKVCore
|
||||
- PromisesObjC
|
||||
- Protobuf
|
||||
- SDWebImage
|
||||
@@ -3383,6 +3388,8 @@ EXTERNAL SOURCES:
|
||||
:tag: hermes-v0.14.0
|
||||
NitroFetch:
|
||||
:path: "../node_modules/react-native-nitro-fetch"
|
||||
NitroMmkv:
|
||||
:path: "../node_modules/react-native-mmkv"
|
||||
NitroModules:
|
||||
:path: "../node_modules/react-native-nitro-modules"
|
||||
NitroOta:
|
||||
@@ -3473,8 +3480,6 @@ EXTERNAL SOURCES:
|
||||
:path: "../node_modules/react-native-config"
|
||||
react-native-google-cast:
|
||||
:path: "../node_modules/react-native-google-cast"
|
||||
react-native-mmkv:
|
||||
:path: "../node_modules/react-native-mmkv"
|
||||
react-native-netinfo:
|
||||
:path: "../node_modules/@react-native-community/netinfo"
|
||||
react-native-pager-view:
|
||||
@@ -3588,7 +3593,9 @@ SPEC CHECKSUMS:
|
||||
glog: 5683914934d5b6e4240e497e0f4a3b42d1854183
|
||||
google-cast-sdk: 1fb6724e94cc5ff23b359176e0cf6360586bb97a
|
||||
hermes-engine: 83ac7cadb2a3a158ae6d9e4192417c5232065e99
|
||||
MMKVCore: f2dd4c9befea04277a55e84e7812f930537993df
|
||||
NitroFetch: 660adfb47f84b28db664f97b50e5dc28506ab6c1
|
||||
NitroMmkv: ce1df9b9f0e06dfbde2455d863047e0411fceb6e
|
||||
NitroModules: 5bc319d441f4983894ea66b1d392c519536e6d23
|
||||
NitroOta: 7755c4728f7348584cebb2d428480b1ed0cd2679
|
||||
NitroOtaBundleManager: 482abb17f0ca629ad551da43f13e76e59dba9568
|
||||
@@ -3636,7 +3643,6 @@ SPEC CHECKSUMS:
|
||||
react-native-carplay: 8f388f6f73e5e0f73ed154ad8794371343ee20c0
|
||||
react-native-config: f1dde39f8468ad922fc7e8bd4308c8e6223d5ee8
|
||||
react-native-google-cast: 7be68a5d0b7eeb95a5924c3ecef8d319ef6c0a44
|
||||
react-native-mmkv: ac7507625cd74bac0eb5333604a7cd7b08fe9e3e
|
||||
react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187
|
||||
react-native-pager-view: 5c3098839820aa73d75873e7b1a7eb9f119602b7
|
||||
react-native-safe-area-context: c00143b4823773bba23f2f19f85663ae89ceb460
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
"react-native-google-cast": "^4.9.1",
|
||||
"react-native-haptic-feedback": "^2.3.3",
|
||||
"react-native-linear-gradient": "^2.8.3",
|
||||
"react-native-mmkv": "3.3.3",
|
||||
"react-native-mmkv": "^4.1.0",
|
||||
"react-native-nitro-fetch": "^0.1.6",
|
||||
"react-native-nitro-modules": "0.31.10",
|
||||
"react-native-nitro-ota": "0.7.2",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MMKV } from 'react-native-mmkv'
|
||||
import { createMMKV } from 'react-native-mmkv'
|
||||
|
||||
import RNFS from 'react-native-fs'
|
||||
import JellifyTrack from '../../../types/JellifyTrack'
|
||||
@@ -117,7 +117,7 @@ export async function downloadJellyfinFile(
|
||||
}
|
||||
}
|
||||
|
||||
const mmkv = new MMKV({
|
||||
const mmkv = createMMKV({
|
||||
id: 'offlineMode',
|
||||
encryptionKey: 'offlineMode',
|
||||
})
|
||||
@@ -309,7 +309,7 @@ export const deleteDownloadsByIds = async (
|
||||
export const deleteAudioCache = async (): Promise<DeleteDownloadsResult> => {
|
||||
const downloads = getAudioCache()
|
||||
const result = await deleteDownloadsByIds(downloads.map((download) => download.item.Id))
|
||||
mmkv.delete(MMKV_OFFLINE_MODE_KEYS.AUDIO_CACHE)
|
||||
mmkv.remove(MMKV_OFFLINE_MODE_KEYS.AUDIO_CACHE)
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export default function LabsTab(): React.JSX.Element {
|
||||
children: (
|
||||
<Button
|
||||
onPress={() => {
|
||||
storage.delete(QueryKeys.InfiniteArtists)
|
||||
storage.remove(QueryKeys.InfiniteArtists)
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [QueryKeys.InfiniteArtists],
|
||||
})
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { MMKV } from 'react-native-mmkv'
|
||||
import { createMMKV } from 'react-native-mmkv'
|
||||
import { createAsyncStoragePersister } from '@tanstack/query-async-storage-persister'
|
||||
import { AsyncStorage as TanstackAsyncStorage } from '@tanstack/react-query-persist-client'
|
||||
import { StateStorage } from 'zustand/middleware'
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage'
|
||||
|
||||
export const storage = new MMKV()
|
||||
export const storage = createMMKV()
|
||||
storage.recrypt('jellify-storage')
|
||||
|
||||
const storageFunctions = {
|
||||
setItem: async (key: string, value: string) => {
|
||||
@@ -28,7 +29,7 @@ const mmkvStorageFunctions = {
|
||||
return value === undefined ? null : value
|
||||
},
|
||||
removeItem: (key: string) => {
|
||||
storage.delete(key)
|
||||
storage.remove(key)
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { MMKV } from 'react-native-mmkv'
|
||||
import { createMMKV } from 'react-native-mmkv'
|
||||
import { StateStorage } from 'zustand/middleware'
|
||||
import { storage } from './storage'
|
||||
|
||||
@@ -19,14 +19,17 @@ export const STORAGE_SCHEMA_VERSIONS: Record<string, number> = {
|
||||
* Checks if a specific store needs to be cleared due to version bump
|
||||
* and clears it if necessary
|
||||
*/
|
||||
export function migrateStorageIfNeeded(storeName: string, storage: MMKV): void {
|
||||
export function migrateStorageIfNeeded(
|
||||
storeName: string,
|
||||
storage: ReturnType<typeof createMMKV>,
|
||||
): void {
|
||||
const versionKey = `${STORAGE_VERSION_KEY}:${storeName}`
|
||||
const storedVersion = storage.getNumber(versionKey)
|
||||
const currentVersion = STORAGE_SCHEMA_VERSIONS[storeName] ?? 1
|
||||
|
||||
if (storedVersion !== currentVersion) {
|
||||
// Clear the stale storage for this specific store
|
||||
storage.delete(storeName)
|
||||
storage.remove(storeName)
|
||||
// Update the version
|
||||
storage.set(versionKey, currentVersion)
|
||||
console.log(
|
||||
@@ -56,7 +59,7 @@ export function createVersionedMmkvStorage(storeName: string): StateStorage {
|
||||
storage.set(key, value)
|
||||
},
|
||||
removeItem: (key: string) => {
|
||||
storage.delete(key)
|
||||
storage.remove(key)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -67,8 +70,8 @@ export function createVersionedMmkvStorage(storeName: string): StateStorage {
|
||||
*/
|
||||
export function clearAllVersionedStorage(): void {
|
||||
Object.keys(STORAGE_SCHEMA_VERSIONS).forEach((storeName) => {
|
||||
storage.delete(storeName)
|
||||
storage.delete(`${STORAGE_VERSION_KEY}:${storeName}`)
|
||||
storage.remove(storeName)
|
||||
storage.remove(`${STORAGE_VERSION_KEY}:${storeName}`)
|
||||
})
|
||||
console.log('[Storage] Cleared all versioned storage')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user