@poolse/react-native 2.8.1 → 2.8.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.d.cts CHANGED
@@ -1217,9 +1217,13 @@ interface UseVoipCallsOptions {
1217
1217
  */
1218
1218
  apnsEnvironment?: 'production' | 'sandbox';
1219
1219
  /**
1220
- * How old a pushed call may be before it is ignored, in ms. Defaults
1221
- * to 45s, matching `useCalls`' ring timeout — past that the caller has
1222
- * already given up, so there is nothing live to answer.
1220
+ * How old a pushed call may be before it is reported and immediately
1221
+ * ended, in ms. Defaults to a deliberately generous 120s.
1222
+ *
1223
+ * The tight value this once used made clock skew between server and
1224
+ * handset enough to suppress live calls. The authoritative guard is
1225
+ * server-side anyway — accepting an ended call is refused — so this is
1226
+ * only here to spare the user a ring for something long dead.
1223
1227
  *
1224
1228
  * PushKit holds a push that lands before the JS bundle is up and
1225
1229
  * replays it on launch, so opening the app can ring you for a call the
@@ -1227,6 +1231,19 @@ interface UseVoipCallsOptions {
1227
1231
  */
1228
1232
  staleAfterMs?: number;
1229
1233
  }
1234
+ /**
1235
+ * Whether a pushed call is old enough to be dismissed straight after
1236
+ * being reported.
1237
+ *
1238
+ * Exported for testing, because getting this wrong is silent and total:
1239
+ * too tight a window and clock skew between the server and the handset
1240
+ * suppresses live calls with nothing in the app to explain it.
1241
+ *
1242
+ * Never dismisses on a missing timestamp, and never on a future one —
1243
+ * skew runs both ways, and withholding a real call is far worse than
1244
+ * ringing once for a dead one.
1245
+ */
1246
+ declare function isStalePush(sentAt: number | undefined, now: number, staleAfterMs: number): boolean;
1230
1247
  /**
1231
1248
  * Registers this device for VoIP pushes and drives the native call UI.
1232
1249
  *
@@ -1235,4 +1252,4 @@ interface UseVoipCallsOptions {
1235
1252
  */
1236
1253
  declare function useVoipCalls({ voipPush, callKeep, calls, onAnswer, onDecline, appName, apnsEnvironment, staleAfterMs, }: UseVoipCallsOptions): void;
1237
1254
 
1238
- export { AttachmentPicker, type AttachmentPickerProps, AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, type CallKeepModule, CallScreen, type CallScreenProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, DaySeparator, type DaySeparatorProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, ImageMosaic, type ImageMosaicProps, type InboxUser, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, MessageList, type MessageListItem, type MessageListProps, MessageRow, type MessageRowProps, type NativeWebRtcModule, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, type PoolseRNTheme, type PoolseRNThemeOverrides, PoolseTheme, type PoolseThemeProps, primitives as Primitives, ReactionPicker, type ReactionPickerProps, ReactionStrip, type ReactionStripProps, type ThemeColors, type ThemeRadii, type ThemeShadows, type ThemeSpacing, type ThemeType, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, type UseVoipCallsOptions, UserName, type UserNameProps, VoiceRoomBar, type VoiceRoomBarProps, type VoipIncomingCall, type VoipPushModule, createNativeWebRtcAdapter, defaultDarkTheme, defaultLightTheme, isNativeWebRtcAvailable, useAppStateLifecycle, useDisplayName, usePoolseTheme, useVoipCalls };
1255
+ export { AttachmentPicker, type AttachmentPickerProps, AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, type CallKeepModule, CallScreen, type CallScreenProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, DaySeparator, type DaySeparatorProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, ImageMosaic, type ImageMosaicProps, type InboxUser, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, MessageList, type MessageListItem, type MessageListProps, MessageRow, type MessageRowProps, type NativeWebRtcModule, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, type PoolseRNTheme, type PoolseRNThemeOverrides, PoolseTheme, type PoolseThemeProps, primitives as Primitives, ReactionPicker, type ReactionPickerProps, ReactionStrip, type ReactionStripProps, type ThemeColors, type ThemeRadii, type ThemeShadows, type ThemeSpacing, type ThemeType, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, type UseVoipCallsOptions, UserName, type UserNameProps, VoiceRoomBar, type VoiceRoomBarProps, type VoipIncomingCall, type VoipPushModule, createNativeWebRtcAdapter, defaultDarkTheme, defaultLightTheme, isNativeWebRtcAvailable, isStalePush, useAppStateLifecycle, useDisplayName, usePoolseTheme, useVoipCalls };
package/dist/index.d.ts CHANGED
@@ -1217,9 +1217,13 @@ interface UseVoipCallsOptions {
1217
1217
  */
1218
1218
  apnsEnvironment?: 'production' | 'sandbox';
1219
1219
  /**
1220
- * How old a pushed call may be before it is ignored, in ms. Defaults
1221
- * to 45s, matching `useCalls`' ring timeout — past that the caller has
1222
- * already given up, so there is nothing live to answer.
1220
+ * How old a pushed call may be before it is reported and immediately
1221
+ * ended, in ms. Defaults to a deliberately generous 120s.
1222
+ *
1223
+ * The tight value this once used made clock skew between server and
1224
+ * handset enough to suppress live calls. The authoritative guard is
1225
+ * server-side anyway — accepting an ended call is refused — so this is
1226
+ * only here to spare the user a ring for something long dead.
1223
1227
  *
1224
1228
  * PushKit holds a push that lands before the JS bundle is up and
1225
1229
  * replays it on launch, so opening the app can ring you for a call the
@@ -1227,6 +1231,19 @@ interface UseVoipCallsOptions {
1227
1231
  */
1228
1232
  staleAfterMs?: number;
1229
1233
  }
1234
+ /**
1235
+ * Whether a pushed call is old enough to be dismissed straight after
1236
+ * being reported.
1237
+ *
1238
+ * Exported for testing, because getting this wrong is silent and total:
1239
+ * too tight a window and clock skew between the server and the handset
1240
+ * suppresses live calls with nothing in the app to explain it.
1241
+ *
1242
+ * Never dismisses on a missing timestamp, and never on a future one —
1243
+ * skew runs both ways, and withholding a real call is far worse than
1244
+ * ringing once for a dead one.
1245
+ */
1246
+ declare function isStalePush(sentAt: number | undefined, now: number, staleAfterMs: number): boolean;
1230
1247
  /**
1231
1248
  * Registers this device for VoIP pushes and drives the native call UI.
1232
1249
  *
@@ -1235,4 +1252,4 @@ interface UseVoipCallsOptions {
1235
1252
  */
1236
1253
  declare function useVoipCalls({ voipPush, callKeep, calls, onAnswer, onDecline, appName, apnsEnvironment, staleAfterMs, }: UseVoipCallsOptions): void;
1237
1254
 
1238
- export { AttachmentPicker, type AttachmentPickerProps, AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, type CallKeepModule, CallScreen, type CallScreenProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, DaySeparator, type DaySeparatorProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, ImageMosaic, type ImageMosaicProps, type InboxUser, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, MessageList, type MessageListItem, type MessageListProps, MessageRow, type MessageRowProps, type NativeWebRtcModule, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, type PoolseRNTheme, type PoolseRNThemeOverrides, PoolseTheme, type PoolseThemeProps, primitives as Primitives, ReactionPicker, type ReactionPickerProps, ReactionStrip, type ReactionStripProps, type ThemeColors, type ThemeRadii, type ThemeShadows, type ThemeSpacing, type ThemeType, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, type UseVoipCallsOptions, UserName, type UserNameProps, VoiceRoomBar, type VoiceRoomBarProps, type VoipIncomingCall, type VoipPushModule, createNativeWebRtcAdapter, defaultDarkTheme, defaultLightTheme, isNativeWebRtcAvailable, useAppStateLifecycle, useDisplayName, usePoolseTheme, useVoipCalls };
1255
+ export { AttachmentPicker, type AttachmentPickerProps, AttachmentPreview, type AttachmentPreviewProps, Avatar, type AvatarProps, type CallKeepModule, CallScreen, type CallScreenProps, ChatHeader, type ChatHeaderProps, ConversationList, type ConversationListProps, ConversationView, type ConversationViewProps, DaySeparator, type DaySeparatorProps, GroupDetailsSheet, type GroupDetailsSheetProps, type IconName, ImageMosaic, type ImageMosaicProps, type InboxUser, MemberList, type MemberListProps, MentionInput, type MentionInputProps, MessageActions, type MessageActionsProps, MessageBubble, type MessageBubbleProps, MessageComposer, type MessageComposerProps, MessageList, type MessageListItem, type MessageListProps, MessageRow, type MessageRowProps, type NativeWebRtcModule, PoolseIcon, type PoolseIconProps, PoolseInbox, type PoolseInboxHandle, type PoolseInboxProps, PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant, type PoolseRNTheme, type PoolseRNThemeOverrides, PoolseTheme, type PoolseThemeProps, primitives as Primitives, ReactionPicker, type ReactionPickerProps, ReactionStrip, type ReactionStripProps, type ThemeColors, type ThemeRadii, type ThemeShadows, type ThemeSpacing, type ThemeType, ThreadView, type ThreadViewProps, TypingIndicator, type TypingIndicatorProps, UploadQueueStrip, type UseVoipCallsOptions, UserName, type UserNameProps, VoiceRoomBar, type VoiceRoomBarProps, type VoipIncomingCall, type VoipPushModule, createNativeWebRtcAdapter, defaultDarkTheme, defaultLightTheme, isNativeWebRtcAvailable, isStalePush, useAppStateLifecycle, useDisplayName, usePoolseTheme, useVoipCalls };
package/dist/index.js CHANGED
@@ -5209,6 +5209,12 @@ var styles24 = StyleSheet.create({
5209
5209
  callBtnText: { color: "#ffffff", fontSize: 16, fontWeight: "600" },
5210
5210
  warn: { fontSize: 12, textAlign: "center", marginTop: 12 }
5211
5211
  });
5212
+ function isStalePush(sentAt, now, staleAfterMs) {
5213
+ if (typeof sentAt !== "number" || !Number.isFinite(sentAt)) return false;
5214
+ const age = now - sentAt;
5215
+ if (age < 0) return false;
5216
+ return age > staleAfterMs;
5217
+ }
5212
5218
  function useVoipCalls({
5213
5219
  voipPush,
5214
5220
  callKeep,
@@ -5217,15 +5223,15 @@ function useVoipCalls({
5217
5223
  onDecline,
5218
5224
  appName = "poolse",
5219
5225
  apnsEnvironment,
5220
- staleAfterMs = 45e3
5226
+ staleAfterMs = 12e4
5221
5227
  }) {
5222
5228
  const poolse = usePoolse();
5223
5229
  const shown = useRef(/* @__PURE__ */ new Map());
5224
- const seen = useRef(/* @__PURE__ */ new Set());
5225
5230
  const handlers = useRef({ onAnswer, onDecline, calls });
5226
5231
  handlers.current = { onAnswer, onDecline, calls };
5227
5232
  const staleRef = useRef(staleAfterMs);
5228
5233
  staleRef.current = staleAfterMs;
5234
+ const ready = useRef(Promise.resolve());
5229
5235
  const dismiss = useRef((callId) => {
5230
5236
  if (!shown.current.has(callId)) return;
5231
5237
  shown.current.delete(callId);
@@ -5235,11 +5241,21 @@ function useVoipCalls({
5235
5241
  }
5236
5242
  });
5237
5243
  const present = useRef((call, sentAt) => {
5238
- if (seen.current.has(call.callId)) return;
5239
- if (typeof sentAt === "number" && Date.now() - sentAt > staleRef.current) return;
5240
- seen.current.add(call.callId);
5241
5244
  shown.current.set(call.callId, call);
5242
- callKeep.displayIncomingCall(call.callId, call.callerUserId, call.callerName, "generic", false);
5245
+ const show = () => {
5246
+ try {
5247
+ callKeep.displayIncomingCall(
5248
+ call.callId,
5249
+ call.callerUserId,
5250
+ call.callerName,
5251
+ "generic",
5252
+ false
5253
+ );
5254
+ } catch {
5255
+ }
5256
+ };
5257
+ void ready.current.then(show, show);
5258
+ if (isStalePush(sentAt, Date.now(), staleRef.current)) dismiss.current(call.callId);
5243
5259
  });
5244
5260
  useEffect(() => {
5245
5261
  let cancelled = false;
@@ -5257,7 +5273,7 @@ function useVoipCalls({
5257
5273
  payload.sent_at
5258
5274
  );
5259
5275
  };
5260
- void callKeep.setup({
5276
+ ready.current = callKeep.setup({
5261
5277
  ios: { appName },
5262
5278
  android: {
5263
5279
  alertTitle: "Permissions required",
@@ -5289,8 +5305,11 @@ function useVoipCalls({
5289
5305
  }));
5290
5306
  callKeep.addEventListener("answerCall", (({ callUUID }) => {
5291
5307
  const call = shown.current.get(callUUID);
5292
- if (!call) return;
5293
5308
  shown.current.delete(callUUID);
5309
+ if (!call) {
5310
+ void handlers.current.calls?.accept();
5311
+ return;
5312
+ }
5294
5313
  void handlers.current.calls?.accept({
5295
5314
  callId: call.callId,
5296
5315
  conversationId: call.conversationId,
@@ -5301,7 +5320,10 @@ function useVoipCalls({
5301
5320
  callKeep.addEventListener("endCall", (({ callUUID }) => {
5302
5321
  const call = shown.current.get(callUUID);
5303
5322
  shown.current.delete(callUUID);
5304
- if (!call) return;
5323
+ if (!call) {
5324
+ void handlers.current.calls?.hangUp();
5325
+ return;
5326
+ }
5305
5327
  void handlers.current.calls?.decline({
5306
5328
  callId: call.callId,
5307
5329
  conversationId: call.conversationId,
@@ -5340,6 +5362,6 @@ function guessApnsEnvironment() {
5340
5362
  return __DEV__ ? "sandbox" : "production";
5341
5363
  }
5342
5364
 
5343
- export { AttachmentPicker, AttachmentPreview, Avatar, CallScreen, ChatHeader, ConversationList, ConversationView, DaySeparator, GroupDetailsSheet, ImageMosaic, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, MessageList, MessageRow, PoolseIcon, PoolseInbox, PoolseLogo, PoolseTheme, primitives as Primitives, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, UploadQueueStrip, UserName, VoiceRoomBar, createNativeWebRtcAdapter, defaultDarkTheme, defaultLightTheme, isNativeWebRtcAvailable, useAppStateLifecycle, useDisplayName, usePoolseTheme, useVoipCalls };
5365
+ export { AttachmentPicker, AttachmentPreview, Avatar, CallScreen, ChatHeader, ConversationList, ConversationView, DaySeparator, GroupDetailsSheet, ImageMosaic, MemberList, MentionInput, MessageActions, MessageBubble, MessageComposer, MessageList, MessageRow, PoolseIcon, PoolseInbox, PoolseLogo, PoolseTheme, primitives as Primitives, ReactionPicker, ReactionStrip, ThreadView, TypingIndicator, UploadQueueStrip, UserName, VoiceRoomBar, createNativeWebRtcAdapter, defaultDarkTheme, defaultLightTheme, isNativeWebRtcAvailable, isStalePush, useAppStateLifecycle, useDisplayName, usePoolseTheme, useVoipCalls };
5344
5366
  //# sourceMappingURL=index.js.map
5345
5367
  //# sourceMappingURL=index.js.map