@poolse/react-native 2.8.2 → 2.8.4
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 +23 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -12
- package/dist/index.d.ts +13 -12
- package/dist/index.js +23 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -5236,6 +5236,10 @@ var styles24 = reactNative.StyleSheet.create({
|
|
|
5236
5236
|
callBtnText: { color: "#ffffff", fontSize: 16, fontWeight: "600" },
|
|
5237
5237
|
warn: { fontSize: 12, textAlign: "center", marginTop: 12 }
|
|
5238
5238
|
});
|
|
5239
|
+
function isCallOver(phase) {
|
|
5240
|
+
if (phase === void 0) return false;
|
|
5241
|
+
return phase !== "ringing-in" && phase !== "ringing-out" && phase !== "active";
|
|
5242
|
+
}
|
|
5239
5243
|
function isStalePush(sentAt, now, staleAfterMs) {
|
|
5240
5244
|
if (typeof sentAt !== "number" || !Number.isFinite(sentAt)) return false;
|
|
5241
5245
|
const age = now - sentAt;
|
|
@@ -5259,7 +5263,9 @@ function useVoipCalls({
|
|
|
5259
5263
|
const staleRef = react.useRef(staleAfterMs);
|
|
5260
5264
|
staleRef.current = staleAfterMs;
|
|
5261
5265
|
const ready = react.useRef(Promise.resolve());
|
|
5266
|
+
const answered = react.useRef(/* @__PURE__ */ new Set());
|
|
5262
5267
|
const dismiss = react.useRef((callId) => {
|
|
5268
|
+
answered.current.delete(callId);
|
|
5263
5269
|
if (!shown.current.has(callId)) return;
|
|
5264
5270
|
shown.current.delete(callId);
|
|
5265
5271
|
try {
|
|
@@ -5281,7 +5287,14 @@ function useVoipCalls({
|
|
|
5281
5287
|
} catch {
|
|
5282
5288
|
}
|
|
5283
5289
|
};
|
|
5284
|
-
|
|
5290
|
+
const done = () => {
|
|
5291
|
+
show();
|
|
5292
|
+
try {
|
|
5293
|
+
voipPush.onVoipNotificationCompleted?.(call.callId);
|
|
5294
|
+
} catch {
|
|
5295
|
+
}
|
|
5296
|
+
};
|
|
5297
|
+
void ready.current.then(done, done);
|
|
5285
5298
|
if (isStalePush(sentAt, Date.now(), staleRef.current)) dismiss.current(call.callId);
|
|
5286
5299
|
});
|
|
5287
5300
|
react.useEffect(() => {
|
|
@@ -5332,7 +5345,11 @@ function useVoipCalls({
|
|
|
5332
5345
|
}));
|
|
5333
5346
|
callKeep.addEventListener("answerCall", (({ callUUID }) => {
|
|
5334
5347
|
const call = shown.current.get(callUUID);
|
|
5335
|
-
|
|
5348
|
+
answered.current.add(callUUID);
|
|
5349
|
+
try {
|
|
5350
|
+
callKeep.setCurrentCallActive?.(callUUID);
|
|
5351
|
+
} catch {
|
|
5352
|
+
}
|
|
5336
5353
|
if (!call) {
|
|
5337
5354
|
void handlers.current.calls?.accept();
|
|
5338
5355
|
return;
|
|
@@ -5346,8 +5363,10 @@ function useVoipCalls({
|
|
|
5346
5363
|
}));
|
|
5347
5364
|
callKeep.addEventListener("endCall", (({ callUUID }) => {
|
|
5348
5365
|
const call = shown.current.get(callUUID);
|
|
5366
|
+
const wasAnswered = answered.current.has(callUUID);
|
|
5349
5367
|
shown.current.delete(callUUID);
|
|
5350
|
-
|
|
5368
|
+
answered.current.delete(callUUID);
|
|
5369
|
+
if (!call || wasAnswered) {
|
|
5351
5370
|
void handlers.current.calls?.hangUp();
|
|
5352
5371
|
return;
|
|
5353
5372
|
}
|
|
@@ -5381,7 +5400,7 @@ function useVoipCalls({
|
|
|
5381
5400
|
}
|
|
5382
5401
|
}, [phase, incoming]);
|
|
5383
5402
|
react.useEffect(() => {
|
|
5384
|
-
if (phase
|
|
5403
|
+
if (!isCallOver(phase)) return;
|
|
5385
5404
|
for (const callId of [...shown.current.keys()]) dismiss.current(callId);
|
|
5386
5405
|
}, [phase]);
|
|
5387
5406
|
}
|