refactor: auto delete db memory cache

This commit is contained in:
linyuchen
2024-03-13 09:11:58 +08:00
parent a93220f9d2
commit 712f0a8256
4 changed files with 80 additions and 42 deletions

View File

@@ -180,6 +180,7 @@ async function processGroupEvent(payload) {
}
}
// 群列表变动
registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmd.GROUPS, (payload) => {
if (payload.updateType != 2) {
updateGroups(payload.groupList).then();
@@ -199,6 +200,7 @@ registerReceiveHook<{ groupList: Group[], updateType: number }>(ReceiveCmd.GROUP
}
})
// 好友列表变动
registerReceiveHook<{
data: { categoryId: number, categroyName: string, categroyMbCount: number, buddyList: User[] }[]
}>(ReceiveCmd.FRIENDS, payload => {
@@ -215,6 +217,7 @@ registerReceiveHook<{
}
})
// 新消息
registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.NEW_MSG, (payload) => {
const {autoDeleteFile} = getConfigUtil().getConfig();
for (const message of payload.msgList) {
@@ -232,7 +235,9 @@ registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.NEW_MSG, (payload
setTimeout(() => {
const picPath = msgElement.picElement?.sourcePath
const pttPath = msgElement.pttElement?.filePath
const pathList = [picPath, pttPath]
const filePath = msgElement.fileElement?.filePath
const videoPath = msgElement.videoElement?.filePath
const pathList = [picPath, pttPath, filePath, videoPath]
if (msgElement.picElement) {
pathList.push(...Object.values(msgElement.picElement.thumbPath))
}
@@ -249,7 +254,7 @@ registerReceiveHook<{ msgList: Array<RawMessage> }>(ReceiveCmd.NEW_MSG, (payload
});
}
}
}, 60 * 1000)
}, getConfigUtil().getConfig().autoDeleteFileSecond * 1000)
}
}
})