Просмотр исходного кода

fix(app): handle new session correctly

Adam 1 месяц назад
Родитель
Сommit
da78b758d4
1 измененных файлов с 17 добавлено и 0 удалено
  1. 17 0
      packages/app/src/context/global-sync.tsx

+ 17 - 0
packages/app/src/context/global-sync.tsx

@@ -351,6 +351,23 @@ function createGlobalSync() {
         bootstrapInstance(directory)
         break
       }
+      case "session.created": {
+        const result = Binary.search(store.session, event.properties.info.id, (s) => s.id)
+        if (result.found) {
+          setStore("session", result.index, reconcile(event.properties.info))
+          break
+        }
+        setStore(
+          "session",
+          produce((draft) => {
+            draft.splice(result.index, 0, event.properties.info)
+          }),
+        )
+        if (!event.properties.info.parentID) {
+          setStore("sessionTotal", store.sessionTotal + 1)
+        }
+        break
+      }
       case "session.updated": {
         const result = Binary.search(store.session, event.properties.info.id, (s) => s.id)
         if (event.properties.info.time.archived) {