Files
temetro/frontend/components/meetings/use-call-invites.ts
T
Khalid Abdi 1d9b1b1d22 frontend: chat/meetings/messages/settings UX fixes
- settings: keep tab nav on its own row so "Developers" no longer wraps
- chat: show the "Veil active" chip once per conversation, not every turn
- chat: record cards only offer "Click for more" when they have detail
- chat: chat-history panel (pill + sheet) top-left of the AI chat with
  "Start new chat"; rename sidebar "New chat" -> "Ask temetro" (Sparkles)
- meetings: disable past dates, add an Upcoming Meetings list, and use the
  Empty component for empty days; scheduler can be pre-targeted via ?with
- messages: add a call button left of each inbox row -> Meetings (?with)
- toast: add a dismiss (x) button; call invites now ring 30s with "Accept"

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-20 18:34:48 +03:00

44 lines
1.4 KiB
TypeScript

"use client";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import { toastManager } from "@/components/ui/toast";
import { getSocket } from "@/lib/socket";
type CallInvite = { roomId: string; roomName: string; fromName: string };
// Listens for live "call:invite" events and shows a toast with a Join action
// that drops the user into the room. Mounted once in the app shell (the sidebar)
// so it works from any page.
export function useCallInvites() {
const router = useRouter();
const { t } = useTranslation();
useEffect(() => {
const socket = getSocket();
const onInvite = ({ roomId, roomName, fromName }: CallInvite) => {
toastManager.add({
type: "info",
// Ring long enough for the callee to react; the toast's "x" declines it.
timeout: 30_000,
title: t("meetings.invite.toastTitle", { name: fromName }),
description: roomName,
actionProps: {
// "Accept" drops the user straight into the caller's room.
children: t("meetings.invite.accept"),
onClick: () =>
router.push(
`/messages/meetings?room=${encodeURIComponent(roomId)}`,
),
},
});
};
socket.on("call:invite", onInvite);
return () => {
socket.off("call:invite", onInvite);
};
}, [router, t]);
}