@marktiderman/genesis-chat 0.11.4 → 0.12.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/README.md +116 -3
- package/dist/{chunk-ZQFREERR.js → chunk-2HNQWDLF.js} +3 -3
- package/dist/{chunk-ZQFREERR.js.map → chunk-2HNQWDLF.js.map} +1 -1
- package/dist/{chunk-O2QSBRSH.js → chunk-3HQN2FZ5.js} +3 -3
- package/dist/{chunk-O2QSBRSH.js.map → chunk-3HQN2FZ5.js.map} +1 -1
- package/dist/{chunk-D4RPOYB7.js → chunk-K5GYNHNE.js} +61 -11
- package/dist/chunk-K5GYNHNE.js.map +1 -0
- package/dist/{chunk-5XYDVUPS.js → chunk-VBIYDXL2.js} +9 -3
- package/dist/chunk-VBIYDXL2.js.map +1 -0
- package/dist/{client-DP7rhJ1U.d.ts → client-DJs3ltZc.d.ts} +15 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/native.d.ts +339 -137
- package/dist/native.js +668 -192
- package/dist/native.js.map +1 -1
- package/dist/{outbox-C4LnqpKT.d.ts → outbox-YFTbGIAl.d.ts} +1 -1
- package/dist/push.d.ts +2 -2
- package/dist/react.d.ts +13 -5
- package/dist/react.js +3 -3
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/{thread-CSzdqNR_.d.ts → thread-CgHP00Jw.d.ts} +1 -1
- package/dist/web.d.ts +3 -3
- package/dist/web.js +5 -5
- package/migrations/0006_genesis_chat_read_receipts.sql +110 -0
- package/migrations/tests/0006_genesis_chat_read_receipts.test.sql +131 -0
- package/package.json +7 -3
- package/src/core/client.ts +9 -0
- package/src/core/types.ts +7 -0
- package/src/native/__tests__/bubble-native-feel.test.tsx +153 -0
- package/src/native/__tests__/composer-attach-menu.test.tsx +47 -0
- package/src/native/__tests__/media-cache-key.test.tsx +21 -0
- package/src/native/__tests__/organise-screens.test.tsx +2 -0
- package/src/native/__tests__/receipts.test.ts +95 -0
- package/src/native/__tests__/review-lows.test.tsx +80 -0
- package/src/native/__tests__/sheets-fit.test.tsx +45 -0
- package/src/native/__tests__/stable-hooks.test.tsx +68 -0
- package/src/native/__tests__/thread-screen-audit.test.tsx +248 -0
- package/src/native/__tests__/thread-screen.test.tsx +111 -0
- package/src/native/__tests__/thread-title.test.tsx +59 -0
- package/src/native/composer.tsx +61 -26
- package/src/native/copy.ts +40 -0
- package/src/native/emoji-picker.tsx +1 -1
- package/src/native/index.ts +6 -1
- package/src/native/media.tsx +7 -1
- package/src/native/message-actions-sheet.tsx +1 -1
- package/src/native/message-bubble.tsx +171 -19
- package/src/native/modules.ts +3 -1
- package/src/native/receipts.ts +102 -0
- package/src/native/schedule-sheet.tsx +8 -3
- package/src/native/stack-options.ts +35 -3
- package/src/native/thread-screen.tsx +243 -17
- package/src/native/thread-times.tsx +89 -0
- package/src/native/thread-title.tsx +111 -0
- package/src/native/typing-bubble.tsx +85 -0
- package/src/react/index.tsx +74 -7
- package/dist/chunk-5XYDVUPS.js.map +0 -1
- package/dist/chunk-D4RPOYB7.js.map +0 -1
package/dist/native.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { cardTitle, attachmentPreview, callAttachmentKind, ChatErrorBoundary, messagePreview } from './chunk-
|
|
2
|
-
export { attachmentPreview, cardTitle, messagePreview } from './chunk-
|
|
1
|
+
import { cardTitle, attachmentPreview, callAttachmentKind, ChatErrorBoundary, messagePreview } from './chunk-3HQN2FZ5.js';
|
|
2
|
+
export { attachmentPreview, cardTitle, messagePreview } from './chunk-3HQN2FZ5.js';
|
|
3
3
|
import { isHttpsUrl, extractLinks, scheduleLabel, scheduleQuickPicks, isSchedulable, topicKey, snippetParts } from './chunk-BJCE5O7V.js';
|
|
4
|
-
import { useChat, useInbox, usePeople, chatKeys, useScheduled, useAvailability, useTopics, useConversation, usePins, useMessageActions, useFileUrls, useLinkPreviews, useStartConversation, useBroadcast, useSearch } from './chunk-
|
|
5
|
-
import { summarizeReactions, parseMentions, startsDay, dayLabel, itemTime, itemSender, startsGroup, activityLine } from './chunk-
|
|
6
|
-
import { formatDuration, nextPlaybackRate, ChatError, CHAT_LIMITS, fileExtension, isAllowedExtension, attachmentKindFor, awaySummary, WEEKDAYS, minutesOf, waveformFromMetering, recordingLimitMs, CHAT_BUCKET, randomId } from './chunk-
|
|
4
|
+
import { useChat, useInbox, usePeople, chatKeys, useScheduled, useAvailability, useTopics, useConversation, usePins, useMessageActions, useFileUrls, useLinkPreviews, useStartConversation, useBroadcast, useSearch } from './chunk-K5GYNHNE.js';
|
|
5
|
+
import { summarizeReactions, parseMentions, startsDay, dayLabel, itemTime, itemSender, startsGroup, sameDay, activityLine } from './chunk-2HNQWDLF.js';
|
|
6
|
+
import { formatDuration, nextPlaybackRate, ChatError, CHAT_LIMITS, fileExtension, isAllowedExtension, attachmentKindFor, awaySummary, WEEKDAYS, minutesOf, waveformFromMetering, recordingLimitMs, CHAT_BUCKET, randomId } from './chunk-VBIYDXL2.js';
|
|
7
7
|
export { CHAT_MARK_READ_ACTION, CHAT_PUSH_CATEGORY, CHAT_REPLY_ACTION, PUSH_REPLY_WAIT_MS, chatNotificationActions, chatPath, chatPushCategory, chatPushCopy, chatPushPayload, chatThreadMatch, conversationIdFromData, failedReply, handleChatPushResponse, registerChatNotificationActions, replyClientId, replyClientIdFor } from './chunk-BTG4JWLF.js';
|
|
8
|
-
import { createContext, memo, useMemo, useState, useCallback, useRef, useContext, useSyncExternalStore, useLayoutEffect, useEffect, useReducer } from 'react';
|
|
9
|
-
import { NativeText, NativeAvatar, NativeImage, NativeIcon, NativeButton, LIGHTBOX_DISMISS_DISTANCE, LIGHTBOX_DISMISS_VELOCITY, LIGHTBOX_MAX_ZOOM, lightboxPanLimit, lightboxPinchScale, lightboxShouldDismiss,
|
|
8
|
+
import { createContext, memo, useMemo, useState, useCallback, useRef, useContext, useSyncExternalStore, useLayoutEffect, useEffect, useReducer, createElement, isValidElement } from 'react';
|
|
9
|
+
import { NativeText, useGenesisModules, NativeAvatar, NativeImage, NativeIcon, NativeButton, LIGHTBOX_DISMISS_DISTANCE, LIGHTBOX_DISMISS_VELOCITY, LIGHTBOX_MAX_ZOOM, lightboxPanLimit, lightboxPinchScale, lightboxShouldDismiss, NativeProgress, useToast, NativeSheet, NativeDatePicker, NativeTimePicker, NativeListItem, NativeSkeleton, NativeEmptyState, NativeSheetScrollView, NativeTextarea, NativeSwitch, NativeCombobox, NativeChipGroup, NativeChip, NativeInput, NativeSearchBar, NativeComposerBar, NativeContextMenu, NativeInlineAlert, NativeLightbox, NativeThreadList, NativeCheckbox, NativeBadge } from '@marktiderman/genesis-ui-native/components';
|
|
10
10
|
import { InboxPage, SettingsSubPage, getThreadPageStackOptions, formatInboxTime } from '@marktiderman/genesis-ui-native/layouts';
|
|
11
11
|
import { Pressable, Animated, PanResponder, View, Linking, useWindowDimensions, ActivityIndicator, AppState, Modal, AccessibilityInfo, ScrollView, FlatList, Platform, KeyboardAvoidingView, Alert } from 'react-native';
|
|
12
12
|
import { useThemeRoles, sentBubbleColor, playHaptic, useReducedMotion } from '@marktiderman/genesis-ui-native/hooks';
|
|
13
13
|
import { reportError } from '@marktiderman/genesis-core/errors';
|
|
14
14
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
15
|
-
import { useQueryClient } from '@tanstack/react-query';
|
|
15
|
+
import { useQueryClient, useQuery } from '@tanstack/react-query';
|
|
16
16
|
import { useSafeAreaInsets, SafeAreaView } from 'react-native-safe-area-context';
|
|
17
17
|
|
|
18
18
|
// src/native/organise-copy.ts
|
|
@@ -128,6 +128,13 @@ var chatNativeCopy = {
|
|
|
128
128
|
archive: "Archive",
|
|
129
129
|
threadEmptyTitle: "No messages yet",
|
|
130
130
|
threadEmptyBody: "Say hello below.",
|
|
131
|
+
threadErrorTitle: "Couldn't load messages",
|
|
132
|
+
threadErrorBody: "Check your connection, then try again.",
|
|
133
|
+
waitingForNetwork: "Waiting for network\u2026",
|
|
134
|
+
connecting: "Connecting\u2026",
|
|
135
|
+
newMessagesPillOne: "1 new message",
|
|
136
|
+
newMessagesPill: "{count} new messages",
|
|
137
|
+
newMessagesPillHint: "Goes to the newest message",
|
|
131
138
|
loadEarlier: "Load earlier messages",
|
|
132
139
|
newMessages: "New messages",
|
|
133
140
|
placeholder: "Message",
|
|
@@ -213,6 +220,15 @@ var chatNativeCopy = {
|
|
|
213
220
|
viewerHint: "Swipe up or down for the next or previous photo.",
|
|
214
221
|
sending: "Sending",
|
|
215
222
|
notSent: "Not sent",
|
|
223
|
+
receiptSending: "Sending\u2026",
|
|
224
|
+
receiptSent: "Sent",
|
|
225
|
+
receiptDelivered: "Delivered",
|
|
226
|
+
receiptRead: "Read",
|
|
227
|
+
receiptReadAt: "Read {time}",
|
|
228
|
+
receiptReadBy: "Read by {count}",
|
|
229
|
+
receiptReadByEveryone: "Read by everyone",
|
|
230
|
+
receiptReadersHint: "Shows who has read it",
|
|
231
|
+
receiptReadersTitle: "Read by",
|
|
216
232
|
retry: "Retry",
|
|
217
233
|
attachAgain: "Attach again",
|
|
218
234
|
discard: "Delete",
|
|
@@ -1058,6 +1074,7 @@ function fromServer(a, urls) {
|
|
|
1058
1074
|
key: a.id,
|
|
1059
1075
|
kind: a.kind,
|
|
1060
1076
|
uri: (a.path ? urls[a.path] : null) ?? a.url ?? null,
|
|
1077
|
+
cacheKey: a.path && a.provider === "storage" ? a.path : null,
|
|
1061
1078
|
name: a.name,
|
|
1062
1079
|
width: a.width,
|
|
1063
1080
|
height: a.height,
|
|
@@ -1135,7 +1152,7 @@ function MessageAttachments({ attachments, mine, onOpenImage, testID }) {
|
|
|
1135
1152
|
disabled: !a.uri || !onOpenImage,
|
|
1136
1153
|
onPress: () => a.uri && onOpenImage?.(a.uri, alt),
|
|
1137
1154
|
style: { borderRadius: 14, overflow: "hidden" },
|
|
1138
|
-
children: a.uri ? /* @__PURE__ */ jsx(NativeImage, { src: a.uri, width: w, height: h, placeholder: a.thumbhash ? { thumbhash: a.thumbhash } : void 0, recyclingKey: a.key }) : /* @__PURE__ */ jsx(View, { style: { width: w, height: h, backgroundColor: colors.fill } })
|
|
1155
|
+
children: a.uri ? /* @__PURE__ */ jsx(NativeImage, { src: a.uri, width: w, height: h, placeholder: a.thumbhash ? { thumbhash: a.thumbhash } : void 0, cacheKey: a.cacheKey ?? void 0, recyclingKey: a.key }) : /* @__PURE__ */ jsx(View, { style: { width: w, height: h, backgroundColor: colors.fill } })
|
|
1139
1156
|
},
|
|
1140
1157
|
a.key
|
|
1141
1158
|
);
|
|
@@ -1242,8 +1259,84 @@ function ModerationMarker({ note, mine, testID }) {
|
|
|
1242
1259
|
/* @__PURE__ */ jsx(NativeText, { preset: "caption", className: mine ? "text-primary-foreground" : void 0, style: mine ? { fontWeight: "600", flexShrink: 1 } : { color, fontWeight: "600", flexShrink: 1 }, children: moderationText(note, copy) })
|
|
1243
1260
|
] });
|
|
1244
1261
|
}
|
|
1262
|
+
var TIME_REVEAL_WIDTH = 64;
|
|
1263
|
+
function startsTimeReveal(dx, dy) {
|
|
1264
|
+
return dx < -12 && Math.abs(dx) > Math.abs(dy) * 2;
|
|
1265
|
+
}
|
|
1266
|
+
function timeRevealFor(dx) {
|
|
1267
|
+
return Math.max(0, Math.min(TIME_REVEAL_WIDTH, -dx));
|
|
1268
|
+
}
|
|
1269
|
+
var TimesContext = createContext(null);
|
|
1270
|
+
function useTimeReveal(reducedMotion) {
|
|
1271
|
+
const value = useRef(new Animated.Value(0)).current;
|
|
1272
|
+
const reduced = useRef(reducedMotion);
|
|
1273
|
+
reduced.current = reducedMotion;
|
|
1274
|
+
const responder = useMemo(() => {
|
|
1275
|
+
const back = () => {
|
|
1276
|
+
if (reduced.current) value.setValue(0);
|
|
1277
|
+
else Animated.spring(value, { toValue: 0, useNativeDriver: true, bounciness: 0, speed: 16 }).start();
|
|
1278
|
+
};
|
|
1279
|
+
return PanResponder.create({
|
|
1280
|
+
onMoveShouldSetPanResponder: (_e, g) => startsTimeReveal(g.dx, g.dy),
|
|
1281
|
+
onPanResponderMove: (_e, g) => value.setValue(timeRevealFor(g.dx)),
|
|
1282
|
+
onPanResponderRelease: back,
|
|
1283
|
+
onPanResponderTerminate: back
|
|
1284
|
+
});
|
|
1285
|
+
}, [value]);
|
|
1286
|
+
return { value, panHandlers: responder.panHandlers };
|
|
1287
|
+
}
|
|
1288
|
+
function ChatTimesProvider({ value, children }) {
|
|
1289
|
+
return /* @__PURE__ */ jsx(TimesContext.Provider, { value, children });
|
|
1290
|
+
}
|
|
1291
|
+
function TimeRevealRow({ time, testID, children }) {
|
|
1292
|
+
const reveal = useContext(TimesContext);
|
|
1293
|
+
const colors = useThemeRoles();
|
|
1294
|
+
const styles = useMemo(
|
|
1295
|
+
() => reveal ? {
|
|
1296
|
+
row: { transform: [{ translateX: reveal.interpolate({ inputRange: [0, TIME_REVEAL_WIDTH], outputRange: [0, -TIME_REVEAL_WIDTH], extrapolate: "clamp" }) }] },
|
|
1297
|
+
time: { opacity: reveal.interpolate({ inputRange: [0, TIME_REVEAL_WIDTH], outputRange: [0, 1], extrapolate: "clamp" }) }
|
|
1298
|
+
} : null,
|
|
1299
|
+
[reveal]
|
|
1300
|
+
);
|
|
1301
|
+
if (!styles) return /* @__PURE__ */ jsx(View, { children });
|
|
1302
|
+
return /* @__PURE__ */ jsxs(Animated.View, { style: styles.row, children: [
|
|
1303
|
+
children,
|
|
1304
|
+
/* @__PURE__ */ jsx(
|
|
1305
|
+
Animated.View,
|
|
1306
|
+
{
|
|
1307
|
+
testID: `${testID}-time-reveal`,
|
|
1308
|
+
pointerEvents: "none",
|
|
1309
|
+
accessibilityElementsHidden: true,
|
|
1310
|
+
importantForAccessibility: "no-hide-descendants",
|
|
1311
|
+
style: [{ position: "absolute", top: 0, bottom: 0, right: -TIME_REVEAL_WIDTH, width: TIME_REVEAL_WIDTH, alignItems: "center", justifyContent: "center" }, styles.time],
|
|
1312
|
+
children: /* @__PURE__ */ jsx(NativeText, { preset: "caption", numberOfLines: 1, adjustsFontSizeToFit: true, minimumFontScale: 0.6, style: { color: colors.tertiaryLabel }, children: time })
|
|
1313
|
+
}
|
|
1314
|
+
)
|
|
1315
|
+
] });
|
|
1316
|
+
}
|
|
1245
1317
|
var SWIPE_REPLY = 56;
|
|
1246
1318
|
var SWIPE_MAX = 80;
|
|
1319
|
+
function bubblePosition(row) {
|
|
1320
|
+
if (row.groupStart && row.groupEnd) return "single";
|
|
1321
|
+
if (row.groupStart) return "first";
|
|
1322
|
+
if (row.groupEnd) return "last";
|
|
1323
|
+
return "middle";
|
|
1324
|
+
}
|
|
1325
|
+
var ROUND = 18;
|
|
1326
|
+
var TIGHT = 5;
|
|
1327
|
+
function bubbleCorners(position, mine) {
|
|
1328
|
+
const joinsAbove = position === "middle" || position === "last";
|
|
1329
|
+
const joinsBelow = position === "first" || position === "middle";
|
|
1330
|
+
const near = { top: joinsAbove ? TIGHT : ROUND, bottom: joinsBelow ? TIGHT : ROUND };
|
|
1331
|
+
return {
|
|
1332
|
+
borderTopLeftRadius: mine ? ROUND : near.top,
|
|
1333
|
+
borderBottomLeftRadius: mine ? ROUND : near.bottom,
|
|
1334
|
+
borderTopRightRadius: mine ? near.top : ROUND,
|
|
1335
|
+
borderBottomRightRadius: mine ? near.bottom : ROUND,
|
|
1336
|
+
tail: position === "last" || position === "single"
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1339
|
+
var FRESH_MS = 1500;
|
|
1247
1340
|
function formatClock(iso) {
|
|
1248
1341
|
return new Date(iso).toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
|
|
1249
1342
|
}
|
|
@@ -1300,6 +1393,16 @@ function MessageBubbleImpl(props) {
|
|
|
1300
1393
|
return c ? { label: c.label, run: () => void runs.run(a.id, c.run) } : null;
|
|
1301
1394
|
}) : [];
|
|
1302
1395
|
const playingVoice = usePlayingVoiceNote(voices.map((a) => a.key));
|
|
1396
|
+
const genesis = useGenesisModules();
|
|
1397
|
+
const Swipeable = genesis.swipeable;
|
|
1398
|
+
const reanimated = genesis.reanimated;
|
|
1399
|
+
const [entering] = useState(() => {
|
|
1400
|
+
const rise = reanimated?.FadeInDown;
|
|
1401
|
+
if (!pending || reducedMotion || !rise || Date.now() - new Date(pending.createdAt).getTime() >= FRESH_MS) return void 0;
|
|
1402
|
+
const timed = rise.duration(240);
|
|
1403
|
+
return reanimated.ReduceMotion && timed.reduceMotion ? timed.reduceMotion(reanimated.ReduceMotion.System) : timed;
|
|
1404
|
+
});
|
|
1405
|
+
const swipeRef = useRef(null);
|
|
1303
1406
|
const x = useRef(new Animated.Value(0)).current;
|
|
1304
1407
|
const latest = useRef(props);
|
|
1305
1408
|
latest.current = props;
|
|
@@ -1332,10 +1435,14 @@ function MessageBubbleImpl(props) {
|
|
|
1332
1435
|
return /* @__PURE__ */ jsx(View, { testID, style: { alignItems: "center", paddingVertical: 6, paddingHorizontal: 24 }, children: /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: colors.secondaryLabel, textAlign: "center" }, children: displayBody(message.body) }) });
|
|
1333
1436
|
}
|
|
1334
1437
|
const canSwipe = Boolean(message && !message.deletedAt && props.onReply);
|
|
1438
|
+
const corners = bubbleCorners(bubblePosition(row), mine);
|
|
1439
|
+
const tail = corners.tail && !props.highlighted;
|
|
1440
|
+
const Root = reanimated ? reanimated.default.View : View;
|
|
1335
1441
|
const reactions = message ? summarizeReactions(message, me) : [];
|
|
1336
1442
|
const time = formatClock(createdAt);
|
|
1337
1443
|
const moderation = moderationNote(message, { mine, observer: Boolean(props.observer) });
|
|
1338
|
-
const
|
|
1444
|
+
const receipt = failed ? null : props.receipt ?? null;
|
|
1445
|
+
const statusText = failed ? copy.notSent : receipt ? receipt : sending ? copy.sending : null;
|
|
1339
1446
|
const label = [
|
|
1340
1447
|
senderName,
|
|
1341
1448
|
message?.deletedAt ? copy.deleted : displayBody(body),
|
|
@@ -1400,80 +1507,106 @@ function MessageBubbleImpl(props) {
|
|
|
1400
1507
|
const bubbleColor = mine ? sentBubbleColor(colors) : colors.surface;
|
|
1401
1508
|
const fg = mine ? "text-primary-foreground" : void 0;
|
|
1402
1509
|
const textStyle = mine ? { fontSize: 17, lineHeight: 22 } : { fontSize: 17, lineHeight: 22, color: colors.label };
|
|
1510
|
+
const bubbleRow = /* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "flex-end", justifyContent: mine ? "flex-end" : "flex-start" }, children: [
|
|
1511
|
+
group && !mine ? /* @__PURE__ */ jsx(View, { style: { width: 40, alignItems: "flex-start", zIndex: 1 }, children: row.showAvatar ? /* @__PURE__ */ jsx(NativeAvatar, { size: 32, src: sender?.avatarUrl ?? null, fallback: initials(sender?.name), alt: sender?.name, recyclingKey: row.senderId ?? void 0 }) : null }) : null,
|
|
1512
|
+
/* @__PURE__ */ jsxs(
|
|
1513
|
+
Animated.View,
|
|
1514
|
+
{
|
|
1515
|
+
style: { maxWidth: "80%", transform: [{ translateX: x }] },
|
|
1516
|
+
...canSwipe && !Swipeable ? responder.panHandlers : {},
|
|
1517
|
+
children: [
|
|
1518
|
+
/* @__PURE__ */ jsxs(
|
|
1519
|
+
Pressable,
|
|
1520
|
+
{
|
|
1521
|
+
testID: `${testID}-bubble`,
|
|
1522
|
+
accessible: true,
|
|
1523
|
+
accessibilityLabel: label,
|
|
1524
|
+
accessibilityHint: failed ? copy.retry : void 0,
|
|
1525
|
+
accessibilityActions: actions,
|
|
1526
|
+
onAccessibilityAction: (e) => onAction(e.nativeEvent.actionName),
|
|
1527
|
+
onLongPress: message && !message.deletedAt ? () => props.onLongPress?.(message) : void 0,
|
|
1528
|
+
delayLongPress: 350,
|
|
1529
|
+
style: {
|
|
1530
|
+
paddingHorizontal: attachments.length && !body ? 4 : 12,
|
|
1531
|
+
paddingVertical: attachments.length && !body ? 4 : 8,
|
|
1532
|
+
borderTopLeftRadius: corners.borderTopLeftRadius,
|
|
1533
|
+
borderTopRightRadius: corners.borderTopRightRadius,
|
|
1534
|
+
borderBottomLeftRadius: corners.borderBottomLeftRadius,
|
|
1535
|
+
borderBottomRightRadius: corners.borderBottomRightRadius,
|
|
1536
|
+
backgroundColor: bubbleColor,
|
|
1537
|
+
opacity: sending ? 0.6 : moderation === "hidden-mine" ? 0.7 : 1,
|
|
1538
|
+
gap: 4
|
|
1539
|
+
},
|
|
1540
|
+
children: [
|
|
1541
|
+
quote ? /* @__PURE__ */ jsxs(
|
|
1542
|
+
View,
|
|
1543
|
+
{
|
|
1544
|
+
testID: `${testID}-quote`,
|
|
1545
|
+
style: { borderLeftWidth: 3, borderLeftColor: mine ? colors.surface : colors.tint, paddingLeft: 8, paddingVertical: 2, opacity: 0.85 },
|
|
1546
|
+
children: [
|
|
1547
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "caption", className: fg, style: mine ? { fontWeight: "600" } : { fontWeight: "600", color: colors.secondaryLabel }, children: quoted ? quoted.senderId === me ? copy.you : person(quoted.senderId)?.name ?? "" : "" }),
|
|
1548
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "caption", numberOfLines: 2, className: fg, style: mine ? void 0 : { color: colors.secondaryLabel }, children: quoted ? attachmentPreview(displayBody(quoted.body), quoted.attachments[0], kinds, Boolean(quoted.deletedAt)) : "\u2026" })
|
|
1549
|
+
]
|
|
1550
|
+
}
|
|
1551
|
+
) : null,
|
|
1552
|
+
attachments.length ? /* @__PURE__ */ jsx(MessageAttachments, { attachments, mine, onOpenImage: props.onOpenImage, testID }) : null,
|
|
1553
|
+
message && cards.length ? cards.map((a, i) => /* @__PURE__ */ jsx(
|
|
1554
|
+
AppAttachment,
|
|
1555
|
+
{
|
|
1556
|
+
attachment: a,
|
|
1557
|
+
message,
|
|
1558
|
+
kind: attachmentKindOf(kinds, a.kind),
|
|
1559
|
+
url: (a.path ? urls[a.path] : null) ?? a.url ?? null,
|
|
1560
|
+
mine,
|
|
1561
|
+
slot,
|
|
1562
|
+
onOpenAttachment: props.onOpenAttachment,
|
|
1563
|
+
onEmpty,
|
|
1564
|
+
run: (task) => void runs.run(a.id, task),
|
|
1565
|
+
state: runs.stateOf(a.id),
|
|
1566
|
+
testID: `${testID}-card-${i}`
|
|
1567
|
+
},
|
|
1568
|
+
a.id
|
|
1569
|
+
)) : null,
|
|
1570
|
+
message?.deletedAt ? /* @__PURE__ */ jsx(NativeText, { className: fg, style: [textStyle, { fontStyle: "italic", opacity: 0.7 }], children: copy.deleted }) : body ? /* @__PURE__ */ jsx(NativeText, { className: fg, style: [textStyle, attachments.length ? { paddingHorizontal: 8, paddingBottom: 4 } : null], children: displayBody(body) }) : null,
|
|
1571
|
+
moderation ? /* @__PURE__ */ jsx(ModerationMarker, { note: moderation, mine, testID: `${testID}-moderation` }) : null,
|
|
1572
|
+
preview ? /* @__PURE__ */ jsx(ChatLinkPreviewCard, { preview, mine, images: props.linkPreviewImages, testID: `${testID}-preview` }) : null
|
|
1573
|
+
]
|
|
1574
|
+
}
|
|
1575
|
+
),
|
|
1576
|
+
tail ? /* @__PURE__ */ jsx(BubbleTail, { mine, color: bubbleColor, backdrop: props.backdrop ?? colors.groupedBackground, opacity: sending ? 0.6 : moderation === "hidden-mine" ? 0.7 : 1, testID: `${testID}-tail` }) : null
|
|
1577
|
+
]
|
|
1578
|
+
}
|
|
1579
|
+
)
|
|
1580
|
+
] });
|
|
1581
|
+
const swipeable = canSwipe && Swipeable && message ? /* @__PURE__ */ jsx(
|
|
1582
|
+
Swipeable,
|
|
1583
|
+
{
|
|
1584
|
+
ref: swipeRef,
|
|
1585
|
+
testID: `${testID}-swipe`,
|
|
1586
|
+
friction: 2,
|
|
1587
|
+
leftThreshold: SWIPE_REPLY,
|
|
1588
|
+
overshootLeft: false,
|
|
1589
|
+
dragOffsetFromRightEdge: 1e4,
|
|
1590
|
+
renderLeftActions: () => /* @__PURE__ */ jsx(ReplyHint, { color: colors.secondaryLabel }),
|
|
1591
|
+
onSwipeableWillOpen: () => {
|
|
1592
|
+
props.onSwipeReply?.();
|
|
1593
|
+
props.onReply?.(message);
|
|
1594
|
+
swipeRef.current?.close?.();
|
|
1595
|
+
},
|
|
1596
|
+
children: bubbleRow
|
|
1597
|
+
}
|
|
1598
|
+
) : bubbleRow;
|
|
1403
1599
|
return /* @__PURE__ */ jsxs(
|
|
1404
|
-
|
|
1600
|
+
Root,
|
|
1405
1601
|
{
|
|
1406
1602
|
testID,
|
|
1603
|
+
entering,
|
|
1407
1604
|
accessibilityElementsHidden: invisible || void 0,
|
|
1408
1605
|
importantForAccessibility: invisible ? "no-hide-descendants" : void 0,
|
|
1409
1606
|
style: { paddingTop: row.groupStart ? 8 : 2, borderRadius: 12, backgroundColor: props.highlighted ? colors.fill : void 0, display: invisible ? "none" : void 0 },
|
|
1410
1607
|
children: [
|
|
1411
1608
|
row.showName && sender?.name ? /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { marginLeft: group ? 48 : 12, marginBottom: 2, color: colors.secondaryLabel }, children: sender.name }) : null,
|
|
1412
|
-
/* @__PURE__ */
|
|
1413
|
-
group && !mine ? /* @__PURE__ */ jsx(View, { style: { width: 40, alignItems: "flex-start" }, children: row.showAvatar ? /* @__PURE__ */ jsx(NativeAvatar, { size: 32, src: sender?.avatarUrl ?? null, fallback: initials(sender?.name), alt: sender?.name, recyclingKey: row.senderId ?? void 0 }) : null }) : null,
|
|
1414
|
-
/* @__PURE__ */ jsx(
|
|
1415
|
-
Animated.View,
|
|
1416
|
-
{
|
|
1417
|
-
style: { maxWidth: "80%", transform: [{ translateX: x }] },
|
|
1418
|
-
...canSwipe ? responder.panHandlers : {},
|
|
1419
|
-
children: /* @__PURE__ */ jsxs(
|
|
1420
|
-
Pressable,
|
|
1421
|
-
{
|
|
1422
|
-
testID: `${testID}-bubble`,
|
|
1423
|
-
accessible: true,
|
|
1424
|
-
accessibilityLabel: label,
|
|
1425
|
-
accessibilityHint: failed ? copy.retry : void 0,
|
|
1426
|
-
accessibilityActions: actions,
|
|
1427
|
-
onAccessibilityAction: (e) => onAction(e.nativeEvent.actionName),
|
|
1428
|
-
onLongPress: message && !message.deletedAt ? () => props.onLongPress?.(message) : void 0,
|
|
1429
|
-
delayLongPress: 350,
|
|
1430
|
-
style: {
|
|
1431
|
-
paddingHorizontal: attachments.length && !body ? 4 : 12,
|
|
1432
|
-
paddingVertical: attachments.length && !body ? 4 : 8,
|
|
1433
|
-
borderRadius: 18,
|
|
1434
|
-
backgroundColor: bubbleColor,
|
|
1435
|
-
opacity: sending ? 0.6 : moderation === "hidden-mine" ? 0.7 : 1,
|
|
1436
|
-
gap: 4
|
|
1437
|
-
},
|
|
1438
|
-
children: [
|
|
1439
|
-
quote ? /* @__PURE__ */ jsxs(
|
|
1440
|
-
View,
|
|
1441
|
-
{
|
|
1442
|
-
testID: `${testID}-quote`,
|
|
1443
|
-
style: { borderLeftWidth: 3, borderLeftColor: mine ? colors.surface : colors.tint, paddingLeft: 8, paddingVertical: 2, opacity: 0.85 },
|
|
1444
|
-
children: [
|
|
1445
|
-
/* @__PURE__ */ jsx(NativeText, { preset: "caption", className: fg, style: mine ? { fontWeight: "600" } : { fontWeight: "600", color: colors.secondaryLabel }, children: quoted ? quoted.senderId === me ? copy.you : person(quoted.senderId)?.name ?? "" : "" }),
|
|
1446
|
-
/* @__PURE__ */ jsx(NativeText, { preset: "caption", numberOfLines: 2, className: fg, style: mine ? void 0 : { color: colors.secondaryLabel }, children: quoted ? attachmentPreview(displayBody(quoted.body), quoted.attachments[0], kinds, Boolean(quoted.deletedAt)) : "\u2026" })
|
|
1447
|
-
]
|
|
1448
|
-
}
|
|
1449
|
-
) : null,
|
|
1450
|
-
attachments.length ? /* @__PURE__ */ jsx(MessageAttachments, { attachments, mine, onOpenImage: props.onOpenImage, testID }) : null,
|
|
1451
|
-
message && cards.length ? cards.map((a, i) => /* @__PURE__ */ jsx(
|
|
1452
|
-
AppAttachment,
|
|
1453
|
-
{
|
|
1454
|
-
attachment: a,
|
|
1455
|
-
message,
|
|
1456
|
-
kind: attachmentKindOf(kinds, a.kind),
|
|
1457
|
-
url: (a.path ? urls[a.path] : null) ?? a.url ?? null,
|
|
1458
|
-
mine,
|
|
1459
|
-
slot,
|
|
1460
|
-
onOpenAttachment: props.onOpenAttachment,
|
|
1461
|
-
onEmpty,
|
|
1462
|
-
run: (task) => void runs.run(a.id, task),
|
|
1463
|
-
state: runs.stateOf(a.id),
|
|
1464
|
-
testID: `${testID}-card-${i}`
|
|
1465
|
-
},
|
|
1466
|
-
a.id
|
|
1467
|
-
)) : null,
|
|
1468
|
-
message?.deletedAt ? /* @__PURE__ */ jsx(NativeText, { className: fg, style: [textStyle, { fontStyle: "italic", opacity: 0.7 }], children: copy.deleted }) : body ? /* @__PURE__ */ jsx(NativeText, { className: fg, style: [textStyle, attachments.length ? { paddingHorizontal: 8, paddingBottom: 4 } : null], children: displayBody(body) }) : null,
|
|
1469
|
-
moderation ? /* @__PURE__ */ jsx(ModerationMarker, { note: moderation, mine, testID: `${testID}-moderation` }) : null,
|
|
1470
|
-
preview ? /* @__PURE__ */ jsx(ChatLinkPreviewCard, { preview, mine, images: props.linkPreviewImages, testID: `${testID}-preview` }) : null
|
|
1471
|
-
]
|
|
1472
|
-
}
|
|
1473
|
-
)
|
|
1474
|
-
}
|
|
1475
|
-
)
|
|
1476
|
-
] }),
|
|
1609
|
+
/* @__PURE__ */ jsx(TimeRevealRow, { time, testID, children: swipeable }),
|
|
1477
1610
|
reactions.length ? /* @__PURE__ */ jsx(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 4, marginTop: 2, justifyContent: mine ? "flex-end" : "flex-start", marginLeft: group && !mine ? 40 : 0 }, children: reactions.map((r) => /* @__PURE__ */ jsxs(
|
|
1478
1611
|
Pressable,
|
|
1479
1612
|
{
|
|
@@ -1506,11 +1639,42 @@ function MessageBubbleImpl(props) {
|
|
|
1506
1639
|
/* @__PURE__ */ jsx(NativeText, { testID: `${testID}-failed`, preset: "caption", style: { color: colors.destructive }, children: pending?.error ?? copy.notSent }),
|
|
1507
1640
|
lost ? props.onReattach ? /* @__PURE__ */ jsx(SmallAction, { testID: `${testID}-reattach`, label: copy.attachAgain, onPress: () => props.onReattach?.(pending.clientId, pending.files ?? []), color: colors.tint }) : null : /* @__PURE__ */ jsx(SmallAction, { testID: `${testID}-retry`, label: copy.retry, onPress: () => props.onRetry?.(pending.clientId), color: colors.tint }),
|
|
1508
1641
|
/* @__PURE__ */ jsx(SmallAction, { testID: `${testID}-discard`, label: copy.discard, onPress: () => props.onDiscard?.(pending.clientId), color: colors.destructive })
|
|
1509
|
-
] }) : /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: colors.tertiaryLabel }, children: [time, message?.editedAt ? copy.edited : null, sending ? copy.sending : null].filter(Boolean).join(" \xB7 ") }) }) : null
|
|
1642
|
+
] }) : /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: colors.tertiaryLabel }, children: [time, message?.editedAt ? copy.edited : null, sending && !receipt ? copy.sending : null].filter(Boolean).join(" \xB7 ") }) }) : null,
|
|
1643
|
+
receipt ? /* @__PURE__ */ jsx(ReceiptLine, { text: receipt, onPress: props.onReceiptPress, hint: copy.receiptReadersHint, testID: `${testID}-receipt` }) : null
|
|
1510
1644
|
]
|
|
1511
1645
|
}
|
|
1512
1646
|
);
|
|
1513
1647
|
}
|
|
1648
|
+
function BubbleTail({ mine, color, backdrop, opacity, testID }) {
|
|
1649
|
+
const side = mine ? "right" : "left";
|
|
1650
|
+
return /* @__PURE__ */ jsxs(View, { testID, pointerEvents: "none", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { position: "absolute", bottom: 0, [side]: -6, width: 20, height: 18 }, children: [
|
|
1651
|
+
/* @__PURE__ */ jsx(View, { style: { position: "absolute", bottom: 0, [side]: 0, width: 20, height: 18, opacity, backgroundColor: color, [mine ? "borderBottomLeftRadius" : "borderBottomRightRadius"]: 16 } }),
|
|
1652
|
+
/* @__PURE__ */ jsx(View, { style: { position: "absolute", bottom: 0, [side]: -6, width: 12, height: 20, backgroundColor: backdrop, [mine ? "borderBottomLeftRadius" : "borderBottomRightRadius"]: 10 } })
|
|
1653
|
+
] });
|
|
1654
|
+
}
|
|
1655
|
+
function ReplyHint({ color }) {
|
|
1656
|
+
return /* @__PURE__ */ jsx(View, { pointerEvents: "none", accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { width: SWIPE_MAX, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(NativeIcon, { name: "reply", size: 20, color }) });
|
|
1657
|
+
}
|
|
1658
|
+
function ReceiptLine({ text, onPress, hint, testID }) {
|
|
1659
|
+
const colors = useThemeRoles();
|
|
1660
|
+
const words = /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: colors.secondaryLabel, fontWeight: "600" }, children: text });
|
|
1661
|
+
if (!onPress) {
|
|
1662
|
+
return /* @__PURE__ */ jsx(View, { testID, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { alignItems: "flex-end", marginTop: 1, marginRight: 12 }, children: words });
|
|
1663
|
+
}
|
|
1664
|
+
return /* @__PURE__ */ jsx(
|
|
1665
|
+
Pressable,
|
|
1666
|
+
{
|
|
1667
|
+
testID,
|
|
1668
|
+
accessibilityRole: "button",
|
|
1669
|
+
accessibilityLabel: text,
|
|
1670
|
+
accessibilityHint: hint,
|
|
1671
|
+
onPress,
|
|
1672
|
+
hitSlop: 8,
|
|
1673
|
+
style: { alignSelf: "flex-end", minHeight: 28, justifyContent: "center", marginRight: 12 },
|
|
1674
|
+
children: words
|
|
1675
|
+
}
|
|
1676
|
+
);
|
|
1677
|
+
}
|
|
1514
1678
|
function SmallAction({ label, onPress, color, testID }) {
|
|
1515
1679
|
return /* @__PURE__ */ jsx(Pressable, { testID, accessibilityRole: "button", accessibilityLabel: label, onPress, style: { minHeight: 44, minWidth: 44, paddingHorizontal: 8, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(NativeText, { preset: "label", style: { color }, children: label }) });
|
|
1516
1680
|
}
|
|
@@ -1589,6 +1753,8 @@ var HAPTIC_KIND = {
|
|
|
1589
1753
|
"record-lock": "light",
|
|
1590
1754
|
"record-start": "medium",
|
|
1591
1755
|
select: "select",
|
|
1756
|
+
/** A bubble lifting for its menu: UIKit's context-menu tap. */
|
|
1757
|
+
"long-press": "medium",
|
|
1592
1758
|
error: "error",
|
|
1593
1759
|
"record-cancel": "warning"
|
|
1594
1760
|
};
|
|
@@ -2549,9 +2715,9 @@ function ChatScheduledBar({ conversationId, testID = "chat-scheduled-bar" }) {
|
|
|
2549
2715
|
]
|
|
2550
2716
|
}
|
|
2551
2717
|
),
|
|
2552
|
-
/* @__PURE__ */ jsx(NativeSheet, { open, onOpenChange: setOpen, testID: `${testID}-sheet`, children: /* @__PURE__ */ jsxs(View, { style: { paddingVertical: 8 }, children: [
|
|
2718
|
+
/* @__PURE__ */ jsx(NativeSheet, { open, onOpenChange: setOpen, fitContent: true, testID: `${testID}-sheet`, children: /* @__PURE__ */ jsxs(View, { style: { paddingVertical: 8, flexShrink: 1 }, children: [
|
|
2553
2719
|
/* @__PURE__ */ jsx(NativeText, { preset: "h4", accessibilityRole: "header", style: { paddingHorizontal: 16, paddingBottom: 4 }, children: copy.scheduledTitle }),
|
|
2554
|
-
/* @__PURE__ */ jsx(ChatScheduledList, { conversationId, testID: `${testID}-list` })
|
|
2720
|
+
/* @__PURE__ */ jsx(NativeSheetScrollView, { testID: `${testID}-scroll`, style: { flexShrink: 1 }, children: /* @__PURE__ */ jsx(ChatScheduledList, { conversationId, testID: `${testID}-list` }) })
|
|
2555
2721
|
] }) })
|
|
2556
2722
|
] });
|
|
2557
2723
|
}
|
|
@@ -3185,7 +3351,7 @@ var EmojiCell = memo(function EmojiCell2({ entry, width, onPress, testID }) {
|
|
|
3185
3351
|
function ChatEmojiPickerSheet({ open, onClose, onSelect, testID = "chat-emoji-sheet", ...rest }) {
|
|
3186
3352
|
const { copy } = useChatNative();
|
|
3187
3353
|
const colors = useThemeRoles();
|
|
3188
|
-
return /* @__PURE__ */ jsx(NativeSheet, { open, onOpenChange: (o) => o ? void 0 : onClose(), testID, children: /* @__PURE__ */ jsxs(View, { style: { gap: 4, paddingHorizontal: 16 }, children: [
|
|
3354
|
+
return /* @__PURE__ */ jsx(NativeSheet, { open, onOpenChange: (o) => o ? void 0 : onClose(), fitContent: true, testID, children: /* @__PURE__ */ jsxs(View, { style: { gap: 4, paddingHorizontal: 16 }, children: [
|
|
3189
3355
|
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", minHeight: 44 }, children: [
|
|
3190
3356
|
/* @__PURE__ */ jsx(NativeText, { preset: "h4", accessibilityRole: "header", children: copy.emojiPicker }),
|
|
3191
3357
|
/* @__PURE__ */ jsx(Pressable, { testID: `${testID}-done`, accessibilityRole: "button", accessibilityLabel: copy.closeViewer, onPress: onClose, style: { minWidth: 44, minHeight: 44, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(NativeIcon, { name: "close", size: 22, color: colors.secondaryLabel }) })
|
|
@@ -3524,16 +3690,14 @@ function ComposerBody({ composer, canPost, onSend, signalTyping, onRecordVideo,
|
|
|
3524
3690
|
paste2 = false;
|
|
3525
3691
|
}
|
|
3526
3692
|
setCanPaste(paste2);
|
|
3527
|
-
if (!paste2 && !modules.imagePicker?.launchCameraAsync && modules.imagePicker) return pick("library"
|
|
3693
|
+
if (!paste2 && !modules.imagePicker?.launchCameraAsync && modules.imagePicker) return pick("library");
|
|
3528
3694
|
setAttachOpen(true);
|
|
3529
3695
|
};
|
|
3530
3696
|
const remaining = CHAT_LIMITS.attachmentsPerMessage - state.attachments.length;
|
|
3531
|
-
const
|
|
3532
|
-
const pick = async (from, fromSheet = true) => {
|
|
3697
|
+
const pick = async (from) => {
|
|
3533
3698
|
setAttachOpen(false);
|
|
3534
3699
|
const picker = modules.imagePicker;
|
|
3535
3700
|
if (!picker) return;
|
|
3536
|
-
if (fromSheet) await afterSheet();
|
|
3537
3701
|
try {
|
|
3538
3702
|
if (from === "camera") {
|
|
3539
3703
|
const permission = await picker.requestCameraPermissionsAsync?.();
|
|
@@ -3615,11 +3779,21 @@ function ComposerBody({ composer, canPost, onSend, signalTyping, onRecordVideo,
|
|
|
3615
3779
|
}
|
|
3616
3780
|
),
|
|
3617
3781
|
/* @__PURE__ */ jsx(ChatEmojiPickerSheet, { open: emojiOpen, onClose: () => setEmojiOpen(false), onSelect: insertEmoji, userId, testID: `${testID}-emoji-sheet` }),
|
|
3618
|
-
/* @__PURE__ */ jsx(
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3782
|
+
/* @__PURE__ */ jsx(
|
|
3783
|
+
NativeContextMenu,
|
|
3784
|
+
{
|
|
3785
|
+
open: attachOpen,
|
|
3786
|
+
onOpenChange: setAttachOpen,
|
|
3787
|
+
title: copy.attach,
|
|
3788
|
+
cancelLabel: copy.cancel,
|
|
3789
|
+
actions: [
|
|
3790
|
+
...modules.imagePicker ? [{ id: "library", label: copy.attachLibrary, onPress: () => void pick("library") }] : [],
|
|
3791
|
+
...modules.imagePicker?.launchCameraAsync ? [{ id: "camera", label: copy.attachCamera, onPress: () => void pick("camera") }] : [],
|
|
3792
|
+
...canPaste ? [{ id: "paste", label: copy.attachPaste, onPress: () => void paste() }] : []
|
|
3793
|
+
],
|
|
3794
|
+
testID: `${testID}-attach-sheet`
|
|
3795
|
+
}
|
|
3796
|
+
)
|
|
3623
3797
|
] });
|
|
3624
3798
|
}
|
|
3625
3799
|
function IconButton({
|
|
@@ -3644,15 +3818,32 @@ function IconButton({
|
|
|
3644
3818
|
}
|
|
3645
3819
|
);
|
|
3646
3820
|
}
|
|
3821
|
+
function micOffset(dx, dy) {
|
|
3822
|
+
return { x: Math.max(-120, Math.min(0, dx)), y: Math.max(-72, Math.min(0, dy)) };
|
|
3823
|
+
}
|
|
3647
3824
|
function MicButton({ voice, disabled, testID }) {
|
|
3648
3825
|
const { copy } = useChatNative();
|
|
3649
3826
|
const colors = useThemeRoles();
|
|
3827
|
+
const reducedMotion = useReducedMotion();
|
|
3828
|
+
const reduced = useRef(reducedMotion);
|
|
3829
|
+
reduced.current = reducedMotion;
|
|
3830
|
+
const followX = useRef(new Animated.Value(0)).current;
|
|
3831
|
+
const followY = useRef(new Animated.Value(0)).current;
|
|
3832
|
+
const home = useRef(() => {
|
|
3833
|
+
for (const v of [followX, followY]) {
|
|
3834
|
+
if (reduced.current) v.setValue(0);
|
|
3835
|
+
else Animated.spring(v, { toValue: 0, useNativeDriver: true, bounciness: 6 }).start();
|
|
3836
|
+
}
|
|
3837
|
+
}).current;
|
|
3650
3838
|
const { state, dispatch } = voice;
|
|
3651
3839
|
const latest = useRef(dispatch);
|
|
3652
3840
|
latest.current = dispatch;
|
|
3653
3841
|
const locked = state.phase === "recording" && state.locked;
|
|
3654
3842
|
const lockedNow = useRef(locked);
|
|
3655
3843
|
lockedNow.current = locked;
|
|
3844
|
+
useEffect(() => {
|
|
3845
|
+
if (locked || state.phase === "idle") home();
|
|
3846
|
+
}, [locked, state.phase, home]);
|
|
3656
3847
|
const lockWhenReady = useRef(false);
|
|
3657
3848
|
useEffect(() => {
|
|
3658
3849
|
if (state.phase === "recording" && lockWhenReady.current) {
|
|
@@ -3672,14 +3863,24 @@ function MicButton({ voice, disabled, testID }) {
|
|
|
3672
3863
|
if (!tapToSend) latest.current({ type: "press" });
|
|
3673
3864
|
},
|
|
3674
3865
|
onPanResponderMove: (_e, g) => {
|
|
3675
|
-
if (
|
|
3866
|
+
if (tapToSend) return;
|
|
3867
|
+
latest.current({ type: "move", dx: g.dx, dy: g.dy });
|
|
3868
|
+
if (!lockedNow.current) {
|
|
3869
|
+
const at = micOffset(g.dx, g.dy);
|
|
3870
|
+
followX.setValue(at.x);
|
|
3871
|
+
followY.setValue(at.y);
|
|
3872
|
+
}
|
|
3873
|
+
},
|
|
3874
|
+
onPanResponderRelease: () => {
|
|
3875
|
+
home();
|
|
3876
|
+
latest.current({ type: tapToSend ? "send" : "release" });
|
|
3676
3877
|
},
|
|
3677
|
-
onPanResponderRelease: () => latest.current({ type: tapToSend ? "send" : "release" }),
|
|
3678
3878
|
onPanResponderTerminate: () => {
|
|
3879
|
+
home();
|
|
3679
3880
|
if (!tapToSend) latest.current({ type: "cancel" });
|
|
3680
3881
|
}
|
|
3681
3882
|
});
|
|
3682
|
-
}, []);
|
|
3883
|
+
}, [followX, followY, home]);
|
|
3683
3884
|
const holding = !locked && (state.phase === "starting" || state.phase === "recording");
|
|
3684
3885
|
return /* @__PURE__ */ jsxs(View, { style: { alignItems: "center" }, children: [
|
|
3685
3886
|
holding ? /* @__PURE__ */ jsxs(View, { testID: `${testID}-lock-hint`, pointerEvents: "none", style: { position: "absolute", bottom: 52, width: 36, height: 56, borderRadius: 18, backgroundColor: colors.surface, alignItems: "center", justifyContent: "flex-start", paddingTop: 8 }, children: [
|
|
@@ -3705,7 +3906,14 @@ function MicButton({ voice, disabled, testID }) {
|
|
|
3705
3906
|
},
|
|
3706
3907
|
style: { width: 44, height: 44, alignItems: "center", justifyContent: "center", opacity: disabled ? 0.4 : 1, transform: [{ scale: holding ? 1.25 : 1 }] },
|
|
3707
3908
|
...disabled ? {} : responder.panHandlers,
|
|
3708
|
-
children: /* @__PURE__ */ jsx(
|
|
3909
|
+
children: /* @__PURE__ */ jsx(
|
|
3910
|
+
Animated.View,
|
|
3911
|
+
{
|
|
3912
|
+
testID: `${testID}-mic-follow`,
|
|
3913
|
+
style: { width: 34, height: 34, borderRadius: 17, alignItems: "center", justifyContent: "center", backgroundColor: locked ? colors.tint : holding ? colors.destructive : "transparent", transform: [{ translateX: followX }, { translateY: followY }] },
|
|
3914
|
+
children: /* @__PURE__ */ jsx(NativeIcon, { name: locked ? "arrow-up" : "mic", size: locked || holding ? 18 : 24, color: locked || holding ? colors.surface : colors.tint, weight: locked ? "semibold" : void 0 })
|
|
3915
|
+
}
|
|
3916
|
+
)
|
|
3709
3917
|
}
|
|
3710
3918
|
)
|
|
3711
3919
|
] });
|
|
@@ -3722,6 +3930,138 @@ function RecordingBar({ voice, testID }) {
|
|
|
3722
3930
|
state.locked ? /* @__PURE__ */ jsx(View, { accessible: true, accessibilityLabel: copy.lockedHint, children: /* @__PURE__ */ jsx(NativeIcon, { name: "lock", size: 16, color: colors.secondaryLabel }) }) : /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: state.cancelArmed ? colors.destructive : colors.secondaryLabel }, children: state.cancelArmed ? copy.releaseToCancel : copy.slideToCancel })
|
|
3723
3931
|
] });
|
|
3724
3932
|
}
|
|
3933
|
+
|
|
3934
|
+
// src/native/rows.ts
|
|
3935
|
+
function rowKey(item) {
|
|
3936
|
+
return `c:${item.type === "message" ? item.message.clientId : item.pending.clientId}`;
|
|
3937
|
+
}
|
|
3938
|
+
function buildThreadRows(items, options) {
|
|
3939
|
+
const { me, firstUnreadId, group, now = /* @__PURE__ */ new Date(), locale } = options;
|
|
3940
|
+
const rows = [];
|
|
3941
|
+
for (let i = 0; i < items.length; i++) {
|
|
3942
|
+
const item = items[i];
|
|
3943
|
+
if (startsDay(items, i)) rows.push({ type: "day", key: `d:${rowKey(item)}`, label: dayLabel(itemTime(item), now, locale) });
|
|
3944
|
+
if (item.type === "message" && item.message.id === firstUnreadId) rows.push({ type: "unread", key: "unread" });
|
|
3945
|
+
const senderId = itemSender(item);
|
|
3946
|
+
const mine = item.type === "pending" || senderId === me;
|
|
3947
|
+
const system = item.type === "message" && item.message.kind === "system";
|
|
3948
|
+
const groupStart = startsGroup(items, i) || item.type === "message" && item.message.id === firstUnreadId;
|
|
3949
|
+
const nextItem = items[i + 1];
|
|
3950
|
+
const groupEnd = !nextItem || startsGroup(items, i + 1) || nextItem.type === "message" && nextItem.message.id === firstUnreadId;
|
|
3951
|
+
rows.push({
|
|
3952
|
+
type: "message",
|
|
3953
|
+
key: rowKey(item),
|
|
3954
|
+
item,
|
|
3955
|
+
mine,
|
|
3956
|
+
senderId,
|
|
3957
|
+
groupStart,
|
|
3958
|
+
groupEnd,
|
|
3959
|
+
showName: group && !mine && !system && groupStart,
|
|
3960
|
+
showAvatar: group && !mine && !system && groupEnd
|
|
3961
|
+
});
|
|
3962
|
+
}
|
|
3963
|
+
return rows;
|
|
3964
|
+
}
|
|
3965
|
+
function invertedRows(items, options) {
|
|
3966
|
+
return buildThreadRows(items, options).reverse();
|
|
3967
|
+
}
|
|
3968
|
+
|
|
3969
|
+
// src/native/receipts.ts
|
|
3970
|
+
function lastSentReceipt(items, options) {
|
|
3971
|
+
const { me, members, group, queued, receipts = "show" } = options;
|
|
3972
|
+
if (receipts === "hide") return null;
|
|
3973
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
3974
|
+
const item = items[i];
|
|
3975
|
+
if (item.type === "pending") {
|
|
3976
|
+
if (item.pending.senderId !== me) continue;
|
|
3977
|
+
if (item.pending.status === "failed") return null;
|
|
3978
|
+
const posted = Boolean(item.pending.sentMessageId);
|
|
3979
|
+
return { key: rowKey(item), receipt: { state: posted ? "sent" : "sending" } };
|
|
3980
|
+
}
|
|
3981
|
+
const m = item.message;
|
|
3982
|
+
if (m.senderId !== me || m.kind === "system" || m.deletedAt) continue;
|
|
3983
|
+
if (m.visibility === "observers" || m.moderation === "hidden") return null;
|
|
3984
|
+
return { key: rowKey(item), receipt: receiptFor(m.seq, m.clientId) };
|
|
3985
|
+
}
|
|
3986
|
+
return null;
|
|
3987
|
+
function receiptFor(seq2, clientId) {
|
|
3988
|
+
if (queued?.has(clientId)) return { state: "sent" };
|
|
3989
|
+
const others = members.filter((x) => x.userId !== me && x.role !== "observer");
|
|
3990
|
+
const readers = others.filter((x) => x.lastReadSeq >= seq2);
|
|
3991
|
+
if (!group) {
|
|
3992
|
+
const other = readers[0];
|
|
3993
|
+
return other ? { state: "read", at: other.lastReadAt ?? null } : { state: "delivered" };
|
|
3994
|
+
}
|
|
3995
|
+
if (readers.length === 0) return { state: "delivered" };
|
|
3996
|
+
return { state: "read-by", readers: readers.map((x) => x.userId), everyone: readers.length === others.length };
|
|
3997
|
+
}
|
|
3998
|
+
}
|
|
3999
|
+
function readWhen(at, now = /* @__PURE__ */ new Date(), locale) {
|
|
4000
|
+
return sameDay(at, now.toISOString()) ? new Date(at).toLocaleTimeString(locale, { hour: "numeric", minute: "2-digit" }) : dayLabel(at, now, locale);
|
|
4001
|
+
}
|
|
4002
|
+
function receiptText(receipt, copy, now = /* @__PURE__ */ new Date(), locale) {
|
|
4003
|
+
switch (receipt.state) {
|
|
4004
|
+
case "sending":
|
|
4005
|
+
return copy.receiptSending;
|
|
4006
|
+
case "sent":
|
|
4007
|
+
return copy.receiptSent;
|
|
4008
|
+
case "delivered":
|
|
4009
|
+
return copy.receiptDelivered;
|
|
4010
|
+
case "read":
|
|
4011
|
+
return receipt.at ? fill(copy.receiptReadAt, { time: readWhen(receipt.at, now, locale) }) : copy.receiptRead;
|
|
4012
|
+
case "read-by":
|
|
4013
|
+
return receipt.everyone ? copy.receiptReadByEveryone : fill(copy.receiptReadBy, { count: receipt.readers.length });
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
var DOT = 8;
|
|
4017
|
+
var ANNOUNCE_GAP_MS = 4e3;
|
|
4018
|
+
function ChatTypingBubble({ label, userId, group, reducedMotion, testID }) {
|
|
4019
|
+
const colors = useThemeRoles();
|
|
4020
|
+
const { person } = useChatNative();
|
|
4021
|
+
const typer = userId ? person(userId) : null;
|
|
4022
|
+
const dots = useRef([new Animated.Value(0.4), new Animated.Value(0.4), new Animated.Value(0.4)]).current;
|
|
4023
|
+
const lastSaid = useRef(null);
|
|
4024
|
+
useEffect(() => {
|
|
4025
|
+
if (Platform.OS !== "ios") return;
|
|
4026
|
+
const now = Date.now();
|
|
4027
|
+
const last = lastSaid.current;
|
|
4028
|
+
if (last && (last.label === label || now - last.at < ANNOUNCE_GAP_MS)) return;
|
|
4029
|
+
lastSaid.current = { label, at: now };
|
|
4030
|
+
AccessibilityInfo.announceForAccessibility?.(label);
|
|
4031
|
+
}, [label]);
|
|
4032
|
+
useEffect(() => {
|
|
4033
|
+
if (reducedMotion) {
|
|
4034
|
+
dots.forEach((d) => d.setValue(0.6));
|
|
4035
|
+
return;
|
|
4036
|
+
}
|
|
4037
|
+
const pulses = dots.map(
|
|
4038
|
+
(d, i) => Animated.loop(
|
|
4039
|
+
Animated.sequence([
|
|
4040
|
+
Animated.timing(d, { toValue: 0.4, duration: i * 160, useNativeDriver: true }),
|
|
4041
|
+
Animated.timing(d, { toValue: 1, duration: 300, useNativeDriver: true }),
|
|
4042
|
+
Animated.timing(d, { toValue: 0.4, duration: 300, useNativeDriver: true }),
|
|
4043
|
+
Animated.timing(d, { toValue: 0.4, duration: (dots.length - 1 - i) * 160, useNativeDriver: true })
|
|
4044
|
+
])
|
|
4045
|
+
)
|
|
4046
|
+
);
|
|
4047
|
+
pulses.forEach((p) => p.start());
|
|
4048
|
+
return () => pulses.forEach((p) => p.stop());
|
|
4049
|
+
}, [dots, reducedMotion]);
|
|
4050
|
+
return /* @__PURE__ */ jsxs(
|
|
4051
|
+
View,
|
|
4052
|
+
{
|
|
4053
|
+
testID,
|
|
4054
|
+
accessible: true,
|
|
4055
|
+
accessibilityLabel: label,
|
|
4056
|
+
accessibilityLiveRegion: "polite",
|
|
4057
|
+
style: { flexDirection: "row", alignItems: "flex-end", paddingTop: 8, paddingBottom: 6, paddingHorizontal: 8 },
|
|
4058
|
+
children: [
|
|
4059
|
+
group ? /* @__PURE__ */ jsx(View, { style: { width: 40, alignItems: "flex-start" }, children: /* @__PURE__ */ jsx(NativeAvatar, { size: 32, src: typer?.avatarUrl ?? null, fallback: initials(typer?.name), alt: typer?.name, recyclingKey: userId ?? void 0 }) }) : null,
|
|
4060
|
+
/* @__PURE__ */ jsx(View, { testID: `${testID}-bubble`, style: { flexDirection: "row", alignItems: "center", gap: 5, paddingHorizontal: 14, paddingVertical: 12, borderRadius: 18, backgroundColor: colors.surface }, children: dots.map((opacity, i) => /* @__PURE__ */ jsx(Animated.View, { testID: `${testID}-dot-${i}`, style: { width: DOT, height: DOT, borderRadius: DOT / 2, backgroundColor: colors.secondaryLabel, opacity } }, i)) })
|
|
4061
|
+
]
|
|
4062
|
+
}
|
|
4063
|
+
);
|
|
4064
|
+
}
|
|
3725
4065
|
var memoryDrafts = memoryDraftStorage();
|
|
3726
4066
|
function useChatComposer(conversationId, threadRootId, userId) {
|
|
3727
4067
|
const { modules } = useChatNative();
|
|
@@ -3928,7 +4268,7 @@ function MessageActionsSheet({ message, context, onClose, onReact, onAction, att
|
|
|
3928
4268
|
onClose();
|
|
3929
4269
|
onAction(message, action);
|
|
3930
4270
|
};
|
|
3931
|
-
return /* @__PURE__ */ jsx(NativeSheet, { open: message !== null, onOpenChange: (open) => open ? void 0 : onClose(), testID, children: message && picking ? /* @__PURE__ */ jsx(View, { style: { paddingHorizontal: 16 }, children: /* @__PURE__ */ jsx(
|
|
4271
|
+
return /* @__PURE__ */ jsx(NativeSheet, { open: message !== null, onOpenChange: (open) => open ? void 0 : onClose(), fitContent: true, testID, children: message && picking ? /* @__PURE__ */ jsx(View, { style: { paddingHorizontal: 16 }, children: /* @__PURE__ */ jsx(
|
|
3932
4272
|
ChatEmojiPicker,
|
|
3933
4273
|
{
|
|
3934
4274
|
userId: context.me,
|
|
@@ -3987,42 +4327,59 @@ function MessageActionsSheet({ message, context, onClose, onReact, onAction, att
|
|
|
3987
4327
|
] })
|
|
3988
4328
|
) : null });
|
|
3989
4329
|
}
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
function rowKey(item) {
|
|
3993
|
-
return `c:${item.type === "message" ? item.message.clientId : item.pending.clientId}`;
|
|
4330
|
+
function isOnline(state) {
|
|
4331
|
+
return state.isConnected !== false && state.isInternetReachable !== false;
|
|
3994
4332
|
}
|
|
3995
|
-
function
|
|
3996
|
-
const {
|
|
3997
|
-
const
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
const
|
|
4004
|
-
|
|
4005
|
-
const
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
rows.push({
|
|
4009
|
-
type: "message",
|
|
4010
|
-
key: rowKey(item),
|
|
4011
|
-
item,
|
|
4012
|
-
mine,
|
|
4013
|
-
senderId,
|
|
4014
|
-
groupStart,
|
|
4015
|
-
groupEnd,
|
|
4016
|
-
showName: group && !mine && !system && groupStart,
|
|
4017
|
-
showAvatar: group && !mine && !system && groupEnd
|
|
4333
|
+
function useChatAutoRetry({ netInfo, appState } = {}) {
|
|
4334
|
+
const { retryAll } = useChat();
|
|
4335
|
+
const { modules } = useChatNative();
|
|
4336
|
+
const net = netInfo ?? modules.netInfo;
|
|
4337
|
+
const app = appState ?? AppState;
|
|
4338
|
+
const retry = useRef(retryAll);
|
|
4339
|
+
retry.current = retryAll;
|
|
4340
|
+
useEffect(() => {
|
|
4341
|
+
const go = () => void retry.current().catch(() => void 0);
|
|
4342
|
+
let last = app?.currentState ?? null;
|
|
4343
|
+
const sub = app?.addEventListener?.("change", (next) => {
|
|
4344
|
+
if (next === "active" && last !== "active") go();
|
|
4345
|
+
last = next;
|
|
4018
4346
|
});
|
|
4019
|
-
|
|
4020
|
-
|
|
4347
|
+
let wasOnline = null;
|
|
4348
|
+
const unsubscribe = net?.addEventListener((state) => {
|
|
4349
|
+
const online = isOnline(state);
|
|
4350
|
+
if (online && wasOnline === false) go();
|
|
4351
|
+
wasOnline = online;
|
|
4352
|
+
});
|
|
4353
|
+
return () => {
|
|
4354
|
+
sub?.remove();
|
|
4355
|
+
unsubscribe?.();
|
|
4356
|
+
};
|
|
4357
|
+
}, [net, app]);
|
|
4021
4358
|
}
|
|
4022
|
-
function
|
|
4023
|
-
|
|
4359
|
+
function ChatAutoRetry(props) {
|
|
4360
|
+
useChatAutoRetry(props);
|
|
4361
|
+
return null;
|
|
4024
4362
|
}
|
|
4025
4363
|
var PREPARED_UPLOAD_MS = 20 * 6e4;
|
|
4364
|
+
function connectionState(online, live) {
|
|
4365
|
+
if (online === false) return "offline";
|
|
4366
|
+
if (live === false) return "connecting";
|
|
4367
|
+
return "online";
|
|
4368
|
+
}
|
|
4369
|
+
function useOnline(netInfo) {
|
|
4370
|
+
const [online, setOnline] = useState(null);
|
|
4371
|
+
useEffect(() => {
|
|
4372
|
+
if (!netInfo) return;
|
|
4373
|
+
return netInfo.addEventListener((state) => setOnline(isOnline(state)));
|
|
4374
|
+
}, [netInfo]);
|
|
4375
|
+
return online;
|
|
4376
|
+
}
|
|
4377
|
+
function countUnseenBelow(messages, afterSeq, me) {
|
|
4378
|
+
if (afterSeq === null) return 0;
|
|
4379
|
+
let n = 0;
|
|
4380
|
+
for (let i = messages.length - 1; i >= 0 && messages[i].seq > afterSeq; i--) if (messages[i].senderId !== me) n++;
|
|
4381
|
+
return n;
|
|
4382
|
+
}
|
|
4026
4383
|
var AT_BOTTOM_POINTS = 120;
|
|
4027
4384
|
function threadListMode(flash, reducedMotion) {
|
|
4028
4385
|
if (flash) {
|
|
@@ -4037,9 +4394,10 @@ function nearBottom(m, slack = AT_BOTTOM_POINTS) {
|
|
|
4037
4394
|
return m.contentOffset.y + m.layoutMeasurement.height >= m.contentSize.height - slack;
|
|
4038
4395
|
}
|
|
4039
4396
|
function ChatThreadScreen(props) {
|
|
4040
|
-
const { conversationId, threadRootId = null, keyboardVerticalOffset, onOpenAttachment, jumpTo, topic: topicProp, showTopics = false, scheduling = true, availability = true,
|
|
4397
|
+
const { conversationId, threadRootId = null, keyboardVerticalOffset, onOpenAttachment, jumpTo, topic: topicProp, showTopics = false, scheduling = true, availability = true, receipts = "show", active: active2 = true, header, accessory, videoLimitMs, testID = "chat-thread" } = props;
|
|
4398
|
+
const focused = (props.focused ?? true) && active2;
|
|
4041
4399
|
const chat = useChat();
|
|
4042
|
-
const { userId, videoUpload, attachmentKinds, outbox } = chat;
|
|
4400
|
+
const { userId, videoUpload, attachmentKinds, outbox, queue } = chat;
|
|
4043
4401
|
const attachmentSlot = props.slots?.attachment;
|
|
4044
4402
|
const cardActionTimeoutMs = props.cardActionTimeoutMs;
|
|
4045
4403
|
const linkPreviewImages = chat.linkPreviewImages === true;
|
|
@@ -4056,13 +4414,14 @@ function ChatThreadScreen(props) {
|
|
|
4056
4414
|
if (jumpTo) setChosenTopic(null);
|
|
4057
4415
|
}
|
|
4058
4416
|
const topic = topicProp ?? chosenTopic ?? void 0;
|
|
4059
|
-
const conv = useConversation(conversationId, { threadRootId: threadRootId ?? void 0, topic });
|
|
4417
|
+
const conv = useConversation(conversationId, { threadRootId: threadRootId ?? void 0, topic, markRead: active2 });
|
|
4060
4418
|
const pins = usePins(conversationId);
|
|
4061
4419
|
const messageActions = useMessageActions();
|
|
4062
4420
|
const { modules, copy, person } = useChatNative();
|
|
4063
4421
|
const toast = useToast();
|
|
4064
4422
|
const colors = useThemeRoles();
|
|
4065
4423
|
const reducedMotion = useReducedMotion();
|
|
4424
|
+
const { height: windowHeight } = useWindowDimensions();
|
|
4066
4425
|
const genesis = useGenesisModules();
|
|
4067
4426
|
const listRef = useRef(null);
|
|
4068
4427
|
const toNewest = useCallback(() => listRef.current?.scrollToEnd({ animated: true }), []);
|
|
@@ -4083,6 +4442,16 @@ function ChatThreadScreen(props) {
|
|
|
4083
4442
|
() => [...conv.members.map((m) => m.userId), ...conv.messages.map((m) => m.senderId)],
|
|
4084
4443
|
[conv.members, conv.messages]
|
|
4085
4444
|
);
|
|
4445
|
+
const queued = useMemo(() => new Set(queue.map((q) => q.clientId)), [queue]);
|
|
4446
|
+
const lastReceipt = useMemo(
|
|
4447
|
+
() => lastSentReceipt(conv.items, { me: userId, members: conv.members, group, queued, receipts }),
|
|
4448
|
+
[conv.items, userId, conv.members, group, queued, receipts]
|
|
4449
|
+
);
|
|
4450
|
+
const receiptLabel = lastReceipt ? receiptText(lastReceipt.receipt, copy) : null;
|
|
4451
|
+
const receiptKey = lastReceipt?.key ?? null;
|
|
4452
|
+
const readers = lastReceipt?.receipt.state === "read-by" ? lastReceipt.receipt.readers : null;
|
|
4453
|
+
const [readersOpen, setReadersOpen] = useState(false);
|
|
4454
|
+
const openReaders = useCallback(() => setReadersOpen(true), []);
|
|
4086
4455
|
const rows = useMemo(() => buildThreadRows(conv.items, { me: userId, firstUnreadId: conv.firstUnreadId, group }), [conv.items, userId, conv.firstUnreadId, group]);
|
|
4087
4456
|
const paths = useMemo(() => conv.items.flatMap((i) => i.type === "message" ? attachmentPaths(i.message.attachments) : []), [conv.items]);
|
|
4088
4457
|
const urls = useFileUrls(paths);
|
|
@@ -4141,10 +4510,10 @@ function ChatThreadScreen(props) {
|
|
|
4141
4510
|
const { retry, discard, canPost: allowed } = conv;
|
|
4142
4511
|
const onLongPress = useCallback(
|
|
4143
4512
|
(message) => {
|
|
4144
|
-
haptic(modules.haptics, "
|
|
4513
|
+
haptic(modules.haptics ?? genesis.haptics, "long-press");
|
|
4145
4514
|
setActionsFor(message);
|
|
4146
4515
|
},
|
|
4147
|
-
[modules.haptics]
|
|
4516
|
+
[modules.haptics, genesis.haptics]
|
|
4148
4517
|
);
|
|
4149
4518
|
const onSwipeReply = useCallback(() => haptic(modules.haptics, "select"), [modules.haptics]);
|
|
4150
4519
|
const onRetry = useCallback((clientId) => void retry(clientId), [retry]);
|
|
@@ -4205,6 +4574,28 @@ function ChatThreadScreen(props) {
|
|
|
4205
4574
|
},
|
|
4206
4575
|
[copy.jumpedTo, nameOf, attachmentKinds]
|
|
4207
4576
|
);
|
|
4577
|
+
const [scrolledAwayAt, setScrolledAwayAt] = useState(null);
|
|
4578
|
+
const timeline = `${conversationId}:${threadRootId ?? ""}`;
|
|
4579
|
+
const [awayFor, setAwayFor] = useState(timeline);
|
|
4580
|
+
if (awayFor !== timeline) {
|
|
4581
|
+
setAwayFor(timeline);
|
|
4582
|
+
setScrolledAwayAt(null);
|
|
4583
|
+
}
|
|
4584
|
+
const latestSeqNow = useRef(0);
|
|
4585
|
+
latestSeqNow.current = conv.messages.length ? conv.messages[conv.messages.length - 1].seq : 0;
|
|
4586
|
+
const onAtBottomChange = useCallback((atBottom) => setScrolledAwayAt(atBottom ? null : latestSeqNow.current), []);
|
|
4587
|
+
const newBelow = countUnseenBelow(conv.messages, scrolledAwayAt, userId);
|
|
4588
|
+
const openAt = conv.firstUnreadKnown ? conv.firstUnreadId ? UNREAD_ROW_ID : null : void 0;
|
|
4589
|
+
const online = useOnline(modules.netInfo);
|
|
4590
|
+
const connection = connectionState(online, conv.live);
|
|
4591
|
+
const { reload } = conv;
|
|
4592
|
+
const [reloading, setReloading] = useState(false);
|
|
4593
|
+
const retryLoad = useCallback(() => {
|
|
4594
|
+
if (!reload) return;
|
|
4595
|
+
setReloading(true);
|
|
4596
|
+
void reload().catch(() => fail()).finally(() => setReloading(false));
|
|
4597
|
+
}, [reload, fail]);
|
|
4598
|
+
const times = useTimeReveal(reducedMotion);
|
|
4208
4599
|
const onJumpFailed = useCallback(() => {
|
|
4209
4600
|
if (jumpLoadFailed.current) jumpLoadFailed.current = false;
|
|
4210
4601
|
else toast.show({ title: copy.messageGone });
|
|
@@ -4241,11 +4632,14 @@ function ChatThreadScreen(props) {
|
|
|
4241
4632
|
onOpenAttachment,
|
|
4242
4633
|
attachmentSlot,
|
|
4243
4634
|
cardActionTimeoutMs,
|
|
4635
|
+
receipt: row.key === receiptKey ? receiptLabel : null,
|
|
4636
|
+
backdrop: colors.groupedBackground,
|
|
4637
|
+
onReceiptPress: row.key === receiptKey && readers ? openReaders : void 0,
|
|
4244
4638
|
testID: `${testID}-message-${m?.id ?? row.key}`
|
|
4245
4639
|
}
|
|
4246
4640
|
);
|
|
4247
4641
|
},
|
|
4248
|
-
[testID, copy.newMessages, userId, urls, byId, group, reducedMotion, onLongPress, allowed, reply, onSwipeReply, onRetry, onDiscard, react, onOpenImage, picker, reattachable, onReattach, previews, linkPreviewImages, attachmentKinds, onOpenAttachment, attachmentSlot, cardActionTimeoutMs, observer]
|
|
4642
|
+
[receiptKey, receiptLabel, readers, openReaders, testID, colors.groupedBackground, copy.newMessages, userId, urls, byId, group, reducedMotion, onLongPress, allowed, reply, onSwipeReply, onRetry, onDiscard, react, onOpenImage, picker, reattachable, onReattach, previews, linkPreviewImages, attachmentKinds, onOpenAttachment, attachmentSlot, cardActionTimeoutMs, observer]
|
|
4249
4643
|
);
|
|
4250
4644
|
const [videoOpen, setVideoOpen] = useState(false);
|
|
4251
4645
|
const preparedVideo = useRef(null);
|
|
@@ -4274,6 +4668,9 @@ function ChatThreadScreen(props) {
|
|
|
4274
4668
|
[conversationId, userId, replyNow, threadRootId, outbox, videoUpload, takePrepared, modules.openFile, setReply, toNewest]
|
|
4275
4669
|
);
|
|
4276
4670
|
const activity = activityLine(conv.activity, (id) => nameOf(id));
|
|
4671
|
+
const typers = conv.activity.filter((a) => a.activity === "typing");
|
|
4672
|
+
const recording = conv.activity.some((a) => a.activity !== "typing");
|
|
4673
|
+
const footer = !activity ? null : recording ? /* @__PURE__ */ jsx(ActivityLine, { text: activity, testID: `${testID}-activity` }) : /* @__PURE__ */ jsx(ChatTypingBubble, { label: activity, userId: typers[0]?.userId ?? null, group, reducedMotion, testID: `${testID}-typing` });
|
|
4277
4674
|
const topics = topicsState.topics;
|
|
4278
4675
|
const currentTopic = topic ? topics.find((t) => t.topic === topic) ?? null : null;
|
|
4279
4676
|
const topicClosed = topicClosedFor(currentTopic, conv.role);
|
|
@@ -4297,31 +4694,41 @@ function ChatThreadScreen(props) {
|
|
|
4297
4694
|
/* @__PURE__ */ jsxs(KeyboardAvoiding, { style: { flex: 1 }, ...keyboardProps, children: [
|
|
4298
4695
|
showTopicBar ? /* @__PURE__ */ jsx(ChatTopicBar, { topics, value: topic ?? null, onValueChange: setChosenTopic, canManage: canManageTopics(conv.role), onSetTopic: topicsState.setTopic, testID: `${testID}-topics` }) : null,
|
|
4299
4696
|
/* @__PURE__ */ jsx(ChatAwayLine, { text: awayLine, testID: `${testID}-away` }),
|
|
4300
|
-
/* @__PURE__ */ jsx(
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4697
|
+
/* @__PURE__ */ jsx(ChatConnectionLine, { state: connection, testID: `${testID}-connection` }),
|
|
4698
|
+
header,
|
|
4699
|
+
/* @__PURE__ */ jsxs(View, { style: { flex: 1 }, ...times.panHandlers, children: [
|
|
4700
|
+
/* @__PURE__ */ jsx(ChatTimesProvider, { value: times.value, children: /* @__PURE__ */ jsx(
|
|
4701
|
+
NativeThreadList,
|
|
4702
|
+
{
|
|
4703
|
+
ref: listRef,
|
|
4704
|
+
testID: `${testID}-list`,
|
|
4705
|
+
data: rows,
|
|
4706
|
+
keyExtractor: threadRowKey,
|
|
4707
|
+
jumpId: threadRowMessageId,
|
|
4708
|
+
getItemType: threadRowType,
|
|
4709
|
+
renderItem,
|
|
4710
|
+
loading: conv.isLoading,
|
|
4711
|
+
hasEarlier: conv.hasEarlier,
|
|
4712
|
+
onLoadEarlier: () => void conv.loadEarlier(),
|
|
4713
|
+
loadingEarlier: conv.loadingEarlier,
|
|
4714
|
+
earlierLabel: copy.loadEarlier,
|
|
4715
|
+
jumpTo: jumpMessageId,
|
|
4716
|
+
onLoadUntil,
|
|
4717
|
+
jumpAnnouncement,
|
|
4718
|
+
onJumpFailed,
|
|
4719
|
+
footer,
|
|
4720
|
+
openAt,
|
|
4721
|
+
onAtBottomChange,
|
|
4722
|
+
header: firstPageFailed && rows.length ? /* @__PURE__ */ jsx(ThreadLoadError, { onRetry: retryLoad, retrying: reloading, testID: `${testID}-load-error` }) : null,
|
|
4723
|
+
empty: firstPageFailed ? /* @__PURE__ */ jsx(ThreadLoadError, { onRetry: retryLoad, retrying: reloading, testID: `${testID}-load-error` }) : /* @__PURE__ */ jsx(NativeEmptyState, { variant: "first-run", title: copy.threadEmptyTitle, body: currentTopic?.closedAt ? copy.topicClosedNotice : copy.threadEmptyBody, testID: `${testID}-empty` })
|
|
4724
|
+
},
|
|
4725
|
+
`${conversationId}:${threadRootId ?? ""}`
|
|
4726
|
+
) }),
|
|
4727
|
+
newBelow > 0 ? /* @__PURE__ */ jsx(NewMessagesPill, { count: newBelow, onPress: toNewest, testID: `${testID}-new-below` }) : null
|
|
4728
|
+
] }),
|
|
4323
4729
|
scheduling && !threadRootId ? /* @__PURE__ */ jsx(ChatScheduledBar, { conversationId, testID: `${testID}-scheduled` }) : null,
|
|
4324
4730
|
/* @__PURE__ */ jsx(VideoUploadTray, { conversationId, userId, testID: `${testID}-video-uploads` }),
|
|
4731
|
+
accessory && !accessFailed ? /* @__PURE__ */ jsx(View, { testID: `${testID}-accessory`, children: accessory({ conversationId, composer, canPost }) }) : null,
|
|
4325
4732
|
accessFailed ? /* @__PURE__ */ jsx(ChatAccessError, { onRetry: retryAccess, retrying: retryingAccess, testID: `${testID}-access-error` }) : /* @__PURE__ */ jsx(
|
|
4326
4733
|
ChatComposer,
|
|
4327
4734
|
{
|
|
@@ -4355,6 +4762,21 @@ function ChatThreadScreen(props) {
|
|
|
4355
4762
|
testID: `${testID}-actions`
|
|
4356
4763
|
}
|
|
4357
4764
|
),
|
|
4765
|
+
/* @__PURE__ */ jsx(NativeSheet, { open: readersOpen && Boolean(readers?.length), onOpenChange: setReadersOpen, fitContent: true, testID: `${testID}-readers`, children: /* @__PURE__ */ jsxs(View, { style: { paddingTop: 20, paddingBottom: 8, paddingHorizontal: 16, gap: 8 }, children: [
|
|
4766
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "label", accessibilityRole: "header", style: { color: colors.secondaryLabel, paddingHorizontal: 4 }, children: copy.receiptReadersTitle }),
|
|
4767
|
+
/* @__PURE__ */ jsx(NativeSheetScrollView, { testID: `${testID}-readers-list`, style: { maxHeight: Math.round(windowHeight * 0.7) }, children: (readers ?? []).map((id) => {
|
|
4768
|
+
const p = person(id) ?? people[id];
|
|
4769
|
+
return /* @__PURE__ */ jsx(
|
|
4770
|
+
NativeListItem,
|
|
4771
|
+
{
|
|
4772
|
+
testID: `${testID}-readers-${id}`,
|
|
4773
|
+
title: nameOf(id),
|
|
4774
|
+
leading: /* @__PURE__ */ jsx(NativeAvatar, { size: 32, src: p?.avatarUrl ?? null, fallback: initials(p?.name), alt: p?.name, recyclingKey: id })
|
|
4775
|
+
},
|
|
4776
|
+
id
|
|
4777
|
+
);
|
|
4778
|
+
}) })
|
|
4779
|
+
] }) }),
|
|
4358
4780
|
/* @__PURE__ */ jsx(ChatPhotoViewer, { photos: viewer?.photos ?? null, initialIndex: viewer?.index, onClose: () => setViewer(null), testID: `${testID}-viewer` }),
|
|
4359
4781
|
canSchedule ? /* @__PURE__ */ jsx(ChatScheduleSheet, { open: schedule.open, onOpenChange: schedule.setOpen, onSchedule: (at) => void schedule.scheduleAt(at), testID: `${testID}-schedule` }) : null,
|
|
4360
4782
|
/* @__PURE__ */ jsx(
|
|
@@ -4362,7 +4784,7 @@ function ChatThreadScreen(props) {
|
|
|
4362
4784
|
{
|
|
4363
4785
|
open: videoOpen,
|
|
4364
4786
|
onClose: () => setVideoOpen(false),
|
|
4365
|
-
limitMs: recordingLimitMs(conv.role),
|
|
4787
|
+
limitMs: videoLimitMs ?? recordingLimitMs(conv.role),
|
|
4366
4788
|
onStart: onVideoStart,
|
|
4367
4789
|
onTick: conv.signalRecordingVideo,
|
|
4368
4790
|
onRecorded: onVideoRecorded,
|
|
@@ -4383,19 +4805,106 @@ function UnreadDivider({ label, testID }) {
|
|
|
4383
4805
|
/* @__PURE__ */ jsx(View, { style: { flex: 1, height: 1, backgroundColor: colors.tint } })
|
|
4384
4806
|
] });
|
|
4385
4807
|
}
|
|
4808
|
+
function ChatConnectionLine({ state, testID }) {
|
|
4809
|
+
const colors = useThemeRoles();
|
|
4810
|
+
const { copy } = useChatNative();
|
|
4811
|
+
if (state === "online") return null;
|
|
4812
|
+
const text = state === "offline" ? copy.waitingForNetwork : copy.connecting;
|
|
4813
|
+
return /* @__PURE__ */ jsx(View, { testID, accessible: true, accessibilityRole: "text", accessibilityLabel: text, accessibilityLiveRegion: "polite", style: { alignItems: "center", paddingVertical: 6, backgroundColor: colors.fill }, children: /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: colors.secondaryLabel, fontWeight: "600" }, children: text }) });
|
|
4814
|
+
}
|
|
4815
|
+
function ThreadLoadError({ onRetry, retrying, testID }) {
|
|
4816
|
+
const { copy } = useChatNative();
|
|
4817
|
+
return /* @__PURE__ */ jsx(
|
|
4818
|
+
NativeEmptyState,
|
|
4819
|
+
{
|
|
4820
|
+
variant: "error",
|
|
4821
|
+
title: copy.threadErrorTitle,
|
|
4822
|
+
body: copy.threadErrorBody,
|
|
4823
|
+
testID,
|
|
4824
|
+
primaryAction: /* @__PURE__ */ jsx(NativeButton, { onPress: onRetry, loading: retrying, disabled: retrying, testID: `${testID}-retry`, children: copy.retry })
|
|
4825
|
+
}
|
|
4826
|
+
);
|
|
4827
|
+
}
|
|
4828
|
+
function NewMessagesPill({ count, onPress, testID }) {
|
|
4829
|
+
const colors = useThemeRoles();
|
|
4830
|
+
const { copy } = useChatNative();
|
|
4831
|
+
const label = count === 1 ? copy.newMessagesPillOne : fill(copy.newMessagesPill, { count });
|
|
4832
|
+
return /* @__PURE__ */ jsx(View, { pointerEvents: "box-none", style: { position: "absolute", left: 0, right: 0, bottom: 8, alignItems: "center" }, children: /* @__PURE__ */ jsxs(
|
|
4833
|
+
Pressable,
|
|
4834
|
+
{
|
|
4835
|
+
testID,
|
|
4836
|
+
accessibilityRole: "button",
|
|
4837
|
+
accessibilityLabel: label,
|
|
4838
|
+
accessibilityHint: copy.newMessagesPillHint,
|
|
4839
|
+
accessibilityLiveRegion: "polite",
|
|
4840
|
+
onPress,
|
|
4841
|
+
style: { flexDirection: "row", alignItems: "center", gap: 6, minHeight: 36, paddingHorizontal: 14, borderRadius: 18, backgroundColor: colors.tint },
|
|
4842
|
+
children: [
|
|
4843
|
+
/* @__PURE__ */ jsx(NativeIcon, { name: "chevron-down", size: 14, color: colors.surface }),
|
|
4844
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: colors.surface, fontWeight: "600" }, children: label })
|
|
4845
|
+
]
|
|
4846
|
+
}
|
|
4847
|
+
) });
|
|
4848
|
+
}
|
|
4386
4849
|
function ActivityLine({ text, testID }) {
|
|
4387
4850
|
const colors = useThemeRoles();
|
|
4388
4851
|
return /* @__PURE__ */ jsx(View, { testID, accessibilityLiveRegion: "polite", style: { paddingHorizontal: 20, paddingVertical: 6 }, children: /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: colors.secondaryLabel, fontStyle: "italic" }, children: text }) });
|
|
4389
4852
|
}
|
|
4390
4853
|
var threadRowKey = (row) => row.key;
|
|
4391
|
-
var
|
|
4854
|
+
var UNREAD_ROW_ID = "genesis-chat:unread";
|
|
4855
|
+
var threadRowMessageId = (row) => row.type === "unread" ? UNREAD_ROW_ID : row.type === "message" && row.item.type === "message" ? row.item.message.id : null;
|
|
4392
4856
|
var threadRowType = (row) => row.type === "message" ? row.mine ? "mine" : "theirs" : row.type;
|
|
4857
|
+
function isAvatarData(a) {
|
|
4858
|
+
if (a === null || typeof a !== "object" || isValidElement(a)) return false;
|
|
4859
|
+
if ("$$typeof" in a) return false;
|
|
4860
|
+
return typeof a[Symbol.iterator] !== "function";
|
|
4861
|
+
}
|
|
4862
|
+
function ChatThreadTitle({ title, subtitle, avatar, onPress, pressHint, conversationId, tintColor, testID = "chat-thread-title" }) {
|
|
4863
|
+
if (subtitle === void 0 && conversationId) {
|
|
4864
|
+
return /* @__PURE__ */ jsx(AwayTitle, { conversationId, title, avatar, onPress, pressHint, tintColor, testID });
|
|
4865
|
+
}
|
|
4866
|
+
return /* @__PURE__ */ jsx(TitleBody, { title, subtitle: subtitle ?? null, avatar, onPress, pressHint, tintColor, testID });
|
|
4867
|
+
}
|
|
4868
|
+
function AwayTitle({ conversationId, ...rest }) {
|
|
4869
|
+
const { client, userId } = useChat();
|
|
4870
|
+
const { person, copy } = useChatNative();
|
|
4871
|
+
const members = useQuery({ queryKey: chatKeys.members(conversationId), queryFn: () => client.members(conversationId), staleTime: 6e4 }).data;
|
|
4872
|
+
const nameOf = useCallback((id) => person(id)?.name ?? copy.someone, [person, copy.someone]);
|
|
4873
|
+
const away = useAwayLine(conversationId, useMemo(() => members ?? [], [members]), userId, nameOf);
|
|
4874
|
+
return /* @__PURE__ */ jsx(TitleBody, { ...rest, subtitle: away });
|
|
4875
|
+
}
|
|
4876
|
+
function TitleBody({ title, subtitle, avatar, onPress, pressHint, tintColor, testID }) {
|
|
4877
|
+
const colors = useThemeRoles();
|
|
4878
|
+
const picture = isAvatarData(avatar) ? /* @__PURE__ */ jsx(NativeAvatar, { size: 28, src: avatar.src ?? null, fallback: initials(avatar.name ?? title), alt: avatar.name ?? title, recyclingKey: avatar.id }) : avatar ?? null;
|
|
4879
|
+
const label = [title, subtitle].filter(Boolean).join(", ");
|
|
4880
|
+
const body = /* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "center", gap: 8, maxWidth: 260 }, children: [
|
|
4881
|
+
picture ? /* @__PURE__ */ jsx(View, { testID: `${testID}-avatar`, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: picture }) : null,
|
|
4882
|
+
/* @__PURE__ */ jsxs(View, { style: { flexShrink: 1, alignItems: picture ? "flex-start" : "center" }, children: [
|
|
4883
|
+
/* @__PURE__ */ jsx(NativeText, { numberOfLines: 1, style: { fontSize: 17, lineHeight: 22, fontWeight: "600", color: tintColor ?? colors.label }, children: title }),
|
|
4884
|
+
subtitle ? /* @__PURE__ */ jsx(NativeText, { testID: `${testID}-subtitle`, numberOfLines: 1, preset: "caption", style: { color: colors.secondaryLabel }, children: subtitle }) : null
|
|
4885
|
+
] })
|
|
4886
|
+
] });
|
|
4887
|
+
if (!onPress) {
|
|
4888
|
+
return /* @__PURE__ */ jsx(View, { testID, accessible: true, accessibilityRole: "header", accessibilityLabel: label, children: body });
|
|
4889
|
+
}
|
|
4890
|
+
return /* @__PURE__ */ jsx(Pressable, { testID, accessibilityRole: "button", accessibilityLabel: label, accessibilityHint: pressHint, onPress, hitSlop: 8, style: { minHeight: 44, justifyContent: "center" }, children: body });
|
|
4891
|
+
}
|
|
4393
4892
|
function chatThreadStackOptions(props, background) {
|
|
4893
|
+
const { avatar, subtitle, onPressTitle, titleHint, conversationId, ...header } = props;
|
|
4894
|
+
const custom = avatar !== void 0 || subtitle !== void 0 || onPressTitle !== void 0 || conversationId !== void 0;
|
|
4895
|
+
const title = header.headerTitle ?? "Conversation";
|
|
4394
4896
|
return getThreadPageStackOptions({
|
|
4395
|
-
...
|
|
4897
|
+
...header,
|
|
4396
4898
|
// Large titles collapse into the content scroll view, which is the flipped list here.
|
|
4397
4899
|
large: false,
|
|
4398
|
-
headerOptions: {
|
|
4900
|
+
headerOptions: {
|
|
4901
|
+
headerTransparent: false,
|
|
4902
|
+
headerStyle: { backgroundColor: background },
|
|
4903
|
+
...custom ? {
|
|
4904
|
+
headerTitle: ({ tintColor }) => createElement(ChatThreadTitle, { title, subtitle, avatar, onPress: onPressTitle, pressHint: titleHint, conversationId, tintColor })
|
|
4905
|
+
} : {},
|
|
4906
|
+
...props.headerOptions
|
|
4907
|
+
}
|
|
4399
4908
|
});
|
|
4400
4909
|
}
|
|
4401
4910
|
function useChatThreadStackOptions(props) {
|
|
@@ -4442,39 +4951,6 @@ function ChatStartButton({ onPress, testID = "chat-start-button" }) {
|
|
|
4442
4951
|
const colors = useThemeRoles();
|
|
4443
4952
|
return /* @__PURE__ */ jsx(Pressable, { testID, accessibilityRole: "button", accessibilityLabel: copy.startConversation, onPress, hitSlop: 6, style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(NativeIcon, { name: "compose", size: 22, color: colors.tint }) });
|
|
4444
4953
|
}
|
|
4445
|
-
function isOnline(state) {
|
|
4446
|
-
return state.isConnected !== false && state.isInternetReachable !== false;
|
|
4447
|
-
}
|
|
4448
|
-
function useChatAutoRetry({ netInfo, appState } = {}) {
|
|
4449
|
-
const { retryAll } = useChat();
|
|
4450
|
-
const { modules } = useChatNative();
|
|
4451
|
-
const net = netInfo ?? modules.netInfo;
|
|
4452
|
-
const app = appState ?? AppState;
|
|
4453
|
-
const retry = useRef(retryAll);
|
|
4454
|
-
retry.current = retryAll;
|
|
4455
|
-
useEffect(() => {
|
|
4456
|
-
const go = () => void retry.current().catch(() => void 0);
|
|
4457
|
-
let last = app?.currentState ?? null;
|
|
4458
|
-
const sub = app?.addEventListener?.("change", (next) => {
|
|
4459
|
-
if (next === "active" && last !== "active") go();
|
|
4460
|
-
last = next;
|
|
4461
|
-
});
|
|
4462
|
-
let wasOnline = null;
|
|
4463
|
-
const unsubscribe = net?.addEventListener((state) => {
|
|
4464
|
-
const online = isOnline(state);
|
|
4465
|
-
if (online && wasOnline === false) go();
|
|
4466
|
-
wasOnline = online;
|
|
4467
|
-
});
|
|
4468
|
-
return () => {
|
|
4469
|
-
sub?.remove();
|
|
4470
|
-
unsubscribe?.();
|
|
4471
|
-
};
|
|
4472
|
-
}, [net, app]);
|
|
4473
|
-
}
|
|
4474
|
-
function ChatAutoRetry(props) {
|
|
4475
|
-
useChatAutoRetry(props);
|
|
4476
|
-
return null;
|
|
4477
|
-
}
|
|
4478
4954
|
|
|
4479
4955
|
// src/native/tus.ts
|
|
4480
4956
|
var TUS_CHUNK_BYTES = 6 * 1024 * 1024;
|
|
@@ -4940,6 +5416,6 @@ function useJumpToMessage({ target, rows, loading, has, loadUntil, scrollTo, onS
|
|
|
4940
5416
|
return { highlightedId, jumping: pending !== null };
|
|
4941
5417
|
}
|
|
4942
5418
|
|
|
4943
|
-
export { AT_BOTTOM_POINTS, AppAttachment, BUILT_IN_KINDS, CARD_ACTION_TIMEOUT_MS, CardError, ChatAccessError, ChatAttachmentCard, ChatAutoRetry, ChatAvailabilityScreen, ChatAwayLine, ChatBroadcastSheet, ChatComposer, ChatEmojiPicker, ChatEmojiPickerSheet, ChatIconButton, ChatInboxScreen, ChatLinkPreviewCard, ChatMediaViewer, ChatNativeProvider, ChatPhotoViewer, ChatScheduleSheet, ChatScheduledBar, ChatScheduledList, ChatSearchScreen, ChatStartButton, ChatStartSheet, ChatThreadScreen, ChatTopicBar, ChatVideoPlayer, ChatVideoRecorder, DISMISS_DISTANCE, DISMISS_VELOCITY, EMOJI_CATEGORIES, MAX_ZOOM, MessageActionsSheet, MessageAttachments, MessageBubble, ModerationMarker, QUICK_REACTIONS, RECENT_EMOJI_MAX, SearchSnippet, TRANSCRIPT_LINES, TUS_CHUNK_BYTES, VIDEO_CHUNK_BYTES, VIDEO_HOLD_MS, VIDEO_MIN_MS, VideoUploadTray, VoiceNotePlayer, VoiceTranscript, activePlaybackId, attachmentKindOf, attachmentPaths, availabilityInput, awayLineFor, barsThatFit, base64ToBytes, base64Utf8, broadcastOutcome, broadcastRows, buildThreadRows, canManageTopics, canReactTo, canSend, cardAction, chatNativeCopy, chatOrganiseCopy, chatThreadStackOptions, checkTopicName, chunkedPut, claimPlayback, clearDrafts, clockToDate, composerDisabledReason, composerReducer, createDraftSaver, createTusUpload, createVideoUploads, cycleVideoRate, cycleVoiceNoteRate, dateToClock, defaultScheduleAt, defaultWeek, deviceTimeZone, displayBody, draftKey, emojiEntry, emojiInCategory, emptyComposer, fileFromDataUri, fileSource, filesFromAssets, fill, forgetRecentEmoji, formFrom, formatClock, fullScreenVideo, galleryFor, haptic, hoursFromWeek, idleRecorder, inboxRow, initialVideoRecorder, initials, insertAtSelection, invertedRows, isLocalUri, isOnline, isOpenableHref, isVideoPlaying, linkHost, linkPreviewIds, liveBars, loadDraft, loadRecentEmoji, memoryDraftStorage, messageActionsFor, moderationNote, moderationText, muxPosterUrl, muxStreamUrl, nearBottom, nextOffset, openChatLink, panLimit, pauseChatPlayback, pinchScale, previewToShow, pushRecentEmoji, recentEmojiKey, recordedVideoFile, recorderStep, recordingType, releasePlayback, replyTargetFor, resolveChatCopy, rowIndexOf, rowKey, sameTimeDays, saveRecentEmoji, scheduleInputFrom, scrubSeconds, searchEmoji, shouldDismiss, slotUrl, snippetText, splitCardAttachments, threadListMode, timeZones, toSend, toggleVideo, toggleVideoMute, toggleVoiceNote, topicClosedFor, topicMenuFor, transcriptIsLong, useAwayLine, useCardRuns, useChatAutoRetry, useChatComposer, useChatNative, useChatThreadStackOptions, useJumpToMessage, usePlayingVideo, usePlayingVoiceNote, useScheduleSend, useVideoUploads, useVoiceRecorder, videoRecorderStep, videoSource, videoState, videoUploads, voiceNoteFile, waveformBars, weekFromHours, withDay, withTime };
|
|
5419
|
+
export { AT_BOTTOM_POINTS, AppAttachment, BUILT_IN_KINDS, CARD_ACTION_TIMEOUT_MS, CardError, ChatAccessError, ChatAttachmentCard, ChatAutoRetry, ChatAvailabilityScreen, ChatAwayLine, ChatBroadcastSheet, ChatComposer, ChatEmojiPicker, ChatEmojiPickerSheet, ChatIconButton, ChatInboxScreen, ChatLinkPreviewCard, ChatMediaViewer, ChatNativeProvider, ChatPhotoViewer, ChatScheduleSheet, ChatScheduledBar, ChatScheduledList, ChatSearchScreen, ChatStartButton, ChatStartSheet, ChatThreadScreen, ChatThreadTitle, ChatTopicBar, ChatTypingBubble, ChatVideoPlayer, ChatVideoRecorder, DISMISS_DISTANCE, DISMISS_VELOCITY, EMOJI_CATEGORIES, MAX_ZOOM, MessageActionsSheet, MessageAttachments, MessageBubble, ModerationMarker, QUICK_REACTIONS, RECENT_EMOJI_MAX, SearchSnippet, TIME_REVEAL_WIDTH, TRANSCRIPT_LINES, TUS_CHUNK_BYTES, VIDEO_CHUNK_BYTES, VIDEO_HOLD_MS, VIDEO_MIN_MS, VideoUploadTray, VoiceNotePlayer, VoiceTranscript, activePlaybackId, attachmentKindOf, attachmentPaths, availabilityInput, awayLineFor, barsThatFit, base64ToBytes, base64Utf8, broadcastOutcome, broadcastRows, bubbleCorners, bubblePosition, buildThreadRows, canManageTopics, canReactTo, canSend, cardAction, chatNativeCopy, chatOrganiseCopy, chatThreadStackOptions, checkTopicName, chunkedPut, claimPlayback, clearDrafts, clockToDate, composerDisabledReason, composerReducer, connectionState, countUnseenBelow, createDraftSaver, createTusUpload, createVideoUploads, cycleVideoRate, cycleVoiceNoteRate, dateToClock, defaultScheduleAt, defaultWeek, deviceTimeZone, displayBody, draftKey, emojiEntry, emojiInCategory, emptyComposer, fileFromDataUri, fileSource, filesFromAssets, fill, forgetRecentEmoji, formFrom, formatClock, fullScreenVideo, galleryFor, haptic, hoursFromWeek, idleRecorder, inboxRow, initialVideoRecorder, initials, insertAtSelection, invertedRows, isLocalUri, isOnline, isOpenableHref, isVideoPlaying, lastSentReceipt, linkHost, linkPreviewIds, liveBars, loadDraft, loadRecentEmoji, memoryDraftStorage, messageActionsFor, moderationNote, moderationText, muxPosterUrl, muxStreamUrl, nearBottom, nextOffset, openChatLink, panLimit, pauseChatPlayback, pinchScale, previewToShow, pushRecentEmoji, readWhen, receiptText, recentEmojiKey, recordedVideoFile, recorderStep, recordingType, releasePlayback, replyTargetFor, resolveChatCopy, rowIndexOf, rowKey, sameTimeDays, saveRecentEmoji, scheduleInputFrom, scrubSeconds, searchEmoji, shouldDismiss, slotUrl, snippetText, splitCardAttachments, startsTimeReveal, threadListMode, timeRevealFor, timeZones, toSend, toggleVideo, toggleVideoMute, toggleVoiceNote, topicClosedFor, topicMenuFor, transcriptIsLong, useAwayLine, useCardRuns, useChatAutoRetry, useChatComposer, useChatNative, useChatThreadStackOptions, useJumpToMessage, useOnline, usePlayingVideo, usePlayingVoiceNote, useScheduleSend, useVideoUploads, useVoiceRecorder, videoRecorderStep, videoSource, videoState, videoUploads, voiceNoteFile, waveformBars, weekFromHours, withDay, withTime };
|
|
4944
5420
|
//# sourceMappingURL=native.js.map
|
|
4945
5421
|
//# sourceMappingURL=native.js.map
|