@poolse/react 2.24.0 → 2.26.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.cjs +85 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -3
- package/dist/index.d.ts +20 -3
- package/dist/index.js +55 -5
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -1026,8 +1026,6 @@ function useUser(externalId) {
|
|
|
1026
1026
|
}, [chat, externalId]);
|
|
1027
1027
|
return state;
|
|
1028
1028
|
}
|
|
1029
|
-
|
|
1030
|
-
// src/grouping.ts
|
|
1031
1029
|
function computeGroupPosition(msg, prev, next, windowMs) {
|
|
1032
1030
|
const continuesPrev = sameGroup(msg, prev, windowMs);
|
|
1033
1031
|
const continuesNext = sameGroup(next, msg, windowMs);
|
|
@@ -1038,6 +1036,7 @@ function computeGroupPosition(msg, prev, next, windowMs) {
|
|
|
1038
1036
|
}
|
|
1039
1037
|
function sameGroup(a, b, windowMs) {
|
|
1040
1038
|
if (!a || !b) return false;
|
|
1039
|
+
if (sdk.isCallLogMessage(a) || sdk.isCallLogMessage(b)) return false;
|
|
1041
1040
|
if (a.sender_id !== b.sender_id) return false;
|
|
1042
1041
|
if (!sameDay(a.inserted_at, b.inserted_at)) return false;
|
|
1043
1042
|
const ta = new Date(a.inserted_at).getTime();
|
|
@@ -1614,6 +1613,57 @@ function useCalls(userId, opts = {}) {
|
|
|
1614
1613
|
reset
|
|
1615
1614
|
};
|
|
1616
1615
|
}
|
|
1616
|
+
function useLiveCall(conversationId) {
|
|
1617
|
+
const chat = usePoolse();
|
|
1618
|
+
const [call, setCall] = react.useState(null);
|
|
1619
|
+
const [participantIds, setParticipantIds] = react.useState([]);
|
|
1620
|
+
const callIdRef = react.useRef(null);
|
|
1621
|
+
const seq = react.useRef(0);
|
|
1622
|
+
const apply = react.useCallback((next) => {
|
|
1623
|
+
callIdRef.current = next?.id ?? null;
|
|
1624
|
+
setCall(next);
|
|
1625
|
+
setParticipantIds(next ? next.participants.map((p) => p.user_id) : []);
|
|
1626
|
+
}, []);
|
|
1627
|
+
const refresh = react.useCallback(() => {
|
|
1628
|
+
if (!conversationId) return;
|
|
1629
|
+
const mine = ++seq.current;
|
|
1630
|
+
chat.liveCalls.get(conversationId).then((c) => {
|
|
1631
|
+
if (mine === seq.current) apply(c);
|
|
1632
|
+
}).catch(() => {
|
|
1633
|
+
});
|
|
1634
|
+
}, [chat, conversationId, apply]);
|
|
1635
|
+
react.useEffect(() => {
|
|
1636
|
+
apply(null);
|
|
1637
|
+
if (!conversationId) return;
|
|
1638
|
+
refresh();
|
|
1639
|
+
const conv = chat.realtime.conversation(conversationId);
|
|
1640
|
+
const offStarted = conv.onCallStarted((evt) => {
|
|
1641
|
+
seq.current++;
|
|
1642
|
+
apply(evt.call);
|
|
1643
|
+
});
|
|
1644
|
+
const offParticipants = conv.onCallParticipants((evt) => {
|
|
1645
|
+
if (evt.call_id === callIdRef.current) setParticipantIds(evt.participants);
|
|
1646
|
+
else refresh();
|
|
1647
|
+
});
|
|
1648
|
+
const offFinished = conv.onCallFinished((evt) => {
|
|
1649
|
+
if (evt.call_id !== callIdRef.current) return;
|
|
1650
|
+
seq.current++;
|
|
1651
|
+
apply(null);
|
|
1652
|
+
});
|
|
1653
|
+
let wasConnected = chat.realtime.getStatus() === "connected";
|
|
1654
|
+
const offStatus = chat.realtime.onStatus((status) => {
|
|
1655
|
+
if (status === "connected" && !wasConnected) refresh();
|
|
1656
|
+
wasConnected = status === "connected";
|
|
1657
|
+
});
|
|
1658
|
+
return () => {
|
|
1659
|
+
offStarted();
|
|
1660
|
+
offParticipants();
|
|
1661
|
+
offFinished();
|
|
1662
|
+
offStatus();
|
|
1663
|
+
};
|
|
1664
|
+
}, [chat, conversationId, apply, refresh]);
|
|
1665
|
+
return { call, participantIds, refresh };
|
|
1666
|
+
}
|
|
1617
1667
|
|
|
1618
1668
|
Object.defineProperty(exports, "ApiError", {
|
|
1619
1669
|
enumerable: true,
|
|
@@ -1635,6 +1685,38 @@ Object.defineProperty(exports, "RateLimitedError", {
|
|
|
1635
1685
|
enumerable: true,
|
|
1636
1686
|
get: function () { return sdk.RateLimitedError; }
|
|
1637
1687
|
});
|
|
1688
|
+
Object.defineProperty(exports, "callLogDisplayFor", {
|
|
1689
|
+
enumerable: true,
|
|
1690
|
+
get: function () { return sdk.callLogDisplayFor; }
|
|
1691
|
+
});
|
|
1692
|
+
Object.defineProperty(exports, "describeCallLog", {
|
|
1693
|
+
enumerable: true,
|
|
1694
|
+
get: function () { return sdk.describeCallLog; }
|
|
1695
|
+
});
|
|
1696
|
+
Object.defineProperty(exports, "formatCallDuration", {
|
|
1697
|
+
enumerable: true,
|
|
1698
|
+
get: function () { return sdk.formatCallDuration; }
|
|
1699
|
+
});
|
|
1700
|
+
Object.defineProperty(exports, "formatCallLogPreview", {
|
|
1701
|
+
enumerable: true,
|
|
1702
|
+
get: function () { return sdk.formatCallLogPreview; }
|
|
1703
|
+
});
|
|
1704
|
+
Object.defineProperty(exports, "isCallLogMessage", {
|
|
1705
|
+
enumerable: true,
|
|
1706
|
+
get: function () { return sdk.isCallLogMessage; }
|
|
1707
|
+
});
|
|
1708
|
+
Object.defineProperty(exports, "isMessageVisibleTo", {
|
|
1709
|
+
enumerable: true,
|
|
1710
|
+
get: function () { return sdk.isMessageVisibleTo; }
|
|
1711
|
+
});
|
|
1712
|
+
Object.defineProperty(exports, "parseCallLog", {
|
|
1713
|
+
enumerable: true,
|
|
1714
|
+
get: function () { return sdk.parseCallLog; }
|
|
1715
|
+
});
|
|
1716
|
+
Object.defineProperty(exports, "parseCallLogBody", {
|
|
1717
|
+
enumerable: true,
|
|
1718
|
+
get: function () { return sdk.parseCallLogBody; }
|
|
1719
|
+
});
|
|
1638
1720
|
exports.PoolseProvider = PoolseProvider;
|
|
1639
1721
|
exports.computeGroupPosition = computeGroupPosition;
|
|
1640
1722
|
exports.formatDayLabel = formatDayLabel;
|
|
@@ -1646,6 +1728,7 @@ exports.useCallRoom = useCallRoom;
|
|
|
1646
1728
|
exports.useCalls = useCalls;
|
|
1647
1729
|
exports.useConversation = useConversation;
|
|
1648
1730
|
exports.useConversations = useConversations;
|
|
1731
|
+
exports.useLiveCall = useLiveCall;
|
|
1649
1732
|
exports.useMe = useMe;
|
|
1650
1733
|
exports.useMembers = useMembers;
|
|
1651
1734
|
exports.useMessages = useMessages;
|