fix: 修复数据库和 store 数据不一致问题
This commit is contained in:
parent
6265d27ebc
commit
b47d6c95e7
@ -22,7 +22,7 @@ const persistedReducer = persistReducer(
|
|||||||
{
|
{
|
||||||
key: 'cherry-studio',
|
key: 'cherry-studio',
|
||||||
storage,
|
storage,
|
||||||
version: 33,
|
version: 34,
|
||||||
blacklist: ['runtime'],
|
blacklist: ['runtime'],
|
||||||
migrate
|
migrate
|
||||||
},
|
},
|
||||||
|
|||||||
@ -1,7 +1,8 @@
|
|||||||
import { SYSTEM_MODELS } from '@renderer/config/models'
|
import { SYSTEM_MODELS } from '@renderer/config/models'
|
||||||
|
import db from '@renderer/databases'
|
||||||
import i18n from '@renderer/i18n'
|
import i18n from '@renderer/i18n'
|
||||||
import { Assistant } from '@renderer/types'
|
import { Assistant } from '@renderer/types'
|
||||||
import { uuid } from '@renderer/utils'
|
import { runAsyncFunction, uuid } from '@renderer/utils'
|
||||||
import { isEmpty } from 'lodash'
|
import { isEmpty } from 'lodash'
|
||||||
import { createMigrate } from 'redux-persist'
|
import { createMigrate } from 'redux-persist'
|
||||||
|
|
||||||
@ -594,6 +595,21 @@ const migrateConfig = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'34': (state: RootState) => {
|
||||||
|
state.assistants.assistants.forEach((assistant) => {
|
||||||
|
assistant.topics.forEach((topic) => {
|
||||||
|
topic.assistantId = assistant.id
|
||||||
|
runAsyncFunction(async () => {
|
||||||
|
const _topic = await db.topics.get(topic.id)
|
||||||
|
if (_topic) {
|
||||||
|
const messages = (_topic?.messages || []).map((message) => ({ ...message, assistantId: assistant.id }))
|
||||||
|
db.topics.put({ ..._topic, messages }, topic.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return state
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user