refactor Notifications rc

This commit is contained in:
alma 2026-01-16 01:52:51 +01:00
parent 35dfac064f
commit ab1ba65a9f
3 changed files with 43 additions and 14 deletions

View File

@ -34,10 +34,15 @@ export function IncomingCallNotification({
useEffect(() => { useEffect(() => {
if (call) { if (call) {
console.log('[IncomingCallNotification] 📞 Call received, showing notification', {
from: call.from.name || call.from.username,
roomId: call.roomId,
});
setIsVisible(true); setIsVisible(true);
// Auto-dismiss after 30 seconds if user doesn't interact // Auto-dismiss after 30 seconds if user doesn't interact
const autoDismissTimer = setTimeout(() => { const autoDismissTimer = setTimeout(() => {
console.log('[IncomingCallNotification] ⏰ Auto-dismissing after 30 seconds');
setIsVisible(false); setIsVisible(false);
onDismiss(); onDismiss();
}, 30000); // 30 seconds }, 30000); // 30 seconds

View File

@ -210,19 +210,30 @@ export function LayoutWrapper({ children, isSignInPage, isAuthenticated }: Layou
{/* Incoming call notification */} {/* Incoming call notification */}
{!isSignInPage && isAuthenticated && ( {!isSignInPage && isAuthenticated && (
<IncomingCallNotification <>
call={incomingCall} {incomingCall && (
onDismiss={() => setIncomingCall(null)} <div style={{ position: 'fixed', top: 0, right: 0, zIndex: 9999 }}>
onAccept={(roomId) => { {/* Debug: Show if incomingCall exists */}
console.log('[LayoutWrapper] Call accepted, navigating to room:', roomId); {console.log('[LayoutWrapper] Rendering IncomingCallNotification', { incomingCall })}
setIncomingCall(null); </div>
}} )}
onReject={() => { <IncomingCallNotification
console.log('[LayoutWrapper] Call rejected'); call={incomingCall}
setIncomingCall(null); onDismiss={() => {
// TODO: Send reject signal to RocketChat if needed console.log('[LayoutWrapper] Call dismissed');
}} setIncomingCall(null);
/> }}
onAccept={(roomId) => {
console.log('[LayoutWrapper] Call accepted, navigating to room:', roomId);
setIncomingCall(null);
}}
onReject={() => {
console.log('[LayoutWrapper] Call rejected');
setIncomingCall(null);
// TODO: Send reject signal to RocketChat if needed
}}
/>
</>
)} )}
</AuthCheck> </AuthCheck>
); );

View File

@ -117,7 +117,20 @@ export function useRocketChatCalls() {
roomId: callEvent.roomId, roomId: callEvent.roomId,
}); });
// Trigger notification // Show incoming call notification UI (Outlook-style rectangle)
setIncomingCall({
from: callEvent.from,
roomId: callEvent.roomId,
roomName: callEvent.roomName,
timestamp: callEvent.timestamp,
});
console.log('[useRocketChatCalls] 📞 Incoming call notification UI set', {
from: callEvent.from.username,
roomId: callEvent.roomId,
});
// Trigger notification badge
// For calls, we want to increment the existing count, not replace it // For calls, we want to increment the existing count, not replace it
// So we fetch current count first, then increment // So we fetch current count first, then increment
triggerNotification({ triggerNotification({