(existing: Thread[], incoming: Thread[])
| 10 | } |
| 11 | |
| 12 | const mergeThreadList = (existing: Thread[], incoming: Thread[]): Thread[] => |
| 13 | Array.from(new Map([...existing, ...incoming].map((t) => [t.id, t])).values()).sort( |
| 14 | (a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime(), |
| 15 | ); |
| 16 | |
| 17 | export const createChatStore = (config: CreateChatStoreConfig) => { |
| 18 | const { storage, llm } = config; |