@poolse/react 2.23.0 → 2.25.0

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.
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { PoolseConfig, Poolse, Me, Uuid, Conversation, ConversationCreateRequest, Membership, MemberRole, Message, MessageCreateRequest, RealtimeStatus, Attachment, AttachmentUploadInput, PoolseUserProfile, CallRoomStatus, CallParticipant, CameraFacing, CallDeviceKind, CallDevice, LiveKitModule, VoiceStatus, VoiceParticipant, VoiceRoomOptions, IncomingCall, OutgoingCall, CallMedia } from '@poolse/sdk';
3
- export { ApiError, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, Conversation, ConversationCreateRequest, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, RealtimeStatus, Uuid } from '@poolse/sdk';
3
+ export { ApiError, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, Conversation, ConversationCreateRequest, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, RealtimeStatus, Uuid, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  interface PoolseProviderProps {
@@ -736,6 +736,16 @@ interface UseCalls {
736
736
  * `declined` / `busy` / `timed-out` state the UI has finished
737
737
  * showing. */
738
738
  reset: () => void;
739
+ /**
740
+ * Tell the hook how many OTHER people are currently on the call's
741
+ * media. `hangUp` consults it: with two or more others connected,
742
+ * hanging up just leaves — the call continues without you — and the
743
+ * end-the-call signal is only sent when at most one other remains.
744
+ * Every hang-up path funnels through the hook (the in-call button,
745
+ * CallKit's end event, the OS back gesture), so this is the ONE
746
+ * place group calls are protected from being ended by a leaver.
747
+ */
748
+ reportOthersOnCall: (count: number) => void;
739
749
  }
740
750
  /**
741
751
  * WhatsApp-style calling: ring a conversation, show an incoming-call
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { PoolseConfig, Poolse, Me, Uuid, Conversation, ConversationCreateRequest, Membership, MemberRole, Message, MessageCreateRequest, RealtimeStatus, Attachment, AttachmentUploadInput, PoolseUserProfile, CallRoomStatus, CallParticipant, CameraFacing, CallDeviceKind, CallDevice, LiveKitModule, VoiceStatus, VoiceParticipant, VoiceRoomOptions, IncomingCall, OutgoingCall, CallMedia } from '@poolse/sdk';
3
- export { ApiError, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, Conversation, ConversationCreateRequest, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, RealtimeStatus, Uuid } from '@poolse/sdk';
3
+ export { ApiError, Attachment, AttachmentStatus, AttachmentUploadInput, AttachmentUploadRequest, AttachmentUploadResponse, AuthError, CallLog, CallLogDisplay, CallLogEntry, CallLogMedia, CallMissedEntry, Conversation, ConversationCreateRequest, Me, MemberRole, Membership, Message, MessageCreateRequest, MessageType, NetworkError, PoolseConfig, PoolseError, PoolseUserProfile, RateLimitedError, RealtimeStatus, Uuid, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
4
4
  import { ReactNode } from 'react';
5
5
 
6
6
  interface PoolseProviderProps {
@@ -736,6 +736,16 @@ interface UseCalls {
736
736
  * `declined` / `busy` / `timed-out` state the UI has finished
737
737
  * showing. */
738
738
  reset: () => void;
739
+ /**
740
+ * Tell the hook how many OTHER people are currently on the call's
741
+ * media. `hangUp` consults it: with two or more others connected,
742
+ * hanging up just leaves — the call continues without you — and the
743
+ * end-the-call signal is only sent when at most one other remains.
744
+ * Every hang-up path funnels through the hook (the in-call button,
745
+ * CallKit's end event, the OS back gesture), so this is the ONE
746
+ * place group calls are protected from being ended by a leaver.
747
+ */
748
+ reportOthersOnCall: (count: number) => void;
739
749
  }
740
750
  /**
741
751
  * WhatsApp-style calling: ring a conversation, show an incoming-call
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import { Poolse, safeUuid } from '@poolse/sdk';
3
- export { ApiError, AuthError, NetworkError, PoolseError, RateLimitedError } from '@poolse/sdk';
2
+ import { Poolse, safeUuid, isCallLogMessage } from '@poolse/sdk';
3
+ export { ApiError, AuthError, NetworkError, PoolseError, RateLimitedError, callLogDisplayFor, describeCallLog, formatCallDuration, formatCallLogPreview, isCallLogMessage, isMessageVisibleTo, parseCallLog, parseCallLogBody } from '@poolse/sdk';
4
4
  import { createContext, useRef, useMemo, useEffect, useContext, useState, useCallback } from 'react';
5
5
  import { jsx } from 'react/jsx-runtime';
6
6
 
@@ -1025,8 +1025,6 @@ function useUser(externalId) {
1025
1025
  }, [chat, externalId]);
1026
1026
  return state;
1027
1027
  }
1028
-
1029
- // src/grouping.ts
1030
1028
  function computeGroupPosition(msg, prev, next, windowMs) {
1031
1029
  const continuesPrev = sameGroup(msg, prev, windowMs);
1032
1030
  const continuesNext = sameGroup(next, msg, windowMs);
@@ -1037,6 +1035,7 @@ function computeGroupPosition(msg, prev, next, windowMs) {
1037
1035
  }
1038
1036
  function sameGroup(a, b, windowMs) {
1039
1037
  if (!a || !b) return false;
1038
+ if (isCallLogMessage(a) || isCallLogMessage(b)) return false;
1040
1039
  if (a.sender_id !== b.sender_id) return false;
1041
1040
  if (!sameDay(a.inserted_at, b.inserted_at)) return false;
1042
1041
  const ta = new Date(a.inserted_at).getTime();
@@ -1546,7 +1545,21 @@ function useCalls(userId, opts = {}) {
1546
1545
  }, ringTimeoutMs);
1547
1546
  return () => clearTimeout(timer);
1548
1547
  }, [phase, ringTimeoutMs]);
1548
+ const othersOnCallRef = useRef(0);
1549
+ const reportOthersOnCall = useCallback((count) => {
1550
+ othersOnCallRef.current = count;
1551
+ }, []);
1549
1552
  const hangUp = useCallback(async () => {
1553
+ if (phaseRef.current === "active" && othersOnCallRef.current >= 2) {
1554
+ setPhase("idle");
1555
+ setIncoming(null);
1556
+ setOutgoing(null);
1557
+ setActiveConversationId(null);
1558
+ setActiveCallId(null);
1559
+ setActiveMedia(null);
1560
+ setError(null);
1561
+ return;
1562
+ }
1550
1563
  const conversationId = activeConversationId ?? incoming?.conversationId ?? outgoing?.conversationId;
1551
1564
  const callId = activeCallId ?? incoming?.callId ?? outgoing?.callId;
1552
1565
  try {
@@ -1595,6 +1608,7 @@ function useCalls(userId, opts = {}) {
1595
1608
  decline,
1596
1609
  cancel,
1597
1610
  hangUp,
1611
+ reportOthersOnCall,
1598
1612
  reset
1599
1613
  };
1600
1614
  }