| 44 | }) as SetStoreFunction<State> |
| 45 | |
| 46 | const index = (sessionID: string) => { |
| 47 | const session = serverSync.session.get(sessionID) |
| 48 | if (!session || session.directory !== directory) return |
| 49 | const [store, setStore] = current() |
| 50 | const result = Binary.search(store.session, session.id, (item) => item.id) |
| 51 | if (result.found) { |
| 52 | setStore("session", result.index, reconcile(session)) |
| 53 | return |
| 54 | } |
| 55 | setStore( |
| 56 | "session", |
| 57 | produce((draft) => void draft.splice(result.index, 0, session)), |
| 58 | ) |
| 59 | } |
| 60 | |
| 61 | return { |
| 62 | data, |