feat: add upstash redis cloud sync

This commit is contained in:
Yidadaa
2023-09-19 03:18:34 +08:00
parent 59fbadd9eb
commit 83fed42997
8 changed files with 137 additions and 12 deletions

View File

@@ -69,6 +69,9 @@ const MergeStates: StateMerger = {
localState.sessions.forEach((s) => (localSessions[s.id] = s));
remoteState.sessions.forEach((remoteSession) => {
// skip empty chats
if (remoteSession.messages.length === 0) return;
const localSession = localSessions[remoteSession.id];
if (!localSession) {
// if remote session is new, just merge it