fix: dexie data upgrade
This commit is contained in:
parent
74b80b474e
commit
8350ac037e
@ -14,14 +14,14 @@ db.version(1).stores({
|
||||
files: 'id, name, origin_name, path, size, ext, type, created_at, count'
|
||||
})
|
||||
|
||||
db.version(2).stores({
|
||||
db.version(2)
|
||||
.stores({
|
||||
files: 'id, name, origin_name, path, size, ext, type, created_at, count',
|
||||
topics: '&id, messages',
|
||||
settings: '&id, value'
|
||||
})
|
||||
.upgrade(populateTopics)
|
||||
|
||||
db.on('populate', async (trans) => {
|
||||
populateTopics(trans)
|
||||
})
|
||||
db.on('populate', populateTopics)
|
||||
|
||||
export default db
|
||||
|
||||
@ -5,10 +5,7 @@ import localforage from 'localforage'
|
||||
export async function populateTopics(trans: Transaction) {
|
||||
const indexedKeys = await localforage.keys()
|
||||
|
||||
if (indexedKeys.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
if (indexedKeys.length > 0) {
|
||||
for (const key of indexedKeys) {
|
||||
const value: any = await localforage.getItem(key)
|
||||
if (key.startsWith('topic:')) {
|
||||
@ -27,3 +24,4 @@ export async function populateTopics(trans: Transaction) {
|
||||
onOk: () => window.api.reload()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user