@poolse/react 2.15.0 → 2.15.2

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.js CHANGED
@@ -1330,6 +1330,7 @@ function useCalls(userId, opts = {}) {
1330
1330
  const [outgoing, setOutgoing] = useState(null);
1331
1331
  const [activeConversationId, setActiveConversationId] = useState(null);
1332
1332
  const [activeCallId, setActiveCallId] = useState(null);
1333
+ const [activeMedia, setActiveMedia] = useState(null);
1333
1334
  const [error, setError] = useState(null);
1334
1335
  const incomingRef = useRef(null);
1335
1336
  incomingRef.current = incoming;
@@ -1369,12 +1370,14 @@ function useCalls(userId, opts = {}) {
1369
1370
  setPhase("declined");
1370
1371
  setOutgoing(null);
1371
1372
  setActiveCallId(null);
1373
+ setActiveMedia(null);
1372
1374
  });
1373
1375
  const offBusy = calls.onBusy((call2) => {
1374
1376
  if (!isCurrent(call2.callId)) return;
1375
1377
  setPhase("busy");
1376
1378
  setOutgoing(null);
1377
1379
  setActiveCallId(null);
1380
+ setActiveMedia(null);
1378
1381
  });
1379
1382
  const offEnded = calls.onEnded((call2) => {
1380
1383
  if (!isCurrent(call2.callId)) return;
@@ -1383,12 +1386,14 @@ function useCalls(userId, opts = {}) {
1383
1386
  setOutgoing(null);
1384
1387
  setActiveConversationId(null);
1385
1388
  setActiveCallId(null);
1389
+ setActiveMedia(null);
1386
1390
  });
1387
1391
  const offCancelled = calls.onCancelled((call2) => {
1388
1392
  if (call2.callId !== incomingRef.current?.callId) return;
1389
1393
  setIncoming(null);
1390
1394
  setPhase("idle");
1391
1395
  setActiveCallId(null);
1396
+ setActiveMedia(null);
1392
1397
  });
1393
1398
  return () => {
1394
1399
  offIncoming();
@@ -1407,6 +1412,7 @@ function useCalls(userId, opts = {}) {
1407
1412
  const placed = await calls.invite(conversationId, media2);
1408
1413
  setOutgoing(placed);
1409
1414
  setActiveCallId(placed.callId);
1415
+ setActiveMedia(placed.media);
1410
1416
  setPhase("ringing-out");
1411
1417
  } catch (err) {
1412
1418
  setError(err instanceof Error ? err : new Error(String(err)));
@@ -1423,6 +1429,7 @@ function useCalls(userId, opts = {}) {
1423
1429
  await calls.accept(target);
1424
1430
  setActiveConversationId(target.conversationId);
1425
1431
  setActiveCallId(target.callId);
1432
+ setActiveMedia(target.media);
1426
1433
  setPhase("active");
1427
1434
  setIncoming(null);
1428
1435
  } catch (err) {
@@ -1442,6 +1449,7 @@ function useCalls(userId, opts = {}) {
1442
1449
  } finally {
1443
1450
  setIncoming(null);
1444
1451
  setActiveCallId(null);
1452
+ setActiveMedia(null);
1445
1453
  setPhase("idle");
1446
1454
  }
1447
1455
  },
@@ -1456,6 +1464,7 @@ function useCalls(userId, opts = {}) {
1456
1464
  } finally {
1457
1465
  setOutgoing(null);
1458
1466
  setActiveCallId(null);
1467
+ setActiveMedia(null);
1459
1468
  setPhase("idle");
1460
1469
  }
1461
1470
  }, [calls, outgoing]);
@@ -1491,6 +1500,7 @@ function useCalls(userId, opts = {}) {
1491
1500
  setOutgoing(null);
1492
1501
  setActiveConversationId(null);
1493
1502
  setActiveCallId(null);
1503
+ setActiveMedia(null);
1494
1504
  }
1495
1505
  }, [calls, phase, incoming, outgoing, activeConversationId, activeCallId]);
1496
1506
  const reset = useCallback(() => {
@@ -1499,9 +1509,10 @@ function useCalls(userId, opts = {}) {
1499
1509
  setOutgoing(null);
1500
1510
  setActiveConversationId(null);
1501
1511
  setActiveCallId(null);
1512
+ setActiveMedia(null);
1502
1513
  setError(null);
1503
1514
  }, []);
1504
- const media = incoming?.media ?? outgoing?.media ?? "audio";
1515
+ const media = incoming?.media ?? outgoing?.media ?? activeMedia ?? "audio";
1505
1516
  return {
1506
1517
  phase,
1507
1518
  incoming,