fix: harden data integrity, connection stability, and memory management

Wrap all multi-write DB operations in atomic transactions (server/channel
creation, message+attachment linking, DM creation, friend acceptance,
cascading deletes) to prevent partial-write corruption.

Batch N+1 queries in WS ready payload into O(1) bulk fetches with
chunked inArray() to respect SQLite's variable limit.

Fix chat history regression where background WS messages bypassed
channel load by switching the guard from messages.has() to hasMore.has().

Add LRU channel eviction (20 cached, evict to 15) and per-channel
message cap (200) to bound client memory growth.

Shorten WS heartbeat from 30s to 15s for aggressive proxy/NAT
environments. Clear all user-scoped stores on logout to prevent
cross-session data leaks.

Extract LiveKit internal accessors into shared livekitInternals utility.
This commit is contained in:
Jannis Braun
2026-02-24 03:52:22 +01:00
parent 2342396fce
commit 36e27121da
13 changed files with 380 additions and 205 deletions
+3
View File
@@ -18,6 +18,7 @@ interface SocialState {
addFriendFromAccepted: (friend: Friend, requestId: string) => void;
updateFriendPresence: (userId: string, status: string) => void;
removeFriendLocally: (userId: string) => void;
reset: () => void;
}
export const useSocialStore = create<SocialState>((set, get) => ({
@@ -139,4 +140,6 @@ export const useSocialStore = create<SocialState>((set, get) => ({
),
}));
},
reset: () => set({ friends: [], requests: [], isLoading: false, error: null }),
}));