chore: storage delete JSONR
This commit is contained in:
parent
893342a317
commit
7681682445
2 changed files with 11 additions and 23 deletions
|
@ -281,7 +281,6 @@ const RoomDomain = Remesh.domain({
|
||||||
name: 'Room.SendSyncHistoryMessageCommand',
|
name: 'Room.SendSyncHistoryMessageCommand',
|
||||||
impl: ({ get }, { peerId, lastMessageTime }: { peerId: string; lastMessageTime: number }) => {
|
impl: ({ get }, { peerId, lastMessageTime }: { peerId: string; lastMessageTime: number }) => {
|
||||||
const self = get(SelfUserQuery())
|
const self = get(SelfUserQuery())
|
||||||
console.log('SendSyncHistoryMessageCommand', peerId, peerRoom.peerId)
|
|
||||||
|
|
||||||
const historyMessages = get(messageListDomain.query.ListQuery()).filter(
|
const historyMessages = get(messageListDomain.query.ListQuery()).filter(
|
||||||
(message) =>
|
(message) =>
|
||||||
|
|
|
@ -7,7 +7,11 @@ import { webExtensionDriver } from '@/utils/webExtensionDriver'
|
||||||
|
|
||||||
import { Storage } from '@/domain/externs/Storage'
|
import { Storage } from '@/domain/externs/Storage'
|
||||||
import { EVENT } from '@/constants/event'
|
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({
|
export const localStorage = createStorage({
|
||||||
driver: localStorageDriver({ base: `${STORAGE_NAME}:` })
|
driver: localStorageDriver({ base: `${STORAGE_NAME}:` })
|
||||||
|
@ -23,8 +27,8 @@ export const browserSyncStorage = createStorage({
|
||||||
|
|
||||||
export const LocalStorageImpl = LocalStorageExtern.impl({
|
export const LocalStorageImpl = LocalStorageExtern.impl({
|
||||||
name: STORAGE_NAME,
|
name: STORAGE_NAME,
|
||||||
get: async (key) => JSONR.parse(await localStorage.getItem(key)),
|
get: localStorage.getItem,
|
||||||
set: (key, value) => localStorage.setItem(key, JSONR.stringify(value)),
|
set: localStorage.setItem,
|
||||||
remove: localStorage.removeItem,
|
remove: localStorage.removeItem,
|
||||||
clear: localStorage.clear,
|
clear: localStorage.clear,
|
||||||
watch: async (callback) => {
|
watch: async (callback) => {
|
||||||
|
@ -46,14 +50,8 @@ export const LocalStorageImpl = LocalStorageExtern.impl({
|
||||||
|
|
||||||
export const IndexDBStorageImpl = IndexDBStorageExtern.impl({
|
export const IndexDBStorageImpl = IndexDBStorageExtern.impl({
|
||||||
name: STORAGE_NAME,
|
name: STORAGE_NAME,
|
||||||
get: async (key) => JSONR.parse(await indexDBStorage.getItem(key)),
|
get: indexDBStorage.getItem,
|
||||||
set: (key, value) => {
|
set: indexDBStorage.setItem,
|
||||||
/**
|
|
||||||
* Waiting to be resolved
|
|
||||||
* @see https://github.com/unjs/unstorage/issues/277
|
|
||||||
* */
|
|
||||||
return indexDBStorage.setItem(key, JSONR.stringify(value))
|
|
||||||
},
|
|
||||||
remove: indexDBStorage.removeItem,
|
remove: indexDBStorage.removeItem,
|
||||||
clear: indexDBStorage.clear,
|
clear: indexDBStorage.clear,
|
||||||
watch: indexDBStorage.watch as Storage['watch'],
|
watch: indexDBStorage.watch as Storage['watch'],
|
||||||
|
@ -62,17 +60,8 @@ export const IndexDBStorageImpl = IndexDBStorageExtern.impl({
|
||||||
|
|
||||||
export const BrowserSyncStorageImpl = BrowserSyncStorageExtern.impl({
|
export const BrowserSyncStorageImpl = BrowserSyncStorageExtern.impl({
|
||||||
name: STORAGE_NAME,
|
name: STORAGE_NAME,
|
||||||
get: async (key) => {
|
get: browserSyncStorage.getItem,
|
||||||
const value: any = await browserSyncStorage.getItem(key)
|
set: browserSyncStorage.setItem,
|
||||||
|
|
||||||
// Compatibility with old version data
|
|
||||||
try {
|
|
||||||
return JSONR.parse(value)
|
|
||||||
} catch {
|
|
||||||
return value
|
|
||||||
}
|
|
||||||
},
|
|
||||||
set: (key, value) => browserSyncStorage.setItem(key, JSONR.stringify(value)),
|
|
||||||
remove: browserSyncStorage.removeItem,
|
remove: browserSyncStorage.removeItem,
|
||||||
clear: browserSyncStorage.clear,
|
clear: browserSyncStorage.clear,
|
||||||
watch: browserSyncStorage.watch as Storage['watch'],
|
watch: browserSyncStorage.watch as Storage['watch'],
|
||||||
|
|
Loading…
Reference in a new issue