修复同步数据字段顺序不一致的问题
parent
0da63c6ef0
commit
74ef112d57
|
@ -1,5 +1,17 @@
|
|||
import { LIST_IDS } from '@common/constants'
|
||||
|
||||
// 构建列表信息对象,用于统一字段位置顺序
|
||||
export const buildUserListInfoFull = ({ id, name, source, sourceListId, list, locationUpdateTime }: LX.List.UserListInfoFull) => {
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
source,
|
||||
sourceListId,
|
||||
locationUpdateTime,
|
||||
list,
|
||||
}
|
||||
}
|
||||
|
||||
export const getLocalListData = async(): Promise<LX.Sync.List.ListData> => {
|
||||
const lists: LX.Sync.List.ListData = {
|
||||
defaultList: await global.lx.worker.dbService.getListMusics(LIST_IDS.DEFAULT),
|
||||
|
@ -10,7 +22,7 @@ export const getLocalListData = async(): Promise<LX.Sync.List.ListData> => {
|
|||
const userListInfos = await global.lx.worker.dbService.getAllUserList()
|
||||
for await (const list of userListInfos) {
|
||||
lists.userList.push(await global.lx.worker.dbService.getListMusics(list.id)
|
||||
.then(musics => ({ ...list, list: musics })))
|
||||
.then(musics => buildUserListInfoFull({ ...list, list: musics })))
|
||||
}
|
||||
|
||||
return lists
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// import { SYNC_CLOSE_CODE } from '../../../../constants'
|
||||
import { removeSelectModeListener, sendCloseSelectMode, sendSelectMode } from '@main/modules/winMain'
|
||||
import { getUserSpace, getUserConfig } from '../../../user'
|
||||
import { getLocalListData, setLocalListData } from '@main/modules/sync/listEvent'
|
||||
import { buildUserListInfoFull, getLocalListData, setLocalListData } from '@main/modules/sync/listEvent'
|
||||
import { SYNC_CLOSE_CODE } from '@common/constants_sync'
|
||||
// import { LIST_IDS } from '@common/constants'
|
||||
|
||||
|
@ -355,14 +355,14 @@ const handleMergeListDataFromSnapshot = async(socket: LX.Sync.Server.Socket, sna
|
|||
let newList: LX.List.UserListInfoFull
|
||||
if (remoteList) {
|
||||
const snapshotList = snapshotUserListData.get(list.id) ?? { name: null, source: null, sourceListId: null, list: [] }
|
||||
newList = {
|
||||
newList = buildUserListInfoFull({
|
||||
id: list.id,
|
||||
locationUpdateTime: list.locationUpdateTime,
|
||||
name: selectData(snapshotList.name, list.name, remoteList.name),
|
||||
source: selectData(snapshotList.source, list.source, remoteList.source),
|
||||
sourceListId: selectData(snapshotList.sourceListId, list.sourceListId, remoteList.sourceListId),
|
||||
locationUpdateTime: list.locationUpdateTime,
|
||||
list: mergeListDataFromSnapshot(list.list, remoteList.list, snapshotList.list, addMusicLocationType),
|
||||
}
|
||||
})
|
||||
} else {
|
||||
newList = { ...list }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue