diff --git a/src/main/modules/sync/server/modules/list/sync/handler.ts b/src/main/modules/sync/server/modules/list/sync/handler.ts index dc34dade..bf8a2877 100644 --- a/src/main/modules/sync/server/modules/list/sync/handler.ts +++ b/src/main/modules/sync/server/modules/list/sync/handler.ts @@ -3,6 +3,7 @@ // import { sendSyncActionList } from '@main/modules/winMain' // import { SYNC_CLOSE_CODE } from '@/constants' // import { SYNC_CLOSE_CODE } from '@common/constants_sync' +import { SYNC_CLOSE_CODE } from '@common/constants_sync' import { getUserSpace } from '@main/modules/sync/server/user' import { handleRemoteListAction } from '@main/modules/sync/utils' // import { encryptMsg } from '@/utils/tools' @@ -155,6 +156,13 @@ export const onListSyncAction = async(socket: LX.Sync.Server.Socket, action: LX. const currentId = socket.keyInfo.clientId socket.broadcast((client) => { if (client.keyInfo.clientId == currentId || !client.moduleReadys?.list || client.userInfo.name != currentUserName) return - void client.remoteQueueList.onListSyncAction(action) + void client.remoteQueueList.onListSyncAction(action).then(async() => { + return userSpace.listManage.updateDeviceSnapshotKey(client.keyInfo.clientId, key) + }).catch(err => { + // TODO send status + client.close(SYNC_CLOSE_CODE.failed) + // client.moduleReadys.list = false + console.log(err.message) + }) }) } diff --git a/src/main/modules/sync/server/modules/list/sync/localEvent.ts b/src/main/modules/sync/server/modules/list/sync/localEvent.ts index 14a9e794..d5db5c99 100644 --- a/src/main/modules/sync/server/modules/list/sync/localEvent.ts +++ b/src/main/modules/sync/server/modules/list/sync/localEvent.ts @@ -1,3 +1,4 @@ +import { SYNC_CLOSE_CODE } from '@common/constants_sync' import { registerListActionEvent } from '../../../../utils' import { getUserSpace } from '../../../user' @@ -11,8 +12,13 @@ const sendListAction = async(wss: LX.Sync.Server.SocketServer, action: LX.Sync.L const key = await userSpace.listManage.createSnapshot() for (const client of wss.clients) { if (!client.moduleReadys?.list) continue - void client.remoteQueueList.onListSyncAction(action).then(() => { - void userSpace.listManage.updateDeviceSnapshotKey(client.keyInfo.clientId, key) + void client.remoteQueueList.onListSyncAction(action).then(async() => { + return userSpace.listManage.updateDeviceSnapshotKey(client.keyInfo.clientId, key) + }).catch(err => { + // TODO send status + client.close(SYNC_CLOSE_CODE.failed) + // client.moduleReadys.list = false + console.log(err.message) }) } } diff --git a/src/main/modules/sync/server/modules/list/sync/sync.ts b/src/main/modules/sync/server/modules/list/sync/sync.ts index 9f0d4f24..c287c245 100644 --- a/src/main/modules/sync/server/modules/list/sync/sync.ts +++ b/src/main/modules/sync/server/modules/list/sync/sync.ts @@ -2,6 +2,7 @@ import { removeSelectModeListener, sendCloseSelectMode, sendSelectMode } from '@main/modules/winMain' import { getUserSpace, getUserConfig } from '../../../user' import { getLocalListData, setLocalListData } from '@main/modules/sync/utils' +import { SYNC_CLOSE_CODE } from '@common/constants_sync' // import { LIST_IDS } from '@common/constants' // type ListInfoType = LX.List.UserListInfoFull | LX.List.MyDefaultListInfoFull | LX.List.MyLoveListInfoFull @@ -65,12 +66,15 @@ const setLocalList = async(socket: LX.Sync.Server.Socket, listData: LX.Sync.List const overwriteRemoteListData = async(socket: LX.Sync.Server.Socket, listData: LX.Sync.List.ListData, key: string, excludeIds: string[] = []) => { const action = { action: 'list_data_overwrite', data: listData } as const const tasks: Array> = [] + const userSpace = getUserSpace(socket.userInfo.name) socket.broadcast((client) => { if (excludeIds.includes(client.keyInfo.clientId) || client.userInfo.name != socket.userInfo.name || !client.moduleReadys?.list) return tasks.push(client.remoteQueueList.onListSyncAction(action).then(async() => { - const userSpace = getUserSpace(socket.userInfo.name) - return userSpace.listManage.updateDeviceSnapshotKey(socket.keyInfo.clientId, key) + return userSpace.listManage.updateDeviceSnapshotKey(client.keyInfo.clientId, key) }).catch(err => { + // TODO send status + client.close(SYNC_CLOSE_CODE.failed) + // client.moduleReadys.list = false console.log(err.message) })) })