@poolse/react 2.20.0 → 2.24.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/CHANGELOG.md +28 -0
- package/dist/index.cjs +26 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +26 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -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
|
@@ -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
|
@@ -1477,14 +1477,20 @@ function useCalls(userId, opts = {}) {
|
|
|
1477
1477
|
setIncoming(null);
|
|
1478
1478
|
return;
|
|
1479
1479
|
}
|
|
1480
|
+
setActiveConversationId(target.conversationId);
|
|
1481
|
+
setActiveCallId(target.callId);
|
|
1482
|
+
setActiveMedia(target.media);
|
|
1483
|
+
setPhase("active");
|
|
1484
|
+
setIncoming(null);
|
|
1480
1485
|
try {
|
|
1481
1486
|
await calls.accept(target);
|
|
1482
|
-
setActiveConversationId(target.conversationId);
|
|
1483
|
-
setActiveCallId(target.callId);
|
|
1484
|
-
setActiveMedia(target.media);
|
|
1485
|
-
setPhase("active");
|
|
1486
|
-
setIncoming(null);
|
|
1487
1487
|
} catch (err) {
|
|
1488
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1489
|
+
if (message.includes("timed out")) return;
|
|
1490
|
+
setPhase("idle");
|
|
1491
|
+
setActiveConversationId(null);
|
|
1492
|
+
setActiveCallId(null);
|
|
1493
|
+
setActiveMedia(null);
|
|
1488
1494
|
setError(err instanceof Error ? err : new Error(String(err)));
|
|
1489
1495
|
}
|
|
1490
1496
|
},
|
|
@@ -1540,7 +1546,21 @@ function useCalls(userId, opts = {}) {
|
|
|
1540
1546
|
}, ringTimeoutMs);
|
|
1541
1547
|
return () => clearTimeout(timer);
|
|
1542
1548
|
}, [phase, ringTimeoutMs]);
|
|
1549
|
+
const othersOnCallRef = useRef(0);
|
|
1550
|
+
const reportOthersOnCall = useCallback((count) => {
|
|
1551
|
+
othersOnCallRef.current = count;
|
|
1552
|
+
}, []);
|
|
1543
1553
|
const hangUp = useCallback(async () => {
|
|
1554
|
+
if (phaseRef.current === "active" && othersOnCallRef.current >= 2) {
|
|
1555
|
+
setPhase("idle");
|
|
1556
|
+
setIncoming(null);
|
|
1557
|
+
setOutgoing(null);
|
|
1558
|
+
setActiveConversationId(null);
|
|
1559
|
+
setActiveCallId(null);
|
|
1560
|
+
setActiveMedia(null);
|
|
1561
|
+
setError(null);
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1544
1564
|
const conversationId = activeConversationId ?? incoming?.conversationId ?? outgoing?.conversationId;
|
|
1545
1565
|
const callId = activeCallId ?? incoming?.callId ?? outgoing?.callId;
|
|
1546
1566
|
try {
|
|
@@ -1589,6 +1609,7 @@ function useCalls(userId, opts = {}) {
|
|
|
1589
1609
|
decline,
|
|
1590
1610
|
cancel,
|
|
1591
1611
|
hangUp,
|
|
1612
|
+
reportOthersOnCall,
|
|
1592
1613
|
reset
|
|
1593
1614
|
};
|
|
1594
1615
|
}
|