feat: realtime sync, settings UX and chat list improvements
Some checks failed
CI / test (push) Failing after 21s
Some checks failed
CI / test (push) Failing after 21s
- add chat_updated realtime event and dynamic chat subscriptions - auto-join invite links in web app - implement Telegram-like settings panel (general/notifications/privacy) - add browser notification preferences and keyboard send mode - improve chat list with last message preview/time and online badge - rework chat members UI with context actions and role crowns
This commit is contained in:
@@ -17,6 +17,7 @@ RealtimeEventName = Literal[
|
||||
"message_delivered",
|
||||
"user_online",
|
||||
"user_offline",
|
||||
"chat_updated",
|
||||
"pong",
|
||||
"error",
|
||||
]
|
||||
|
||||
@@ -144,6 +144,24 @@ class RealtimeGateway:
|
||||
async def load_user_chat_ids(self, db: AsyncSession, user_id: int) -> list[int]:
|
||||
return await list_user_chat_ids(db, user_id=user_id)
|
||||
|
||||
def add_chat_subscription(self, *, chat_id: int, user_id: int) -> None:
|
||||
self._chat_subscribers[chat_id].add(user_id)
|
||||
|
||||
def remove_chat_subscription(self, *, chat_id: int, user_id: int) -> None:
|
||||
subscribers = self._chat_subscribers.get(chat_id)
|
||||
if not subscribers:
|
||||
return
|
||||
subscribers.discard(user_id)
|
||||
if not subscribers:
|
||||
self._chat_subscribers.pop(chat_id, None)
|
||||
|
||||
async def publish_chat_updated(self, *, chat_id: int) -> None:
|
||||
await self._publish_chat_event(
|
||||
chat_id,
|
||||
event="chat_updated",
|
||||
payload={"chat_id": chat_id},
|
||||
)
|
||||
|
||||
async def _handle_redis_event(self, channel: str, payload: dict) -> None:
|
||||
chat_id = self._extract_chat_id(channel)
|
||||
if chat_id is None:
|
||||
|
||||
Reference in New Issue
Block a user