chore: storage delete JSONR

This commit is contained in:
molvqingtai 2024-11-06 18:17:33 +08:00
parent 893342a317
commit 7681682445
2 changed files with 11 additions and 23 deletions

View file

@ -281,7 +281,6 @@ const RoomDomain = Remesh.domain({
name: 'Room.SendSyncHistoryMessageCommand',
impl: ({ get }, { peerId, lastMessageTime }: { peerId: string; lastMessageTime: number }) => {
const self = get(SelfUserQuery())
console.log('SendSyncHistoryMessageCommand', peerId, peerRoom.peerId)
const historyMessages = get(messageListDomain.query.ListQuery()).filter(
(message) =>

View file

@ -7,7 +7,11 @@ import { webExtensionDriver } from '@/utils/webExtensionDriver'
import { Storage } from '@/domain/externs/Storage'
import { EVENT } from '@/constants/event'
import { JSONR } from '@/utils'
/**
* Waiting to be resolved
* @see https://github.com/unjs/unstorage/issues/277
* */
export const localStorage = createStorage({
driver: localStorageDriver({ base: `${STORAGE_NAME}:` })
@ -23,8 +27,8 @@ export const browserSyncStorage = createStorage({
export const LocalStorageImpl = LocalStorageExtern.impl({
name: STORAGE_NAME,
get: async (key) => JSONR.parse(await localStorage.getItem(key)),
set: (key, value) => localStorage.setItem(key, JSONR.stringify(value)),
get: localStorage.getItem,
set: localStorage.setItem,
remove: localStorage.removeItem,
clear: localStorage.clear,
watch: async (callback) => {
@ -46,14 +50,8 @@ export const LocalStorageImpl = LocalStorageExtern.impl({
export const IndexDBStorageImpl = IndexDBStorageExtern.impl({
name: STORAGE_NAME,
get: async (key) => JSONR.parse(await indexDBStorage.getItem(key)),
set: (key, value) => {
/**
* Waiting to be resolved
* @see https://github.com/unjs/unstorage/issues/277
* */
return indexDBStorage.setItem(key, JSONR.stringify(value))
},
get: indexDBStorage.getItem,
set: indexDBStorage.setItem,
remove: indexDBStorage.removeItem,
clear: indexDBStorage.clear,
watch: indexDBStorage.watch as Storage['watch'],
@ -62,17 +60,8 @@ export const IndexDBStorageImpl = IndexDBStorageExtern.impl({
export const BrowserSyncStorageImpl = BrowserSyncStorageExtern.impl({
name: STORAGE_NAME,
get: async (key) => {
const value: any = await browserSyncStorage.getItem(key)
// Compatibility with old version data
try {
return JSONR.parse(value)
} catch {
return value
}
},
set: (key, value) => browserSyncStorage.setItem(key, JSONR.stringify(value)),
get: browserSyncStorage.getItem,
set: browserSyncStorage.setItem,
remove: browserSyncStorage.removeItem,
clear: browserSyncStorage.clear,
watch: browserSyncStorage.watch as Storage['watch'],