@poolse/react 2.4.0 → 2.5.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
@@ -553,10 +553,17 @@ interface UseCalls {
553
553
  error: Error | null;
554
554
  /** Ring every other member of a conversation. */
555
555
  call: (conversationId: string) => Promise<void>;
556
- /** Answer the inbound ring. */
557
- accept: () => Promise<void>;
558
- /** Reject the inbound ring. */
559
- decline: () => Promise<void>;
556
+ /**
557
+ * Answer the inbound ring.
558
+ *
559
+ * Pass the call explicitly when it didn't arrive over the socket — a
560
+ * VoIP push can launch the app cold, in which case this hook has no
561
+ * `incoming` state and the push payload is the only source of truth.
562
+ */
563
+ accept: (call?: IncomingCall) => Promise<void>;
564
+ /** Reject the inbound ring. Takes an explicit call for the same
565
+ * cold-launch reason as {@link accept}. */
566
+ decline: (call?: IncomingCall) => Promise<void>;
560
567
  /** Hang up an outbound ring before it's answered. */
561
568
  cancel: () => Promise<void>;
562
569
  /** Drop back to idle — call after leaving the room, or to clear a
package/dist/index.d.ts CHANGED
@@ -553,10 +553,17 @@ interface UseCalls {
553
553
  error: Error | null;
554
554
  /** Ring every other member of a conversation. */
555
555
  call: (conversationId: string) => Promise<void>;
556
- /** Answer the inbound ring. */
557
- accept: () => Promise<void>;
558
- /** Reject the inbound ring. */
559
- decline: () => Promise<void>;
556
+ /**
557
+ * Answer the inbound ring.
558
+ *
559
+ * Pass the call explicitly when it didn't arrive over the socket — a
560
+ * VoIP push can launch the app cold, in which case this hook has no
561
+ * `incoming` state and the push payload is the only source of truth.
562
+ */
563
+ accept: (call?: IncomingCall) => Promise<void>;
564
+ /** Reject the inbound ring. Takes an explicit call for the same
565
+ * cold-launch reason as {@link accept}. */
566
+ decline: (call?: IncomingCall) => Promise<void>;
560
567
  /** Hang up an outbound ring before it's answered. */
561
568
  cancel: () => Promise<void>;
562
569
  /** Drop back to idle — call after leaving the room, or to clear a
package/dist/index.js CHANGED
@@ -1176,28 +1176,36 @@ function useCalls(userId, opts = {}) {
1176
1176
  },
1177
1177
  [calls]
1178
1178
  );
1179
- const accept = useCallback(async () => {
1180
- if (!calls || !incoming) return;
1181
- try {
1182
- await calls.accept(incoming);
1183
- setActiveConversationId(incoming.conversationId);
1184
- setPhase("active");
1185
- setIncoming(null);
1186
- } catch (err) {
1187
- setError(err instanceof Error ? err : new Error(String(err)));
1188
- }
1189
- }, [calls, incoming]);
1190
- const decline = useCallback(async () => {
1191
- if (!calls || !incoming) return;
1192
- try {
1193
- await calls.decline(incoming);
1194
- } catch (err) {
1195
- setError(err instanceof Error ? err : new Error(String(err)));
1196
- } finally {
1197
- setIncoming(null);
1198
- setPhase("idle");
1199
- }
1200
- }, [calls, incoming]);
1179
+ const accept = useCallback(
1180
+ async (call2) => {
1181
+ const target = call2 ?? incoming;
1182
+ if (!calls || !target) return;
1183
+ try {
1184
+ await calls.accept(target);
1185
+ setActiveConversationId(target.conversationId);
1186
+ setPhase("active");
1187
+ setIncoming(null);
1188
+ } catch (err) {
1189
+ setError(err instanceof Error ? err : new Error(String(err)));
1190
+ }
1191
+ },
1192
+ [calls, incoming]
1193
+ );
1194
+ const decline = useCallback(
1195
+ async (call2) => {
1196
+ const target = call2 ?? incoming;
1197
+ if (!calls || !target) return;
1198
+ try {
1199
+ await calls.decline(target);
1200
+ } catch (err) {
1201
+ setError(err instanceof Error ? err : new Error(String(err)));
1202
+ } finally {
1203
+ setIncoming(null);
1204
+ setPhase("idle");
1205
+ }
1206
+ },
1207
+ [calls, incoming]
1208
+ );
1201
1209
  const cancel = useCallback(async () => {
1202
1210
  if (!calls || !outgoing) return;
1203
1211
  try {