Skip to content

Commit

Permalink
feat: Migrate Offline's platform storage from AsyncStorage to MMKV
Browse files Browse the repository at this point in the history
  • Loading branch information
Ldoppea committed Dec 20, 2024
1 parent 270fe87 commit 8092d9e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pouchdb/platformReactNative.storage.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import AsyncStorage from '@react-native-async-storage/async-storage'
import { storage as mmkvStorage } from '/libs/localStore'

export const storage = {
getItem: async (key: string): Promise<string | null> => {
return AsyncStorage.getItem(key)
return Promise.resolve(mmkvStorage.getString(key) ?? null)
},
setItem: async (key: string, value: string | undefined): Promise<void> => {
if (value === undefined) return
return AsyncStorage.setItem(key, value)
return Promise.resolve(mmkvStorage.set(key, value))
},
removeItem: async (key: string): Promise<void> => {
return AsyncStorage.removeItem(key)
return Promise.resolve(mmkvStorage.delete(key))
}
}

0 comments on commit 8092d9e

Please sign in to comment.