fix: 优化云同步功能,自动去除掉非首个空会话,避免多个空会话在中间,更方便管理
This commit is contained in:
parent
6dc868154d
commit
5ae4921ee0
|
@ -131,10 +131,21 @@ const MergeStates: StateMerger = {
|
|||
|
||||
const finalIds: Record<string, any> = {};
|
||||
localState.sessions = localState.sessions.filter((localSession) => {
|
||||
// 去除掉重复的会话
|
||||
if (finalIds[localSession.id]) {
|
||||
return false;
|
||||
}
|
||||
finalIds[localSession.id] = true;
|
||||
|
||||
// 去除掉非首个空会话,避免多个空会话在中间,不方便管理
|
||||
if (
|
||||
localSession.messages.length === 0 &&
|
||||
localSession != localState.sessions[0]
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 去除云端删除并且删除时间小于本地修改时间的会话
|
||||
return (
|
||||
(remoteDeletedSessionIds[localSession.id] || -1) <=
|
||||
localSession.lastUpdate
|
||||
|
|
Loading…
Reference in New Issue