@poolse/react-native 3.0.0 → 3.1.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.d.cts CHANGED
@@ -1100,13 +1100,18 @@ declare const defaultLightTheme: PoolseRNTheme;
1100
1100
  declare const defaultDarkTheme: PoolseRNTheme;
1101
1101
 
1102
1102
  /**
1103
- * Closes the SDK WebSocket cleanly when the app backgrounds and
1104
- * reopens it when the app comes back to the foreground. Designed
1105
- * to pair with push-notification delivery on the dev's backend —
1106
- * iOS / Android suspend sockets aggressively, so we don't fight
1107
- * the OS; we let the push wake the app and resync on resume.
1103
+ * Closes the SDK WebSocket when the app goes to the background and
1104
+ * reopens it when the app comes back. iOS and Android suspend sockets
1105
+ * in the background anyway; closing cleanly avoids a half-dead
1106
+ * connection on resume. poolse sends push notifications for messages
1107
+ * and calls itself, so nothing is lost while the socket is closed.
1108
1108
  *
1109
- * Mount once near the root of your app:
1109
+ * Channel handles and their listeners survive the pause, so mounted
1110
+ * hooks keep working after resume, and `useMessages` /
1111
+ * `useConversations` reload from REST to catch up on what was sent
1112
+ * while the app was away.
1113
+ *
1114
+ * Mount once, inside the provider:
1110
1115
  *
1111
1116
  * <PoolseProvider config={config}>
1112
1117
  * <AppShell />
package/dist/index.d.ts CHANGED
@@ -1100,13 +1100,18 @@ declare const defaultLightTheme: PoolseRNTheme;
1100
1100
  declare const defaultDarkTheme: PoolseRNTheme;
1101
1101
 
1102
1102
  /**
1103
- * Closes the SDK WebSocket cleanly when the app backgrounds and
1104
- * reopens it when the app comes back to the foreground. Designed
1105
- * to pair with push-notification delivery on the dev's backend —
1106
- * iOS / Android suspend sockets aggressively, so we don't fight
1107
- * the OS; we let the push wake the app and resync on resume.
1103
+ * Closes the SDK WebSocket when the app goes to the background and
1104
+ * reopens it when the app comes back. iOS and Android suspend sockets
1105
+ * in the background anyway; closing cleanly avoids a half-dead
1106
+ * connection on resume. poolse sends push notifications for messages
1107
+ * and calls itself, so nothing is lost while the socket is closed.
1108
1108
  *
1109
- * Mount once near the root of your app:
1109
+ * Channel handles and their listeners survive the pause, so mounted
1110
+ * hooks keep working after resume, and `useMessages` /
1111
+ * `useConversations` reload from REST to catch up on what was sent
1112
+ * while the app was away.
1113
+ *
1114
+ * Mount once, inside the provider:
1110
1115
  *
1111
1116
  * <PoolseProvider config={config}>
1112
1117
  * <AppShell />
package/dist/index.js CHANGED
@@ -1316,7 +1316,8 @@ async function assetsToInputs(assets) {
1316
1316
  return {
1317
1317
  body: blob,
1318
1318
  contentType,
1319
- byteSize: asset.fileSize ?? blob.size,
1319
+ // The uploaded bytes: the server refuses a file bigger than declared.
1320
+ byteSize: blob.size || asset.fileSize || 0,
1320
1321
  filename: asset.fileName ?? `image-${Date.now()}.jpg`,
1321
1322
  _previewUri: asset.uri
1322
1323
  };
@@ -1379,7 +1380,8 @@ async function defaultAdapter(kind) {
1379
1380
  return {
1380
1381
  body: blob,
1381
1382
  contentType,
1382
- byteSize: asset.size ?? blob.size,
1383
+ // The uploaded bytes: the server refuses a file bigger than declared.
1384
+ byteSize: blob.size || asset.size || 0,
1383
1385
  filename: asset.name,
1384
1386
  _previewUri: asset.uri
1385
1387
  };
@@ -5410,22 +5412,9 @@ var primitives = { PoolseIcon, PoolseLogo, Avatar };
5410
5412
  function useAppStateLifecycle() {
5411
5413
  const poolse = usePoolse();
5412
5414
  useEffect(() => {
5413
- let prev = AppState.currentState;
5414
5415
  const sub = AppState.addEventListener("change", (next) => {
5415
- const wasActive = prev === "active";
5416
- const isActive = next === "active";
5417
- if (wasActive && !isActive) {
5418
- try {
5419
- poolse.realtime?.disconnect?.();
5420
- } catch {
5421
- }
5422
- } else if (!wasActive && isActive) {
5423
- try {
5424
- poolse.realtime?.connect?.();
5425
- } catch {
5426
- }
5427
- }
5428
- prev = next;
5416
+ if (next === "background") poolse.realtime.pause();
5417
+ else if (next === "active") poolse.realtime.resume();
5429
5418
  });
5430
5419
  return () => sub.remove();
5431
5420
  }, [poolse]);