feat(realtime): live online/offline events and unified search
Some checks failed
CI / test (push) Failing after 18s
Some checks failed
CI / test (push) Failing after 18s
- add websocket events user_online/user_offline - broadcast presence changes on first connect and final disconnect only - apply live presence updates in web chat store and realtime hook - move public discover into unified left search (users + groups/channels) - remove separate Discover Chats dialog/menu entry
This commit is contained in:
@@ -127,6 +127,19 @@ export function useRealtime() {
|
||||
chatStore.setMessageDeliveryStatusUpTo(chatId, maxId, "read", authStore.me?.id ?? -1);
|
||||
}
|
||||
}
|
||||
if (event.event === "user_online" || event.event === "user_offline") {
|
||||
const chatId = Number(event.payload.chat_id);
|
||||
const userId = Number(event.payload.user_id);
|
||||
const isOnline = Boolean(event.payload.is_online);
|
||||
const lastSeenAtRaw = event.payload.last_seen_at;
|
||||
const lastSeenAt = typeof lastSeenAtRaw === "string" ? lastSeenAtRaw : undefined;
|
||||
if (!Number.isFinite(chatId) || !Number.isFinite(userId)) {
|
||||
return;
|
||||
}
|
||||
if (userId !== authStore.me?.id) {
|
||||
chatStore.applyPresenceEvent(chatId, userId, isOnline, lastSeenAt);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ws.onclose = () => {
|
||||
|
||||
Reference in New Issue
Block a user