@ethora/chat-component 26.5.9 → 26.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,6 +16,8 @@ interface ProfileImagePlaceholderProps {
16
16
  active?: boolean;
17
17
  placeholderIcon?: React.ReactNode;
18
18
  disableOverlay?: boolean;
19
+ /** Show a green online-status dot on the avatar. */
20
+ online?: boolean;
19
21
  }
20
22
  export declare const ProfileImagePlaceholder: React.FC<ProfileImagePlaceholderProps>;
21
23
  export {};
@@ -0,0 +1,16 @@
1
+ import { default as React } from 'react';
2
+ import { IConfig } from '../../types/types';
3
+ interface NotificationPermissionBannerProps {
4
+ config?: IConfig;
5
+ /** Triggers the browser permission prompt + push registration. */
6
+ requestPermission: () => Promise<void>;
7
+ }
8
+ /**
9
+ * In-app banner nudging the user to enable browser notifications. Fully
10
+ * config-driven (config.pushNotifications.permissionBanner) and self-contained:
11
+ * it reads the live Notification permission, renders the "enable" or "blocked"
12
+ * variant accordingly, and hides itself when notifications are granted /
13
+ * unsupported / disabled. SSR-safe.
14
+ */
15
+ declare const NotificationPermissionBanner: React.FC<NotificationPermissionBannerProps>;
16
+ export default NotificationPermissionBanner;
@@ -184,6 +184,54 @@ function pickImage(raw = {}, data = {}, notification = {}) {
184
184
  return data.image || notification.image || raw.image || undefined;
185
185
  }
186
186
 
187
+ // ── CALL DETECTION ────────────────────────────────────────────
188
+ // Mirror of helpers/callPush.ts isCallPush(). A backgrounded call push must
189
+ // (a) read as a call (persistent, call-styled title) and (b) carry its FULL
190
+ // data payload through to the click handler — otherwise the app's isCallPush()
191
+ // sees only {url,messageId,...} and can't raise the ring screen.
192
+ function pickField(data, keys) {
193
+ for (let i = 0; i < keys.length; i += 1) {
194
+ const v = data && data[keys[i]];
195
+ if (v !== undefined && v !== null && String(v).trim() !== '') {
196
+ return String(v).trim();
197
+ }
198
+ }
199
+ return '';
200
+ }
201
+
202
+ function isCallPushData(data) {
203
+ if (!data) return false;
204
+ const marker = pickField(data, [
205
+ 'type',
206
+ 'pushType',
207
+ 'category',
208
+ 'messageType',
209
+ 'event',
210
+ ]).toLowerCase();
211
+ if (
212
+ marker === 'call' ||
213
+ marker === 'incoming-call' ||
214
+ marker === 'call-token' ||
215
+ marker === 'call-invite'
216
+ ) {
217
+ return true;
218
+ }
219
+ const callId = pickField(data, ['callId', 'callid', 'callID']);
220
+ const kind = pickField(data, ['kind']).toLowerCase();
221
+ const hasCallField =
222
+ !!pickField(data, ['callToken', 'livekitToken']) ||
223
+ !!pickField(data, ['callKind']) ||
224
+ kind === 'audio' ||
225
+ kind === 'video';
226
+ return !!callId && hasCallField;
227
+ }
228
+
229
+ function callPushKind(data) {
230
+ return pickField(data, ['callKind', 'kind']).toLowerCase() === 'audio'
231
+ ? 'audio'
232
+ : 'video';
233
+ }
234
+
187
235
  function extractMessageId(raw = {}, data = {}) {
188
236
  return (
189
237
  raw.messageId ||
@@ -356,14 +404,40 @@ async function handlePush(raw = {}, source = 'push') {
356
404
  dedupKey,
357
405
  });
358
406
 
407
+ const isCall = isCallPushData(data);
408
+ const callerName = isCall
409
+ ? pickField(data, [
410
+ 'callerName',
411
+ 'callerDisplayName',
412
+ 'senderName',
413
+ 'title',
414
+ ])
415
+ : '';
416
+ const callId = isCall
417
+ ? pickField(data, ['callId', 'callid', 'callID'])
418
+ : '';
419
+
420
+ // Call pushes: a call-styled title, a tag keyed on the callId so repeat
421
+ // call-token pushes replace (not stack), and requireInteraction so the
422
+ // ring notification persists until the user answers/dismisses.
423
+ const notifTitle = isCall
424
+ ? `Incoming ${callPushKind(data)} call${callerName ? ` · ${callerName}` : ''}`
425
+ : title;
426
+ const notifBody = isCall ? 'Tap to answer' : body;
427
+
359
428
  const options = {
360
- body,
429
+ body: notifBody,
361
430
  icon,
362
431
  badge,
363
432
  image,
364
- tag: dedupKey,
365
- renotify: false,
433
+ tag: isCall ? `call:${callId || dedupKey}` : dedupKey,
434
+ renotify: isCall,
435
+ requireInteraction: isCall,
436
+ // Spread the ORIGINAL payload first so the click handler's isCallPush()
437
+ // sees the full call fields (callId/callToken/kind/room); our routing
438
+ // fields win on top.
366
439
  data: {
440
+ ...data,
367
441
  url,
368
442
  messageId,
369
443
  dedupKey,
@@ -375,9 +449,10 @@ async function handlePush(raw = {}, source = 'push') {
375
449
  log('SHOW NOTIFICATION', {
376
450
  reason: 'NO_VISIBLE_CLIENT',
377
451
  tag: options.tag,
452
+ isCall,
378
453
  });
379
454
 
380
- return self.registration.showNotification(title, options);
455
+ return self.registration.showNotification(notifTitle, options);
381
456
  }
382
457
 
383
458
  log('SKIP NOTIFICATION', {
@@ -8,4 +8,12 @@ export interface CallLogMeta {
8
8
  }
9
9
  export declare const isCallLogMessage: (message: unknown) => boolean;
10
10
  export declare const callStateHasLogData: (attrs: Record<string, any>) => boolean;
11
+ export declare const formatCallDuration: (ms: number) => string;
11
12
  export declare const transformCallLogMessage: (message: IMessage, selfXmppUsername: string) => IMessage;
13
+ export declare const buildLocalCallLogMessage: (params: {
14
+ callId: string;
15
+ direction: "outgoing" | "incoming";
16
+ durationMs: number;
17
+ kind: "audio" | "video";
18
+ selfXmppUsername: string;
19
+ }) => IMessage;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * xmppUsernames currently ONLINE (available MUC presence) in the given room.
3
+ * Populated from the room's presence stanzas: an available presence marks a
4
+ * user online; a `type='unavailable'` presence marks them offline. When you
5
+ * join a room the server sends the presence of everyone already online, so the
6
+ * list is correct from the first render and updates live as users come/go.
7
+ */
8
+ export declare const useRoomPresence: (roomJID?: string) => string[];
9
+ /** Whether a specific member (by xmppUsername) is currently online in the room. */
10
+ export declare const useIsUserOnline: (roomJID?: string, xmppUsername?: string) => boolean;
package/dist/main.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  export { XmppProvider } from './context/xmppProvider';
5
5
  export { ReduxWrapper as Chat } from './components/MainComponents/ReduxWrapper';
6
6
  export { useUnread } from './hooks/useUnreadMessagesCounter';
7
+ export { useRoomPresence, useIsUserOnline } from './hooks/useRoomPresence';
7
8
  export { logoutService } from './hooks/useLogout';
8
9
  export { useQRCodeChat, handleQRChatId } from './hooks/useQRCodeChatHandler';
9
10
  export { useInAppNotifications } from './hooks/useInAppNotifications';