@marktiderman/genesis-chat 0.11.4 → 0.13.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 +162 -4
- package/dist/{chunk-ZQFREERR.js → chunk-3UNYTK62.js} +3 -3
- package/dist/{chunk-ZQFREERR.js.map → chunk-3UNYTK62.js.map} +1 -1
- package/dist/{chunk-5XYDVUPS.js → chunk-GEEJMKQF.js} +29 -4
- package/dist/chunk-GEEJMKQF.js.map +1 -0
- package/dist/{chunk-D4RPOYB7.js → chunk-H4BRVJJ7.js} +193 -30
- package/dist/chunk-H4BRVJJ7.js.map +1 -0
- package/dist/{chunk-O2QSBRSH.js → chunk-SEMN3S6Q.js} +3 -3
- package/dist/{chunk-O2QSBRSH.js.map → chunk-SEMN3S6Q.js.map} +1 -1
- package/dist/{client-DP7rhJ1U.d.ts → client-DXWyDJ2u.d.ts} +29 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/dist/native.d.ts +355 -145
- package/dist/native.js +701 -217
- package/dist/native.js.map +1 -1
- package/dist/{outbox-C4LnqpKT.d.ts → outbox-Ctngv6Yz.d.ts} +1 -1
- package/dist/push.d.ts +2 -2
- package/dist/react.d.ts +83 -6
- 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-mZsRiIGz.d.ts} +1 -1
- package/dist/web.d.ts +24 -7
- package/dist/web.js +140 -67
- package/dist/web.js.map +1 -1
- package/migrations/0006_genesis_chat_read_receipts.sql +110 -0
- package/migrations/0007_genesis_chat_unread_and_delete_for_me.sql +455 -0
- package/migrations/tests/0006_genesis_chat_read_receipts.test.sql +131 -0
- package/migrations/tests/0007_genesis_chat_unread_and_delete_for_me.test.sql +178 -0
- package/package.json +17 -9
- package/src/__tests__/inbox-row-actions.test.tsx +251 -0
- package/src/__tests__/unread-delete-for-me.test.ts +84 -0
- package/src/__tests__/web.test.tsx +5 -2
- package/src/core/client.ts +30 -1
- 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__/inbox-screen-actions.test.tsx +131 -0
- package/src/native/__tests__/inbox-screen.test.tsx +29 -1
- 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-layout.test.ts +2 -2
- 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 +47 -10
- package/src/native/emoji-picker.tsx +1 -1
- package/src/native/inbox-screen.tsx +52 -27
- package/src/native/index.ts +7 -2
- 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/inbox-actions.ts +121 -0
- package/src/react/index.tsx +172 -23
- package/src/web/inbox.tsx +120 -11
- package/src/web/index.ts +1 -1
- package/src/web/memory-client.ts +40 -7
- package/dist/chunk-5XYDVUPS.js.map +0 -1
- package/dist/chunk-D4RPOYB7.js.map +0 -1
package/dist/native.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
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-SEMN3S6Q.js';
|
|
2
|
+
export { attachmentPreview, cardTitle, messagePreview } from './chunk-SEMN3S6Q.js';
|
|
3
3
|
import { isHttpsUrl, extractLinks, scheduleLabel, scheduleQuickPicks, isSchedulable, topicKey, snippetParts } from './chunk-BJCE5O7V.js';
|
|
4
|
-
import { useChat, useInbox, usePeople,
|
|
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 { defaultInboxActionLabels, useChat, useInboxActions, useInbox, usePeople, inboxRowActions, useScheduled, useAvailability, useTopics, useConversation, usePins, useMessageActions, useFileUrls, useLinkPreviews, chatKeys, useStartConversation, useBroadcast, useSearch } from './chunk-H4BRVJJ7.js';
|
|
5
|
+
import { summarizeReactions, parseMentions, startsDay, dayLabel, itemTime, itemSender, startsGroup, sameDay, activityLine } from './chunk-3UNYTK62.js';
|
|
6
|
+
import { formatDuration, nextPlaybackRate, ChatError, CHAT_LIMITS, fileExtension, isAllowedExtension, attachmentKindFor, awaySummary, WEEKDAYS, minutesOf, waveformFromMetering, recordingLimitMs, CHAT_BUCKET, randomId } from './chunk-GEEJMKQF.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 {
|
|
8
|
+
import { createContext, memo, useMemo, useState, useCallback, useRef, useContext, useSyncExternalStore, useLayoutEffect, useEffect, useReducer, createElement, isValidElement } from 'react';
|
|
9
|
+
import { Pressable, Animated, PanResponder, View, Linking, useWindowDimensions, ActivityIndicator, AppState, Alert, Modal, AccessibilityInfo, ScrollView, FlatList, Platform, KeyboardAvoidingView } from 'react-native';
|
|
10
|
+
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
11
|
import { InboxPage, SettingsSubPage, getThreadPageStackOptions, formatInboxTime } from '@marktiderman/genesis-ui-native/layouts';
|
|
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';
|
|
16
15
|
import { useSafeAreaInsets, SafeAreaView } from 'react-native-safe-area-context';
|
|
16
|
+
import { useQuery } from '@tanstack/react-query';
|
|
17
17
|
|
|
18
18
|
// src/native/organise-copy.ts
|
|
19
19
|
var chatOrganiseCopy = {
|
|
@@ -122,12 +122,16 @@ var chatNativeCopy = {
|
|
|
122
122
|
someone: "Someone",
|
|
123
123
|
youPrefix: "You: ",
|
|
124
124
|
mentionedYou: "Mentioned you",
|
|
125
|
-
|
|
126
|
-
pin: "Pin",
|
|
127
|
-
unpin: "Unpin",
|
|
128
|
-
archive: "Archive",
|
|
125
|
+
...defaultInboxActionLabels,
|
|
129
126
|
threadEmptyTitle: "No messages yet",
|
|
130
127
|
threadEmptyBody: "Say hello below.",
|
|
128
|
+
threadErrorTitle: "Couldn't load messages",
|
|
129
|
+
threadErrorBody: "Check your connection, then try again.",
|
|
130
|
+
waitingForNetwork: "Waiting for network\u2026",
|
|
131
|
+
connecting: "Connecting\u2026",
|
|
132
|
+
newMessagesPillOne: "1 new message",
|
|
133
|
+
newMessagesPill: "{count} new messages",
|
|
134
|
+
newMessagesPillHint: "Goes to the newest message",
|
|
131
135
|
loadEarlier: "Load earlier messages",
|
|
132
136
|
newMessages: "New messages",
|
|
133
137
|
placeholder: "Message",
|
|
@@ -213,6 +217,15 @@ var chatNativeCopy = {
|
|
|
213
217
|
viewerHint: "Swipe up or down for the next or previous photo.",
|
|
214
218
|
sending: "Sending",
|
|
215
219
|
notSent: "Not sent",
|
|
220
|
+
receiptSending: "Sending\u2026",
|
|
221
|
+
receiptSent: "Sent",
|
|
222
|
+
receiptDelivered: "Delivered",
|
|
223
|
+
receiptRead: "Read",
|
|
224
|
+
receiptReadAt: "Read {time}",
|
|
225
|
+
receiptReadBy: "Read by {count}",
|
|
226
|
+
receiptReadByEveryone: "Read by everyone",
|
|
227
|
+
receiptReadersHint: "Shows who has read it",
|
|
228
|
+
receiptReadersTitle: "Read by",
|
|
216
229
|
retry: "Retry",
|
|
217
230
|
attachAgain: "Attach again",
|
|
218
231
|
discard: "Delete",
|
|
@@ -1058,6 +1071,7 @@ function fromServer(a, urls) {
|
|
|
1058
1071
|
key: a.id,
|
|
1059
1072
|
kind: a.kind,
|
|
1060
1073
|
uri: (a.path ? urls[a.path] : null) ?? a.url ?? null,
|
|
1074
|
+
cacheKey: a.path && a.provider === "storage" ? a.path : null,
|
|
1061
1075
|
name: a.name,
|
|
1062
1076
|
width: a.width,
|
|
1063
1077
|
height: a.height,
|
|
@@ -1135,7 +1149,7 @@ function MessageAttachments({ attachments, mine, onOpenImage, testID }) {
|
|
|
1135
1149
|
disabled: !a.uri || !onOpenImage,
|
|
1136
1150
|
onPress: () => a.uri && onOpenImage?.(a.uri, alt),
|
|
1137
1151
|
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 } })
|
|
1152
|
+
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
1153
|
},
|
|
1140
1154
|
a.key
|
|
1141
1155
|
);
|
|
@@ -1242,8 +1256,84 @@ function ModerationMarker({ note, mine, testID }) {
|
|
|
1242
1256
|
/* @__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
1257
|
] });
|
|
1244
1258
|
}
|
|
1259
|
+
var TIME_REVEAL_WIDTH = 64;
|
|
1260
|
+
function startsTimeReveal(dx, dy) {
|
|
1261
|
+
return dx < -12 && Math.abs(dx) > Math.abs(dy) * 2;
|
|
1262
|
+
}
|
|
1263
|
+
function timeRevealFor(dx) {
|
|
1264
|
+
return Math.max(0, Math.min(TIME_REVEAL_WIDTH, -dx));
|
|
1265
|
+
}
|
|
1266
|
+
var TimesContext = createContext(null);
|
|
1267
|
+
function useTimeReveal(reducedMotion) {
|
|
1268
|
+
const value = useRef(new Animated.Value(0)).current;
|
|
1269
|
+
const reduced = useRef(reducedMotion);
|
|
1270
|
+
reduced.current = reducedMotion;
|
|
1271
|
+
const responder = useMemo(() => {
|
|
1272
|
+
const back = () => {
|
|
1273
|
+
if (reduced.current) value.setValue(0);
|
|
1274
|
+
else Animated.spring(value, { toValue: 0, useNativeDriver: true, bounciness: 0, speed: 16 }).start();
|
|
1275
|
+
};
|
|
1276
|
+
return PanResponder.create({
|
|
1277
|
+
onMoveShouldSetPanResponder: (_e, g) => startsTimeReveal(g.dx, g.dy),
|
|
1278
|
+
onPanResponderMove: (_e, g) => value.setValue(timeRevealFor(g.dx)),
|
|
1279
|
+
onPanResponderRelease: back,
|
|
1280
|
+
onPanResponderTerminate: back
|
|
1281
|
+
});
|
|
1282
|
+
}, [value]);
|
|
1283
|
+
return { value, panHandlers: responder.panHandlers };
|
|
1284
|
+
}
|
|
1285
|
+
function ChatTimesProvider({ value, children }) {
|
|
1286
|
+
return /* @__PURE__ */ jsx(TimesContext.Provider, { value, children });
|
|
1287
|
+
}
|
|
1288
|
+
function TimeRevealRow({ time, testID, children }) {
|
|
1289
|
+
const reveal = useContext(TimesContext);
|
|
1290
|
+
const colors = useThemeRoles();
|
|
1291
|
+
const styles = useMemo(
|
|
1292
|
+
() => reveal ? {
|
|
1293
|
+
row: { transform: [{ translateX: reveal.interpolate({ inputRange: [0, TIME_REVEAL_WIDTH], outputRange: [0, -TIME_REVEAL_WIDTH], extrapolate: "clamp" }) }] },
|
|
1294
|
+
time: { opacity: reveal.interpolate({ inputRange: [0, TIME_REVEAL_WIDTH], outputRange: [0, 1], extrapolate: "clamp" }) }
|
|
1295
|
+
} : null,
|
|
1296
|
+
[reveal]
|
|
1297
|
+
);
|
|
1298
|
+
if (!styles) return /* @__PURE__ */ jsx(View, { children });
|
|
1299
|
+
return /* @__PURE__ */ jsxs(Animated.View, { style: styles.row, children: [
|
|
1300
|
+
children,
|
|
1301
|
+
/* @__PURE__ */ jsx(
|
|
1302
|
+
Animated.View,
|
|
1303
|
+
{
|
|
1304
|
+
testID: `${testID}-time-reveal`,
|
|
1305
|
+
pointerEvents: "none",
|
|
1306
|
+
accessibilityElementsHidden: true,
|
|
1307
|
+
importantForAccessibility: "no-hide-descendants",
|
|
1308
|
+
style: [{ position: "absolute", top: 0, bottom: 0, right: -TIME_REVEAL_WIDTH, width: TIME_REVEAL_WIDTH, alignItems: "center", justifyContent: "center" }, styles.time],
|
|
1309
|
+
children: /* @__PURE__ */ jsx(NativeText, { preset: "caption", numberOfLines: 1, adjustsFontSizeToFit: true, minimumFontScale: 0.6, style: { color: colors.tertiaryLabel }, children: time })
|
|
1310
|
+
}
|
|
1311
|
+
)
|
|
1312
|
+
] });
|
|
1313
|
+
}
|
|
1245
1314
|
var SWIPE_REPLY = 56;
|
|
1246
1315
|
var SWIPE_MAX = 80;
|
|
1316
|
+
function bubblePosition(row) {
|
|
1317
|
+
if (row.groupStart && row.groupEnd) return "single";
|
|
1318
|
+
if (row.groupStart) return "first";
|
|
1319
|
+
if (row.groupEnd) return "last";
|
|
1320
|
+
return "middle";
|
|
1321
|
+
}
|
|
1322
|
+
var ROUND = 18;
|
|
1323
|
+
var TIGHT = 5;
|
|
1324
|
+
function bubbleCorners(position, mine) {
|
|
1325
|
+
const joinsAbove = position === "middle" || position === "last";
|
|
1326
|
+
const joinsBelow = position === "first" || position === "middle";
|
|
1327
|
+
const near = { top: joinsAbove ? TIGHT : ROUND, bottom: joinsBelow ? TIGHT : ROUND };
|
|
1328
|
+
return {
|
|
1329
|
+
borderTopLeftRadius: mine ? ROUND : near.top,
|
|
1330
|
+
borderBottomLeftRadius: mine ? ROUND : near.bottom,
|
|
1331
|
+
borderTopRightRadius: mine ? near.top : ROUND,
|
|
1332
|
+
borderBottomRightRadius: mine ? near.bottom : ROUND,
|
|
1333
|
+
tail: position === "last" || position === "single"
|
|
1334
|
+
};
|
|
1335
|
+
}
|
|
1336
|
+
var FRESH_MS = 1500;
|
|
1247
1337
|
function formatClock(iso) {
|
|
1248
1338
|
return new Date(iso).toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
|
|
1249
1339
|
}
|
|
@@ -1300,6 +1390,16 @@ function MessageBubbleImpl(props) {
|
|
|
1300
1390
|
return c ? { label: c.label, run: () => void runs.run(a.id, c.run) } : null;
|
|
1301
1391
|
}) : [];
|
|
1302
1392
|
const playingVoice = usePlayingVoiceNote(voices.map((a) => a.key));
|
|
1393
|
+
const genesis = useGenesisModules();
|
|
1394
|
+
const Swipeable = genesis.swipeable;
|
|
1395
|
+
const reanimated = genesis.reanimated;
|
|
1396
|
+
const [entering] = useState(() => {
|
|
1397
|
+
const rise = reanimated?.FadeInDown;
|
|
1398
|
+
if (!pending || reducedMotion || !rise || Date.now() - new Date(pending.createdAt).getTime() >= FRESH_MS) return void 0;
|
|
1399
|
+
const timed = rise.duration(240);
|
|
1400
|
+
return reanimated.ReduceMotion && timed.reduceMotion ? timed.reduceMotion(reanimated.ReduceMotion.System) : timed;
|
|
1401
|
+
});
|
|
1402
|
+
const swipeRef = useRef(null);
|
|
1303
1403
|
const x = useRef(new Animated.Value(0)).current;
|
|
1304
1404
|
const latest = useRef(props);
|
|
1305
1405
|
latest.current = props;
|
|
@@ -1332,10 +1432,14 @@ function MessageBubbleImpl(props) {
|
|
|
1332
1432
|
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
1433
|
}
|
|
1334
1434
|
const canSwipe = Boolean(message && !message.deletedAt && props.onReply);
|
|
1435
|
+
const corners = bubbleCorners(bubblePosition(row), mine);
|
|
1436
|
+
const tail = corners.tail && !props.highlighted;
|
|
1437
|
+
const Root = reanimated ? reanimated.default.View : View;
|
|
1335
1438
|
const reactions = message ? summarizeReactions(message, me) : [];
|
|
1336
1439
|
const time = formatClock(createdAt);
|
|
1337
1440
|
const moderation = moderationNote(message, { mine, observer: Boolean(props.observer) });
|
|
1338
|
-
const
|
|
1441
|
+
const receipt = failed ? null : props.receipt ?? null;
|
|
1442
|
+
const statusText = failed ? copy.notSent : receipt ? receipt : sending ? copy.sending : null;
|
|
1339
1443
|
const label = [
|
|
1340
1444
|
senderName,
|
|
1341
1445
|
message?.deletedAt ? copy.deleted : displayBody(body),
|
|
@@ -1400,80 +1504,106 @@ function MessageBubbleImpl(props) {
|
|
|
1400
1504
|
const bubbleColor = mine ? sentBubbleColor(colors) : colors.surface;
|
|
1401
1505
|
const fg = mine ? "text-primary-foreground" : void 0;
|
|
1402
1506
|
const textStyle = mine ? { fontSize: 17, lineHeight: 22 } : { fontSize: 17, lineHeight: 22, color: colors.label };
|
|
1507
|
+
const bubbleRow = /* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "flex-end", justifyContent: mine ? "flex-end" : "flex-start" }, children: [
|
|
1508
|
+
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,
|
|
1509
|
+
/* @__PURE__ */ jsxs(
|
|
1510
|
+
Animated.View,
|
|
1511
|
+
{
|
|
1512
|
+
style: { maxWidth: "80%", transform: [{ translateX: x }] },
|
|
1513
|
+
...canSwipe && !Swipeable ? responder.panHandlers : {},
|
|
1514
|
+
children: [
|
|
1515
|
+
/* @__PURE__ */ jsxs(
|
|
1516
|
+
Pressable,
|
|
1517
|
+
{
|
|
1518
|
+
testID: `${testID}-bubble`,
|
|
1519
|
+
accessible: true,
|
|
1520
|
+
accessibilityLabel: label,
|
|
1521
|
+
accessibilityHint: failed ? copy.retry : void 0,
|
|
1522
|
+
accessibilityActions: actions,
|
|
1523
|
+
onAccessibilityAction: (e) => onAction(e.nativeEvent.actionName),
|
|
1524
|
+
onLongPress: message && !message.deletedAt ? () => props.onLongPress?.(message) : void 0,
|
|
1525
|
+
delayLongPress: 350,
|
|
1526
|
+
style: {
|
|
1527
|
+
paddingHorizontal: attachments.length && !body ? 4 : 12,
|
|
1528
|
+
paddingVertical: attachments.length && !body ? 4 : 8,
|
|
1529
|
+
borderTopLeftRadius: corners.borderTopLeftRadius,
|
|
1530
|
+
borderTopRightRadius: corners.borderTopRightRadius,
|
|
1531
|
+
borderBottomLeftRadius: corners.borderBottomLeftRadius,
|
|
1532
|
+
borderBottomRightRadius: corners.borderBottomRightRadius,
|
|
1533
|
+
backgroundColor: bubbleColor,
|
|
1534
|
+
opacity: sending ? 0.6 : moderation === "hidden-mine" ? 0.7 : 1,
|
|
1535
|
+
gap: 4
|
|
1536
|
+
},
|
|
1537
|
+
children: [
|
|
1538
|
+
quote ? /* @__PURE__ */ jsxs(
|
|
1539
|
+
View,
|
|
1540
|
+
{
|
|
1541
|
+
testID: `${testID}-quote`,
|
|
1542
|
+
style: { borderLeftWidth: 3, borderLeftColor: mine ? colors.surface : colors.tint, paddingLeft: 8, paddingVertical: 2, opacity: 0.85 },
|
|
1543
|
+
children: [
|
|
1544
|
+
/* @__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 ?? "" : "" }),
|
|
1545
|
+
/* @__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" })
|
|
1546
|
+
]
|
|
1547
|
+
}
|
|
1548
|
+
) : null,
|
|
1549
|
+
attachments.length ? /* @__PURE__ */ jsx(MessageAttachments, { attachments, mine, onOpenImage: props.onOpenImage, testID }) : null,
|
|
1550
|
+
message && cards.length ? cards.map((a, i) => /* @__PURE__ */ jsx(
|
|
1551
|
+
AppAttachment,
|
|
1552
|
+
{
|
|
1553
|
+
attachment: a,
|
|
1554
|
+
message,
|
|
1555
|
+
kind: attachmentKindOf(kinds, a.kind),
|
|
1556
|
+
url: (a.path ? urls[a.path] : null) ?? a.url ?? null,
|
|
1557
|
+
mine,
|
|
1558
|
+
slot,
|
|
1559
|
+
onOpenAttachment: props.onOpenAttachment,
|
|
1560
|
+
onEmpty,
|
|
1561
|
+
run: (task) => void runs.run(a.id, task),
|
|
1562
|
+
state: runs.stateOf(a.id),
|
|
1563
|
+
testID: `${testID}-card-${i}`
|
|
1564
|
+
},
|
|
1565
|
+
a.id
|
|
1566
|
+
)) : null,
|
|
1567
|
+
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,
|
|
1568
|
+
moderation ? /* @__PURE__ */ jsx(ModerationMarker, { note: moderation, mine, testID: `${testID}-moderation` }) : null,
|
|
1569
|
+
preview ? /* @__PURE__ */ jsx(ChatLinkPreviewCard, { preview, mine, images: props.linkPreviewImages, testID: `${testID}-preview` }) : null
|
|
1570
|
+
]
|
|
1571
|
+
}
|
|
1572
|
+
),
|
|
1573
|
+
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
|
|
1574
|
+
]
|
|
1575
|
+
}
|
|
1576
|
+
)
|
|
1577
|
+
] });
|
|
1578
|
+
const swipeable = canSwipe && Swipeable && message ? /* @__PURE__ */ jsx(
|
|
1579
|
+
Swipeable,
|
|
1580
|
+
{
|
|
1581
|
+
ref: swipeRef,
|
|
1582
|
+
testID: `${testID}-swipe`,
|
|
1583
|
+
friction: 2,
|
|
1584
|
+
leftThreshold: SWIPE_REPLY,
|
|
1585
|
+
overshootLeft: false,
|
|
1586
|
+
dragOffsetFromRightEdge: 1e4,
|
|
1587
|
+
renderLeftActions: () => /* @__PURE__ */ jsx(ReplyHint, { color: colors.secondaryLabel }),
|
|
1588
|
+
onSwipeableWillOpen: () => {
|
|
1589
|
+
props.onSwipeReply?.();
|
|
1590
|
+
props.onReply?.(message);
|
|
1591
|
+
swipeRef.current?.close?.();
|
|
1592
|
+
},
|
|
1593
|
+
children: bubbleRow
|
|
1594
|
+
}
|
|
1595
|
+
) : bubbleRow;
|
|
1403
1596
|
return /* @__PURE__ */ jsxs(
|
|
1404
|
-
|
|
1597
|
+
Root,
|
|
1405
1598
|
{
|
|
1406
1599
|
testID,
|
|
1600
|
+
entering,
|
|
1407
1601
|
accessibilityElementsHidden: invisible || void 0,
|
|
1408
1602
|
importantForAccessibility: invisible ? "no-hide-descendants" : void 0,
|
|
1409
1603
|
style: { paddingTop: row.groupStart ? 8 : 2, borderRadius: 12, backgroundColor: props.highlighted ? colors.fill : void 0, display: invisible ? "none" : void 0 },
|
|
1410
1604
|
children: [
|
|
1411
1605
|
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
|
-
] }),
|
|
1606
|
+
/* @__PURE__ */ jsx(TimeRevealRow, { time, testID, children: swipeable }),
|
|
1477
1607
|
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
1608
|
Pressable,
|
|
1479
1609
|
{
|
|
@@ -1506,11 +1636,42 @@ function MessageBubbleImpl(props) {
|
|
|
1506
1636
|
/* @__PURE__ */ jsx(NativeText, { testID: `${testID}-failed`, preset: "caption", style: { color: colors.destructive }, children: pending?.error ?? copy.notSent }),
|
|
1507
1637
|
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
1638
|
/* @__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
|
|
1639
|
+
] }) : /* @__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,
|
|
1640
|
+
receipt ? /* @__PURE__ */ jsx(ReceiptLine, { text: receipt, onPress: props.onReceiptPress, hint: copy.receiptReadersHint, testID: `${testID}-receipt` }) : null
|
|
1510
1641
|
]
|
|
1511
1642
|
}
|
|
1512
1643
|
);
|
|
1513
1644
|
}
|
|
1645
|
+
function BubbleTail({ mine, color, backdrop, opacity, testID }) {
|
|
1646
|
+
const side = mine ? "right" : "left";
|
|
1647
|
+
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: [
|
|
1648
|
+
/* @__PURE__ */ jsx(View, { style: { position: "absolute", bottom: 0, [side]: 0, width: 20, height: 18, opacity, backgroundColor: color, [mine ? "borderBottomLeftRadius" : "borderBottomRightRadius"]: 16 } }),
|
|
1649
|
+
/* @__PURE__ */ jsx(View, { style: { position: "absolute", bottom: 0, [side]: -6, width: 12, height: 20, backgroundColor: backdrop, [mine ? "borderBottomLeftRadius" : "borderBottomRightRadius"]: 10 } })
|
|
1650
|
+
] });
|
|
1651
|
+
}
|
|
1652
|
+
function ReplyHint({ color }) {
|
|
1653
|
+
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 }) });
|
|
1654
|
+
}
|
|
1655
|
+
function ReceiptLine({ text, onPress, hint, testID }) {
|
|
1656
|
+
const colors = useThemeRoles();
|
|
1657
|
+
const words = /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: colors.secondaryLabel, fontWeight: "600" }, children: text });
|
|
1658
|
+
if (!onPress) {
|
|
1659
|
+
return /* @__PURE__ */ jsx(View, { testID, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { alignItems: "flex-end", marginTop: 1, marginRight: 12 }, children: words });
|
|
1660
|
+
}
|
|
1661
|
+
return /* @__PURE__ */ jsx(
|
|
1662
|
+
Pressable,
|
|
1663
|
+
{
|
|
1664
|
+
testID,
|
|
1665
|
+
accessibilityRole: "button",
|
|
1666
|
+
accessibilityLabel: text,
|
|
1667
|
+
accessibilityHint: hint,
|
|
1668
|
+
onPress,
|
|
1669
|
+
hitSlop: 8,
|
|
1670
|
+
style: { alignSelf: "flex-end", minHeight: 28, justifyContent: "center", marginRight: 12 },
|
|
1671
|
+
children: words
|
|
1672
|
+
}
|
|
1673
|
+
);
|
|
1674
|
+
}
|
|
1514
1675
|
function SmallAction({ label, onPress, color, testID }) {
|
|
1515
1676
|
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
1677
|
}
|
|
@@ -1529,12 +1690,22 @@ function inboxRow(item, ctx) {
|
|
|
1529
1690
|
unread: item.unread > 0,
|
|
1530
1691
|
unreadCount: item.unread,
|
|
1531
1692
|
meta: item.mentioned ? ctx.copy.mentionedYou : void 0,
|
|
1693
|
+
muted: item.muted,
|
|
1694
|
+
pinned: item.pinned,
|
|
1532
1695
|
avatar: /* @__PURE__ */ jsx(NativeAvatar, { size: 40, src: other?.avatarUrl ?? null, fallback: initials(title), alt: title, recyclingKey: item.conversationId })
|
|
1533
1696
|
};
|
|
1534
1697
|
}
|
|
1535
|
-
function
|
|
1536
|
-
|
|
1537
|
-
|
|
1698
|
+
function alertConfirm(cancelLabel) {
|
|
1699
|
+
return (title, body, confirmLabel) => new Promise(
|
|
1700
|
+
(resolve) => Alert.alert(title, body, [
|
|
1701
|
+
{ text: cancelLabel, style: "cancel", onPress: () => resolve(false) },
|
|
1702
|
+
{ text: confirmLabel, style: "destructive", onPress: () => resolve(true) }
|
|
1703
|
+
], { cancelable: true, onDismiss: () => resolve(false) })
|
|
1704
|
+
);
|
|
1705
|
+
}
|
|
1706
|
+
function ChatInboxScreen({ onOpen, onStart, kind, kinds, excludeKinds, archived, rowActions, pageProps, testID = "chat-inbox" }) {
|
|
1707
|
+
const { userId, attachmentKinds } = useChat();
|
|
1708
|
+
const act = useInboxActions();
|
|
1538
1709
|
const { copy, person: known } = useChatNative();
|
|
1539
1710
|
const inbox = useInbox({ kind, kinds, excludeKinds, archived });
|
|
1540
1711
|
const others = useMemo(() => inbox.items.map((i) => i.otherUserId), [inbox.items]);
|
|
@@ -1549,23 +1720,21 @@ function ChatInboxScreen({ onOpen, onStart, kind, kinds, excludeKinds, archived,
|
|
|
1549
1720
|
setRefreshing(false);
|
|
1550
1721
|
}
|
|
1551
1722
|
}, [inbox]);
|
|
1552
|
-
const
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
]
|
|
1568
|
-
}));
|
|
1723
|
+
const options = useMemo(
|
|
1724
|
+
() => ({
|
|
1725
|
+
confirm: alertConfirm(copy.cancel),
|
|
1726
|
+
onError: (e) => Alert.alert(copy.actionFailed, e instanceof Error ? e.message : void 0)
|
|
1727
|
+
}),
|
|
1728
|
+
[copy]
|
|
1729
|
+
);
|
|
1730
|
+
const items = inbox.items.map((item) => {
|
|
1731
|
+
const defaults = inboxRowActions(item, act, copy, options);
|
|
1732
|
+
return {
|
|
1733
|
+
...inboxRow(item, { me: userId, copy, person, kinds: attachmentKinds }),
|
|
1734
|
+
onPress: () => onOpen(item.conversationId),
|
|
1735
|
+
swipeActions: rowActions ? rowActions(item, defaults) : defaults
|
|
1736
|
+
};
|
|
1737
|
+
});
|
|
1569
1738
|
return /* @__PURE__ */ jsx(
|
|
1570
1739
|
InboxPage,
|
|
1571
1740
|
{
|
|
@@ -1578,6 +1747,9 @@ function ChatInboxScreen({ onOpen, onStart, kind, kinds, excludeKinds, archived,
|
|
|
1578
1747
|
onRefresh: refresh,
|
|
1579
1748
|
emptyTitle: copy.inboxEmptyTitle,
|
|
1580
1749
|
emptyBody: copy.inboxEmptyBody,
|
|
1750
|
+
swipeAppearance: "round",
|
|
1751
|
+
mutedLabel: copy.alertsOff,
|
|
1752
|
+
pinnedLabel: copy.pinnedMark,
|
|
1581
1753
|
emptyActionLabel: onStart ? copy.startConversation : void 0,
|
|
1582
1754
|
onEmptyAction: onStart,
|
|
1583
1755
|
...pageProps
|
|
@@ -1589,6 +1761,8 @@ var HAPTIC_KIND = {
|
|
|
1589
1761
|
"record-lock": "light",
|
|
1590
1762
|
"record-start": "medium",
|
|
1591
1763
|
select: "select",
|
|
1764
|
+
/** A bubble lifting for its menu: UIKit's context-menu tap. */
|
|
1765
|
+
"long-press": "medium",
|
|
1592
1766
|
error: "error",
|
|
1593
1767
|
"record-cancel": "warning"
|
|
1594
1768
|
};
|
|
@@ -2549,9 +2723,9 @@ function ChatScheduledBar({ conversationId, testID = "chat-scheduled-bar" }) {
|
|
|
2549
2723
|
]
|
|
2550
2724
|
}
|
|
2551
2725
|
),
|
|
2552
|
-
/* @__PURE__ */ jsx(NativeSheet, { open, onOpenChange: setOpen, testID: `${testID}-sheet`, children: /* @__PURE__ */ jsxs(View, { style: { paddingVertical: 8 }, children: [
|
|
2726
|
+
/* @__PURE__ */ jsx(NativeSheet, { open, onOpenChange: setOpen, fitContent: true, testID: `${testID}-sheet`, children: /* @__PURE__ */ jsxs(View, { style: { paddingVertical: 8, flexShrink: 1 }, children: [
|
|
2553
2727
|
/* @__PURE__ */ jsx(NativeText, { preset: "h4", accessibilityRole: "header", style: { paddingHorizontal: 16, paddingBottom: 4 }, children: copy.scheduledTitle }),
|
|
2554
|
-
/* @__PURE__ */ jsx(ChatScheduledList, { conversationId, testID: `${testID}-list` })
|
|
2728
|
+
/* @__PURE__ */ jsx(NativeSheetScrollView, { testID: `${testID}-scroll`, style: { flexShrink: 1 }, children: /* @__PURE__ */ jsx(ChatScheduledList, { conversationId, testID: `${testID}-list` }) })
|
|
2555
2729
|
] }) })
|
|
2556
2730
|
] });
|
|
2557
2731
|
}
|
|
@@ -3185,7 +3359,7 @@ var EmojiCell = memo(function EmojiCell2({ entry, width, onPress, testID }) {
|
|
|
3185
3359
|
function ChatEmojiPickerSheet({ open, onClose, onSelect, testID = "chat-emoji-sheet", ...rest }) {
|
|
3186
3360
|
const { copy } = useChatNative();
|
|
3187
3361
|
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: [
|
|
3362
|
+
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
3363
|
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "center", justifyContent: "space-between", minHeight: 44 }, children: [
|
|
3190
3364
|
/* @__PURE__ */ jsx(NativeText, { preset: "h4", accessibilityRole: "header", children: copy.emojiPicker }),
|
|
3191
3365
|
/* @__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 +3698,14 @@ function ComposerBody({ composer, canPost, onSend, signalTyping, onRecordVideo,
|
|
|
3524
3698
|
paste2 = false;
|
|
3525
3699
|
}
|
|
3526
3700
|
setCanPaste(paste2);
|
|
3527
|
-
if (!paste2 && !modules.imagePicker?.launchCameraAsync && modules.imagePicker) return pick("library"
|
|
3701
|
+
if (!paste2 && !modules.imagePicker?.launchCameraAsync && modules.imagePicker) return pick("library");
|
|
3528
3702
|
setAttachOpen(true);
|
|
3529
3703
|
};
|
|
3530
3704
|
const remaining = CHAT_LIMITS.attachmentsPerMessage - state.attachments.length;
|
|
3531
|
-
const
|
|
3532
|
-
const pick = async (from, fromSheet = true) => {
|
|
3705
|
+
const pick = async (from) => {
|
|
3533
3706
|
setAttachOpen(false);
|
|
3534
3707
|
const picker = modules.imagePicker;
|
|
3535
3708
|
if (!picker) return;
|
|
3536
|
-
if (fromSheet) await afterSheet();
|
|
3537
3709
|
try {
|
|
3538
3710
|
if (from === "camera") {
|
|
3539
3711
|
const permission = await picker.requestCameraPermissionsAsync?.();
|
|
@@ -3615,11 +3787,21 @@ function ComposerBody({ composer, canPost, onSend, signalTyping, onRecordVideo,
|
|
|
3615
3787
|
}
|
|
3616
3788
|
),
|
|
3617
3789
|
/* @__PURE__ */ jsx(ChatEmojiPickerSheet, { open: emojiOpen, onClose: () => setEmojiOpen(false), onSelect: insertEmoji, userId, testID: `${testID}-emoji-sheet` }),
|
|
3618
|
-
/* @__PURE__ */ jsx(
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3790
|
+
/* @__PURE__ */ jsx(
|
|
3791
|
+
NativeContextMenu,
|
|
3792
|
+
{
|
|
3793
|
+
open: attachOpen,
|
|
3794
|
+
onOpenChange: setAttachOpen,
|
|
3795
|
+
title: copy.attach,
|
|
3796
|
+
cancelLabel: copy.cancel,
|
|
3797
|
+
actions: [
|
|
3798
|
+
...modules.imagePicker ? [{ id: "library", label: copy.attachLibrary, onPress: () => void pick("library") }] : [],
|
|
3799
|
+
...modules.imagePicker?.launchCameraAsync ? [{ id: "camera", label: copy.attachCamera, onPress: () => void pick("camera") }] : [],
|
|
3800
|
+
...canPaste ? [{ id: "paste", label: copy.attachPaste, onPress: () => void paste() }] : []
|
|
3801
|
+
],
|
|
3802
|
+
testID: `${testID}-attach-sheet`
|
|
3803
|
+
}
|
|
3804
|
+
)
|
|
3623
3805
|
] });
|
|
3624
3806
|
}
|
|
3625
3807
|
function IconButton({
|
|
@@ -3644,15 +3826,32 @@ function IconButton({
|
|
|
3644
3826
|
}
|
|
3645
3827
|
);
|
|
3646
3828
|
}
|
|
3829
|
+
function micOffset(dx, dy) {
|
|
3830
|
+
return { x: Math.max(-120, Math.min(0, dx)), y: Math.max(-72, Math.min(0, dy)) };
|
|
3831
|
+
}
|
|
3647
3832
|
function MicButton({ voice, disabled, testID }) {
|
|
3648
3833
|
const { copy } = useChatNative();
|
|
3649
3834
|
const colors = useThemeRoles();
|
|
3835
|
+
const reducedMotion = useReducedMotion();
|
|
3836
|
+
const reduced = useRef(reducedMotion);
|
|
3837
|
+
reduced.current = reducedMotion;
|
|
3838
|
+
const followX = useRef(new Animated.Value(0)).current;
|
|
3839
|
+
const followY = useRef(new Animated.Value(0)).current;
|
|
3840
|
+
const home = useRef(() => {
|
|
3841
|
+
for (const v of [followX, followY]) {
|
|
3842
|
+
if (reduced.current) v.setValue(0);
|
|
3843
|
+
else Animated.spring(v, { toValue: 0, useNativeDriver: true, bounciness: 6 }).start();
|
|
3844
|
+
}
|
|
3845
|
+
}).current;
|
|
3650
3846
|
const { state, dispatch } = voice;
|
|
3651
3847
|
const latest = useRef(dispatch);
|
|
3652
3848
|
latest.current = dispatch;
|
|
3653
3849
|
const locked = state.phase === "recording" && state.locked;
|
|
3654
3850
|
const lockedNow = useRef(locked);
|
|
3655
3851
|
lockedNow.current = locked;
|
|
3852
|
+
useEffect(() => {
|
|
3853
|
+
if (locked || state.phase === "idle") home();
|
|
3854
|
+
}, [locked, state.phase, home]);
|
|
3656
3855
|
const lockWhenReady = useRef(false);
|
|
3657
3856
|
useEffect(() => {
|
|
3658
3857
|
if (state.phase === "recording" && lockWhenReady.current) {
|
|
@@ -3672,14 +3871,24 @@ function MicButton({ voice, disabled, testID }) {
|
|
|
3672
3871
|
if (!tapToSend) latest.current({ type: "press" });
|
|
3673
3872
|
},
|
|
3674
3873
|
onPanResponderMove: (_e, g) => {
|
|
3675
|
-
if (
|
|
3874
|
+
if (tapToSend) return;
|
|
3875
|
+
latest.current({ type: "move", dx: g.dx, dy: g.dy });
|
|
3876
|
+
if (!lockedNow.current) {
|
|
3877
|
+
const at = micOffset(g.dx, g.dy);
|
|
3878
|
+
followX.setValue(at.x);
|
|
3879
|
+
followY.setValue(at.y);
|
|
3880
|
+
}
|
|
3881
|
+
},
|
|
3882
|
+
onPanResponderRelease: () => {
|
|
3883
|
+
home();
|
|
3884
|
+
latest.current({ type: tapToSend ? "send" : "release" });
|
|
3676
3885
|
},
|
|
3677
|
-
onPanResponderRelease: () => latest.current({ type: tapToSend ? "send" : "release" }),
|
|
3678
3886
|
onPanResponderTerminate: () => {
|
|
3887
|
+
home();
|
|
3679
3888
|
if (!tapToSend) latest.current({ type: "cancel" });
|
|
3680
3889
|
}
|
|
3681
3890
|
});
|
|
3682
|
-
}, []);
|
|
3891
|
+
}, [followX, followY, home]);
|
|
3683
3892
|
const holding = !locked && (state.phase === "starting" || state.phase === "recording");
|
|
3684
3893
|
return /* @__PURE__ */ jsxs(View, { style: { alignItems: "center" }, children: [
|
|
3685
3894
|
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 +3914,14 @@ function MicButton({ voice, disabled, testID }) {
|
|
|
3705
3914
|
},
|
|
3706
3915
|
style: { width: 44, height: 44, alignItems: "center", justifyContent: "center", opacity: disabled ? 0.4 : 1, transform: [{ scale: holding ? 1.25 : 1 }] },
|
|
3707
3916
|
...disabled ? {} : responder.panHandlers,
|
|
3708
|
-
children: /* @__PURE__ */ jsx(
|
|
3917
|
+
children: /* @__PURE__ */ jsx(
|
|
3918
|
+
Animated.View,
|
|
3919
|
+
{
|
|
3920
|
+
testID: `${testID}-mic-follow`,
|
|
3921
|
+
style: { width: 34, height: 34, borderRadius: 17, alignItems: "center", justifyContent: "center", backgroundColor: locked ? colors.tint : holding ? colors.destructive : "transparent", transform: [{ translateX: followX }, { translateY: followY }] },
|
|
3922
|
+
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 })
|
|
3923
|
+
}
|
|
3924
|
+
)
|
|
3709
3925
|
}
|
|
3710
3926
|
)
|
|
3711
3927
|
] });
|
|
@@ -3722,6 +3938,138 @@ function RecordingBar({ voice, testID }) {
|
|
|
3722
3938
|
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
3939
|
] });
|
|
3724
3940
|
}
|
|
3941
|
+
|
|
3942
|
+
// src/native/rows.ts
|
|
3943
|
+
function rowKey(item) {
|
|
3944
|
+
return `c:${item.type === "message" ? item.message.clientId : item.pending.clientId}`;
|
|
3945
|
+
}
|
|
3946
|
+
function buildThreadRows(items, options) {
|
|
3947
|
+
const { me, firstUnreadId, group, now = /* @__PURE__ */ new Date(), locale } = options;
|
|
3948
|
+
const rows = [];
|
|
3949
|
+
for (let i = 0; i < items.length; i++) {
|
|
3950
|
+
const item = items[i];
|
|
3951
|
+
if (startsDay(items, i)) rows.push({ type: "day", key: `d:${rowKey(item)}`, label: dayLabel(itemTime(item), now, locale) });
|
|
3952
|
+
if (item.type === "message" && item.message.id === firstUnreadId) rows.push({ type: "unread", key: "unread" });
|
|
3953
|
+
const senderId = itemSender(item);
|
|
3954
|
+
const mine = item.type === "pending" || senderId === me;
|
|
3955
|
+
const system = item.type === "message" && item.message.kind === "system";
|
|
3956
|
+
const groupStart = startsGroup(items, i) || item.type === "message" && item.message.id === firstUnreadId;
|
|
3957
|
+
const nextItem = items[i + 1];
|
|
3958
|
+
const groupEnd = !nextItem || startsGroup(items, i + 1) || nextItem.type === "message" && nextItem.message.id === firstUnreadId;
|
|
3959
|
+
rows.push({
|
|
3960
|
+
type: "message",
|
|
3961
|
+
key: rowKey(item),
|
|
3962
|
+
item,
|
|
3963
|
+
mine,
|
|
3964
|
+
senderId,
|
|
3965
|
+
groupStart,
|
|
3966
|
+
groupEnd,
|
|
3967
|
+
showName: group && !mine && !system && groupStart,
|
|
3968
|
+
showAvatar: group && !mine && !system && groupEnd
|
|
3969
|
+
});
|
|
3970
|
+
}
|
|
3971
|
+
return rows;
|
|
3972
|
+
}
|
|
3973
|
+
function invertedRows(items, options) {
|
|
3974
|
+
return buildThreadRows(items, options).reverse();
|
|
3975
|
+
}
|
|
3976
|
+
|
|
3977
|
+
// src/native/receipts.ts
|
|
3978
|
+
function lastSentReceipt(items, options) {
|
|
3979
|
+
const { me, members, group, queued, receipts = "show" } = options;
|
|
3980
|
+
if (receipts === "hide") return null;
|
|
3981
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
3982
|
+
const item = items[i];
|
|
3983
|
+
if (item.type === "pending") {
|
|
3984
|
+
if (item.pending.senderId !== me) continue;
|
|
3985
|
+
if (item.pending.status === "failed") return null;
|
|
3986
|
+
const posted = Boolean(item.pending.sentMessageId);
|
|
3987
|
+
return { key: rowKey(item), receipt: { state: posted ? "sent" : "sending" } };
|
|
3988
|
+
}
|
|
3989
|
+
const m = item.message;
|
|
3990
|
+
if (m.senderId !== me || m.kind === "system" || m.deletedAt) continue;
|
|
3991
|
+
if (m.visibility === "observers" || m.moderation === "hidden") return null;
|
|
3992
|
+
return { key: rowKey(item), receipt: receiptFor(m.seq, m.clientId) };
|
|
3993
|
+
}
|
|
3994
|
+
return null;
|
|
3995
|
+
function receiptFor(seq2, clientId) {
|
|
3996
|
+
if (queued?.has(clientId)) return { state: "sent" };
|
|
3997
|
+
const others = members.filter((x) => x.userId !== me && x.role !== "observer");
|
|
3998
|
+
const readers = others.filter((x) => x.lastReadSeq >= seq2);
|
|
3999
|
+
if (!group) {
|
|
4000
|
+
const other = readers[0];
|
|
4001
|
+
return other ? { state: "read", at: other.lastReadAt ?? null } : { state: "delivered" };
|
|
4002
|
+
}
|
|
4003
|
+
if (readers.length === 0) return { state: "delivered" };
|
|
4004
|
+
return { state: "read-by", readers: readers.map((x) => x.userId), everyone: readers.length === others.length };
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
4007
|
+
function readWhen(at, now = /* @__PURE__ */ new Date(), locale) {
|
|
4008
|
+
return sameDay(at, now.toISOString()) ? new Date(at).toLocaleTimeString(locale, { hour: "numeric", minute: "2-digit" }) : dayLabel(at, now, locale);
|
|
4009
|
+
}
|
|
4010
|
+
function receiptText(receipt, copy, now = /* @__PURE__ */ new Date(), locale) {
|
|
4011
|
+
switch (receipt.state) {
|
|
4012
|
+
case "sending":
|
|
4013
|
+
return copy.receiptSending;
|
|
4014
|
+
case "sent":
|
|
4015
|
+
return copy.receiptSent;
|
|
4016
|
+
case "delivered":
|
|
4017
|
+
return copy.receiptDelivered;
|
|
4018
|
+
case "read":
|
|
4019
|
+
return receipt.at ? fill(copy.receiptReadAt, { time: readWhen(receipt.at, now, locale) }) : copy.receiptRead;
|
|
4020
|
+
case "read-by":
|
|
4021
|
+
return receipt.everyone ? copy.receiptReadByEveryone : fill(copy.receiptReadBy, { count: receipt.readers.length });
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
var DOT = 8;
|
|
4025
|
+
var ANNOUNCE_GAP_MS = 4e3;
|
|
4026
|
+
function ChatTypingBubble({ label, userId, group, reducedMotion, testID }) {
|
|
4027
|
+
const colors = useThemeRoles();
|
|
4028
|
+
const { person } = useChatNative();
|
|
4029
|
+
const typer = userId ? person(userId) : null;
|
|
4030
|
+
const dots = useRef([new Animated.Value(0.4), new Animated.Value(0.4), new Animated.Value(0.4)]).current;
|
|
4031
|
+
const lastSaid = useRef(null);
|
|
4032
|
+
useEffect(() => {
|
|
4033
|
+
if (Platform.OS !== "ios") return;
|
|
4034
|
+
const now = Date.now();
|
|
4035
|
+
const last = lastSaid.current;
|
|
4036
|
+
if (last && (last.label === label || now - last.at < ANNOUNCE_GAP_MS)) return;
|
|
4037
|
+
lastSaid.current = { label, at: now };
|
|
4038
|
+
AccessibilityInfo.announceForAccessibility?.(label);
|
|
4039
|
+
}, [label]);
|
|
4040
|
+
useEffect(() => {
|
|
4041
|
+
if (reducedMotion) {
|
|
4042
|
+
dots.forEach((d) => d.setValue(0.6));
|
|
4043
|
+
return;
|
|
4044
|
+
}
|
|
4045
|
+
const pulses = dots.map(
|
|
4046
|
+
(d, i) => Animated.loop(
|
|
4047
|
+
Animated.sequence([
|
|
4048
|
+
Animated.timing(d, { toValue: 0.4, duration: i * 160, useNativeDriver: true }),
|
|
4049
|
+
Animated.timing(d, { toValue: 1, duration: 300, useNativeDriver: true }),
|
|
4050
|
+
Animated.timing(d, { toValue: 0.4, duration: 300, useNativeDriver: true }),
|
|
4051
|
+
Animated.timing(d, { toValue: 0.4, duration: (dots.length - 1 - i) * 160, useNativeDriver: true })
|
|
4052
|
+
])
|
|
4053
|
+
)
|
|
4054
|
+
);
|
|
4055
|
+
pulses.forEach((p) => p.start());
|
|
4056
|
+
return () => pulses.forEach((p) => p.stop());
|
|
4057
|
+
}, [dots, reducedMotion]);
|
|
4058
|
+
return /* @__PURE__ */ jsxs(
|
|
4059
|
+
View,
|
|
4060
|
+
{
|
|
4061
|
+
testID,
|
|
4062
|
+
accessible: true,
|
|
4063
|
+
accessibilityLabel: label,
|
|
4064
|
+
accessibilityLiveRegion: "polite",
|
|
4065
|
+
style: { flexDirection: "row", alignItems: "flex-end", paddingTop: 8, paddingBottom: 6, paddingHorizontal: 8 },
|
|
4066
|
+
children: [
|
|
4067
|
+
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,
|
|
4068
|
+
/* @__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)) })
|
|
4069
|
+
]
|
|
4070
|
+
}
|
|
4071
|
+
);
|
|
4072
|
+
}
|
|
3725
4073
|
var memoryDrafts = memoryDraftStorage();
|
|
3726
4074
|
function useChatComposer(conversationId, threadRootId, userId) {
|
|
3727
4075
|
const { modules } = useChatNative();
|
|
@@ -3928,7 +4276,7 @@ function MessageActionsSheet({ message, context, onClose, onReact, onAction, att
|
|
|
3928
4276
|
onClose();
|
|
3929
4277
|
onAction(message, action);
|
|
3930
4278
|
};
|
|
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(
|
|
4279
|
+
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
4280
|
ChatEmojiPicker,
|
|
3933
4281
|
{
|
|
3934
4282
|
userId: context.me,
|
|
@@ -3987,42 +4335,59 @@ function MessageActionsSheet({ message, context, onClose, onReact, onAction, att
|
|
|
3987
4335
|
] })
|
|
3988
4336
|
) : null });
|
|
3989
4337
|
}
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
function rowKey(item) {
|
|
3993
|
-
return `c:${item.type === "message" ? item.message.clientId : item.pending.clientId}`;
|
|
4338
|
+
function isOnline(state) {
|
|
4339
|
+
return state.isConnected !== false && state.isInternetReachable !== false;
|
|
3994
4340
|
}
|
|
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
|
|
4341
|
+
function useChatAutoRetry({ netInfo, appState } = {}) {
|
|
4342
|
+
const { retryAll } = useChat();
|
|
4343
|
+
const { modules } = useChatNative();
|
|
4344
|
+
const net = netInfo ?? modules.netInfo;
|
|
4345
|
+
const app = appState ?? AppState;
|
|
4346
|
+
const retry = useRef(retryAll);
|
|
4347
|
+
retry.current = retryAll;
|
|
4348
|
+
useEffect(() => {
|
|
4349
|
+
const go = () => void retry.current().catch(() => void 0);
|
|
4350
|
+
let last = app?.currentState ?? null;
|
|
4351
|
+
const sub = app?.addEventListener?.("change", (next) => {
|
|
4352
|
+
if (next === "active" && last !== "active") go();
|
|
4353
|
+
last = next;
|
|
4018
4354
|
});
|
|
4019
|
-
|
|
4020
|
-
|
|
4355
|
+
let wasOnline = null;
|
|
4356
|
+
const unsubscribe = net?.addEventListener((state) => {
|
|
4357
|
+
const online = isOnline(state);
|
|
4358
|
+
if (online && wasOnline === false) go();
|
|
4359
|
+
wasOnline = online;
|
|
4360
|
+
});
|
|
4361
|
+
return () => {
|
|
4362
|
+
sub?.remove();
|
|
4363
|
+
unsubscribe?.();
|
|
4364
|
+
};
|
|
4365
|
+
}, [net, app]);
|
|
4021
4366
|
}
|
|
4022
|
-
function
|
|
4023
|
-
|
|
4367
|
+
function ChatAutoRetry(props) {
|
|
4368
|
+
useChatAutoRetry(props);
|
|
4369
|
+
return null;
|
|
4024
4370
|
}
|
|
4025
4371
|
var PREPARED_UPLOAD_MS = 20 * 6e4;
|
|
4372
|
+
function connectionState(online, live) {
|
|
4373
|
+
if (online === false) return "offline";
|
|
4374
|
+
if (live === false) return "connecting";
|
|
4375
|
+
return "online";
|
|
4376
|
+
}
|
|
4377
|
+
function useOnline(netInfo) {
|
|
4378
|
+
const [online, setOnline] = useState(null);
|
|
4379
|
+
useEffect(() => {
|
|
4380
|
+
if (!netInfo) return;
|
|
4381
|
+
return netInfo.addEventListener((state) => setOnline(isOnline(state)));
|
|
4382
|
+
}, [netInfo]);
|
|
4383
|
+
return online;
|
|
4384
|
+
}
|
|
4385
|
+
function countUnseenBelow(messages, afterSeq, me) {
|
|
4386
|
+
if (afterSeq === null) return 0;
|
|
4387
|
+
let n = 0;
|
|
4388
|
+
for (let i = messages.length - 1; i >= 0 && messages[i].seq > afterSeq; i--) if (messages[i].senderId !== me) n++;
|
|
4389
|
+
return n;
|
|
4390
|
+
}
|
|
4026
4391
|
var AT_BOTTOM_POINTS = 120;
|
|
4027
4392
|
function threadListMode(flash, reducedMotion) {
|
|
4028
4393
|
if (flash) {
|
|
@@ -4037,9 +4402,10 @@ function nearBottom(m, slack = AT_BOTTOM_POINTS) {
|
|
|
4037
4402
|
return m.contentOffset.y + m.layoutMeasurement.height >= m.contentSize.height - slack;
|
|
4038
4403
|
}
|
|
4039
4404
|
function ChatThreadScreen(props) {
|
|
4040
|
-
const { conversationId, threadRootId = null, keyboardVerticalOffset, onOpenAttachment, jumpTo, topic: topicProp, showTopics = false, scheduling = true, availability = true,
|
|
4405
|
+
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;
|
|
4406
|
+
const focused = (props.focused ?? true) && active2;
|
|
4041
4407
|
const chat = useChat();
|
|
4042
|
-
const { userId, videoUpload, attachmentKinds, outbox } = chat;
|
|
4408
|
+
const { userId, videoUpload, attachmentKinds, outbox, queue } = chat;
|
|
4043
4409
|
const attachmentSlot = props.slots?.attachment;
|
|
4044
4410
|
const cardActionTimeoutMs = props.cardActionTimeoutMs;
|
|
4045
4411
|
const linkPreviewImages = chat.linkPreviewImages === true;
|
|
@@ -4056,13 +4422,14 @@ function ChatThreadScreen(props) {
|
|
|
4056
4422
|
if (jumpTo) setChosenTopic(null);
|
|
4057
4423
|
}
|
|
4058
4424
|
const topic = topicProp ?? chosenTopic ?? void 0;
|
|
4059
|
-
const conv = useConversation(conversationId, { threadRootId: threadRootId ?? void 0, topic });
|
|
4425
|
+
const conv = useConversation(conversationId, { threadRootId: threadRootId ?? void 0, topic, markRead: active2 });
|
|
4060
4426
|
const pins = usePins(conversationId);
|
|
4061
4427
|
const messageActions = useMessageActions();
|
|
4062
4428
|
const { modules, copy, person } = useChatNative();
|
|
4063
4429
|
const toast = useToast();
|
|
4064
4430
|
const colors = useThemeRoles();
|
|
4065
4431
|
const reducedMotion = useReducedMotion();
|
|
4432
|
+
const { height: windowHeight } = useWindowDimensions();
|
|
4066
4433
|
const genesis = useGenesisModules();
|
|
4067
4434
|
const listRef = useRef(null);
|
|
4068
4435
|
const toNewest = useCallback(() => listRef.current?.scrollToEnd({ animated: true }), []);
|
|
@@ -4083,6 +4450,16 @@ function ChatThreadScreen(props) {
|
|
|
4083
4450
|
() => [...conv.members.map((m) => m.userId), ...conv.messages.map((m) => m.senderId)],
|
|
4084
4451
|
[conv.members, conv.messages]
|
|
4085
4452
|
);
|
|
4453
|
+
const queued = useMemo(() => new Set(queue.map((q) => q.clientId)), [queue]);
|
|
4454
|
+
const lastReceipt = useMemo(
|
|
4455
|
+
() => lastSentReceipt(conv.items, { me: userId, members: conv.members, group, queued, receipts }),
|
|
4456
|
+
[conv.items, userId, conv.members, group, queued, receipts]
|
|
4457
|
+
);
|
|
4458
|
+
const receiptLabel = lastReceipt ? receiptText(lastReceipt.receipt, copy) : null;
|
|
4459
|
+
const receiptKey = lastReceipt?.key ?? null;
|
|
4460
|
+
const readers = lastReceipt?.receipt.state === "read-by" ? lastReceipt.receipt.readers : null;
|
|
4461
|
+
const [readersOpen, setReadersOpen] = useState(false);
|
|
4462
|
+
const openReaders = useCallback(() => setReadersOpen(true), []);
|
|
4086
4463
|
const rows = useMemo(() => buildThreadRows(conv.items, { me: userId, firstUnreadId: conv.firstUnreadId, group }), [conv.items, userId, conv.firstUnreadId, group]);
|
|
4087
4464
|
const paths = useMemo(() => conv.items.flatMap((i) => i.type === "message" ? attachmentPaths(i.message.attachments) : []), [conv.items]);
|
|
4088
4465
|
const urls = useFileUrls(paths);
|
|
@@ -4141,10 +4518,10 @@ function ChatThreadScreen(props) {
|
|
|
4141
4518
|
const { retry, discard, canPost: allowed } = conv;
|
|
4142
4519
|
const onLongPress = useCallback(
|
|
4143
4520
|
(message) => {
|
|
4144
|
-
haptic(modules.haptics, "
|
|
4521
|
+
haptic(modules.haptics ?? genesis.haptics, "long-press");
|
|
4145
4522
|
setActionsFor(message);
|
|
4146
4523
|
},
|
|
4147
|
-
[modules.haptics]
|
|
4524
|
+
[modules.haptics, genesis.haptics]
|
|
4148
4525
|
);
|
|
4149
4526
|
const onSwipeReply = useCallback(() => haptic(modules.haptics, "select"), [modules.haptics]);
|
|
4150
4527
|
const onRetry = useCallback((clientId) => void retry(clientId), [retry]);
|
|
@@ -4205,6 +4582,28 @@ function ChatThreadScreen(props) {
|
|
|
4205
4582
|
},
|
|
4206
4583
|
[copy.jumpedTo, nameOf, attachmentKinds]
|
|
4207
4584
|
);
|
|
4585
|
+
const [scrolledAwayAt, setScrolledAwayAt] = useState(null);
|
|
4586
|
+
const timeline = `${conversationId}:${threadRootId ?? ""}`;
|
|
4587
|
+
const [awayFor, setAwayFor] = useState(timeline);
|
|
4588
|
+
if (awayFor !== timeline) {
|
|
4589
|
+
setAwayFor(timeline);
|
|
4590
|
+
setScrolledAwayAt(null);
|
|
4591
|
+
}
|
|
4592
|
+
const latestSeqNow = useRef(0);
|
|
4593
|
+
latestSeqNow.current = conv.messages.length ? conv.messages[conv.messages.length - 1].seq : 0;
|
|
4594
|
+
const onAtBottomChange = useCallback((atBottom) => setScrolledAwayAt(atBottom ? null : latestSeqNow.current), []);
|
|
4595
|
+
const newBelow = countUnseenBelow(conv.messages, scrolledAwayAt, userId);
|
|
4596
|
+
const openAt = conv.firstUnreadKnown ? conv.firstUnreadId ? UNREAD_ROW_ID : null : void 0;
|
|
4597
|
+
const online = useOnline(modules.netInfo);
|
|
4598
|
+
const connection = connectionState(online, conv.live);
|
|
4599
|
+
const { reload } = conv;
|
|
4600
|
+
const [reloading, setReloading] = useState(false);
|
|
4601
|
+
const retryLoad = useCallback(() => {
|
|
4602
|
+
if (!reload) return;
|
|
4603
|
+
setReloading(true);
|
|
4604
|
+
void reload().catch(() => fail()).finally(() => setReloading(false));
|
|
4605
|
+
}, [reload, fail]);
|
|
4606
|
+
const times = useTimeReveal(reducedMotion);
|
|
4208
4607
|
const onJumpFailed = useCallback(() => {
|
|
4209
4608
|
if (jumpLoadFailed.current) jumpLoadFailed.current = false;
|
|
4210
4609
|
else toast.show({ title: copy.messageGone });
|
|
@@ -4241,11 +4640,14 @@ function ChatThreadScreen(props) {
|
|
|
4241
4640
|
onOpenAttachment,
|
|
4242
4641
|
attachmentSlot,
|
|
4243
4642
|
cardActionTimeoutMs,
|
|
4643
|
+
receipt: row.key === receiptKey ? receiptLabel : null,
|
|
4644
|
+
backdrop: colors.groupedBackground,
|
|
4645
|
+
onReceiptPress: row.key === receiptKey && readers ? openReaders : void 0,
|
|
4244
4646
|
testID: `${testID}-message-${m?.id ?? row.key}`
|
|
4245
4647
|
}
|
|
4246
4648
|
);
|
|
4247
4649
|
},
|
|
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]
|
|
4650
|
+
[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
4651
|
);
|
|
4250
4652
|
const [videoOpen, setVideoOpen] = useState(false);
|
|
4251
4653
|
const preparedVideo = useRef(null);
|
|
@@ -4274,6 +4676,9 @@ function ChatThreadScreen(props) {
|
|
|
4274
4676
|
[conversationId, userId, replyNow, threadRootId, outbox, videoUpload, takePrepared, modules.openFile, setReply, toNewest]
|
|
4275
4677
|
);
|
|
4276
4678
|
const activity = activityLine(conv.activity, (id) => nameOf(id));
|
|
4679
|
+
const typers = conv.activity.filter((a) => a.activity === "typing");
|
|
4680
|
+
const recording = conv.activity.some((a) => a.activity !== "typing");
|
|
4681
|
+
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
4682
|
const topics = topicsState.topics;
|
|
4278
4683
|
const currentTopic = topic ? topics.find((t) => t.topic === topic) ?? null : null;
|
|
4279
4684
|
const topicClosed = topicClosedFor(currentTopic, conv.role);
|
|
@@ -4297,31 +4702,41 @@ function ChatThreadScreen(props) {
|
|
|
4297
4702
|
/* @__PURE__ */ jsxs(KeyboardAvoiding, { style: { flex: 1 }, ...keyboardProps, children: [
|
|
4298
4703
|
showTopicBar ? /* @__PURE__ */ jsx(ChatTopicBar, { topics, value: topic ?? null, onValueChange: setChosenTopic, canManage: canManageTopics(conv.role), onSetTopic: topicsState.setTopic, testID: `${testID}-topics` }) : null,
|
|
4299
4704
|
/* @__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
|
-
|
|
4705
|
+
/* @__PURE__ */ jsx(ChatConnectionLine, { state: connection, testID: `${testID}-connection` }),
|
|
4706
|
+
header,
|
|
4707
|
+
/* @__PURE__ */ jsxs(View, { style: { flex: 1 }, ...times.panHandlers, children: [
|
|
4708
|
+
/* @__PURE__ */ jsx(ChatTimesProvider, { value: times.value, children: /* @__PURE__ */ jsx(
|
|
4709
|
+
NativeThreadList,
|
|
4710
|
+
{
|
|
4711
|
+
ref: listRef,
|
|
4712
|
+
testID: `${testID}-list`,
|
|
4713
|
+
data: rows,
|
|
4714
|
+
keyExtractor: threadRowKey,
|
|
4715
|
+
jumpId: threadRowMessageId,
|
|
4716
|
+
getItemType: threadRowType,
|
|
4717
|
+
renderItem,
|
|
4718
|
+
loading: conv.isLoading,
|
|
4719
|
+
hasEarlier: conv.hasEarlier,
|
|
4720
|
+
onLoadEarlier: () => void conv.loadEarlier(),
|
|
4721
|
+
loadingEarlier: conv.loadingEarlier,
|
|
4722
|
+
earlierLabel: copy.loadEarlier,
|
|
4723
|
+
jumpTo: jumpMessageId,
|
|
4724
|
+
onLoadUntil,
|
|
4725
|
+
jumpAnnouncement,
|
|
4726
|
+
onJumpFailed,
|
|
4727
|
+
footer,
|
|
4728
|
+
openAt,
|
|
4729
|
+
onAtBottomChange,
|
|
4730
|
+
header: firstPageFailed && rows.length ? /* @__PURE__ */ jsx(ThreadLoadError, { onRetry: retryLoad, retrying: reloading, testID: `${testID}-load-error` }) : null,
|
|
4731
|
+
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` })
|
|
4732
|
+
},
|
|
4733
|
+
`${conversationId}:${threadRootId ?? ""}`
|
|
4734
|
+
) }),
|
|
4735
|
+
newBelow > 0 ? /* @__PURE__ */ jsx(NewMessagesPill, { count: newBelow, onPress: toNewest, testID: `${testID}-new-below` }) : null
|
|
4736
|
+
] }),
|
|
4323
4737
|
scheduling && !threadRootId ? /* @__PURE__ */ jsx(ChatScheduledBar, { conversationId, testID: `${testID}-scheduled` }) : null,
|
|
4324
4738
|
/* @__PURE__ */ jsx(VideoUploadTray, { conversationId, userId, testID: `${testID}-video-uploads` }),
|
|
4739
|
+
accessory && !accessFailed ? /* @__PURE__ */ jsx(View, { testID: `${testID}-accessory`, children: accessory({ conversationId, composer, canPost }) }) : null,
|
|
4325
4740
|
accessFailed ? /* @__PURE__ */ jsx(ChatAccessError, { onRetry: retryAccess, retrying: retryingAccess, testID: `${testID}-access-error` }) : /* @__PURE__ */ jsx(
|
|
4326
4741
|
ChatComposer,
|
|
4327
4742
|
{
|
|
@@ -4355,6 +4770,21 @@ function ChatThreadScreen(props) {
|
|
|
4355
4770
|
testID: `${testID}-actions`
|
|
4356
4771
|
}
|
|
4357
4772
|
),
|
|
4773
|
+
/* @__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: [
|
|
4774
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "label", accessibilityRole: "header", style: { color: colors.secondaryLabel, paddingHorizontal: 4 }, children: copy.receiptReadersTitle }),
|
|
4775
|
+
/* @__PURE__ */ jsx(NativeSheetScrollView, { testID: `${testID}-readers-list`, style: { maxHeight: Math.round(windowHeight * 0.7) }, children: (readers ?? []).map((id) => {
|
|
4776
|
+
const p = person(id) ?? people[id];
|
|
4777
|
+
return /* @__PURE__ */ jsx(
|
|
4778
|
+
NativeListItem,
|
|
4779
|
+
{
|
|
4780
|
+
testID: `${testID}-readers-${id}`,
|
|
4781
|
+
title: nameOf(id),
|
|
4782
|
+
leading: /* @__PURE__ */ jsx(NativeAvatar, { size: 32, src: p?.avatarUrl ?? null, fallback: initials(p?.name), alt: p?.name, recyclingKey: id })
|
|
4783
|
+
},
|
|
4784
|
+
id
|
|
4785
|
+
);
|
|
4786
|
+
}) })
|
|
4787
|
+
] }) }),
|
|
4358
4788
|
/* @__PURE__ */ jsx(ChatPhotoViewer, { photos: viewer?.photos ?? null, initialIndex: viewer?.index, onClose: () => setViewer(null), testID: `${testID}-viewer` }),
|
|
4359
4789
|
canSchedule ? /* @__PURE__ */ jsx(ChatScheduleSheet, { open: schedule.open, onOpenChange: schedule.setOpen, onSchedule: (at) => void schedule.scheduleAt(at), testID: `${testID}-schedule` }) : null,
|
|
4360
4790
|
/* @__PURE__ */ jsx(
|
|
@@ -4362,7 +4792,7 @@ function ChatThreadScreen(props) {
|
|
|
4362
4792
|
{
|
|
4363
4793
|
open: videoOpen,
|
|
4364
4794
|
onClose: () => setVideoOpen(false),
|
|
4365
|
-
limitMs: recordingLimitMs(conv.role),
|
|
4795
|
+
limitMs: videoLimitMs ?? recordingLimitMs(conv.role),
|
|
4366
4796
|
onStart: onVideoStart,
|
|
4367
4797
|
onTick: conv.signalRecordingVideo,
|
|
4368
4798
|
onRecorded: onVideoRecorded,
|
|
@@ -4383,19 +4813,106 @@ function UnreadDivider({ label, testID }) {
|
|
|
4383
4813
|
/* @__PURE__ */ jsx(View, { style: { flex: 1, height: 1, backgroundColor: colors.tint } })
|
|
4384
4814
|
] });
|
|
4385
4815
|
}
|
|
4816
|
+
function ChatConnectionLine({ state, testID }) {
|
|
4817
|
+
const colors = useThemeRoles();
|
|
4818
|
+
const { copy } = useChatNative();
|
|
4819
|
+
if (state === "online") return null;
|
|
4820
|
+
const text = state === "offline" ? copy.waitingForNetwork : copy.connecting;
|
|
4821
|
+
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 }) });
|
|
4822
|
+
}
|
|
4823
|
+
function ThreadLoadError({ onRetry, retrying, testID }) {
|
|
4824
|
+
const { copy } = useChatNative();
|
|
4825
|
+
return /* @__PURE__ */ jsx(
|
|
4826
|
+
NativeEmptyState,
|
|
4827
|
+
{
|
|
4828
|
+
variant: "error",
|
|
4829
|
+
title: copy.threadErrorTitle,
|
|
4830
|
+
body: copy.threadErrorBody,
|
|
4831
|
+
testID,
|
|
4832
|
+
primaryAction: /* @__PURE__ */ jsx(NativeButton, { onPress: onRetry, loading: retrying, disabled: retrying, testID: `${testID}-retry`, children: copy.retry })
|
|
4833
|
+
}
|
|
4834
|
+
);
|
|
4835
|
+
}
|
|
4836
|
+
function NewMessagesPill({ count, onPress, testID }) {
|
|
4837
|
+
const colors = useThemeRoles();
|
|
4838
|
+
const { copy } = useChatNative();
|
|
4839
|
+
const label = count === 1 ? copy.newMessagesPillOne : fill(copy.newMessagesPill, { count });
|
|
4840
|
+
return /* @__PURE__ */ jsx(View, { pointerEvents: "box-none", style: { position: "absolute", left: 0, right: 0, bottom: 8, alignItems: "center" }, children: /* @__PURE__ */ jsxs(
|
|
4841
|
+
Pressable,
|
|
4842
|
+
{
|
|
4843
|
+
testID,
|
|
4844
|
+
accessibilityRole: "button",
|
|
4845
|
+
accessibilityLabel: label,
|
|
4846
|
+
accessibilityHint: copy.newMessagesPillHint,
|
|
4847
|
+
accessibilityLiveRegion: "polite",
|
|
4848
|
+
onPress,
|
|
4849
|
+
style: { flexDirection: "row", alignItems: "center", gap: 6, minHeight: 36, paddingHorizontal: 14, borderRadius: 18, backgroundColor: colors.tint },
|
|
4850
|
+
children: [
|
|
4851
|
+
/* @__PURE__ */ jsx(NativeIcon, { name: "chevron-down", size: 14, color: colors.surface }),
|
|
4852
|
+
/* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { color: colors.surface, fontWeight: "600" }, children: label })
|
|
4853
|
+
]
|
|
4854
|
+
}
|
|
4855
|
+
) });
|
|
4856
|
+
}
|
|
4386
4857
|
function ActivityLine({ text, testID }) {
|
|
4387
4858
|
const colors = useThemeRoles();
|
|
4388
4859
|
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
4860
|
}
|
|
4390
4861
|
var threadRowKey = (row) => row.key;
|
|
4391
|
-
var
|
|
4862
|
+
var UNREAD_ROW_ID = "genesis-chat:unread";
|
|
4863
|
+
var threadRowMessageId = (row) => row.type === "unread" ? UNREAD_ROW_ID : row.type === "message" && row.item.type === "message" ? row.item.message.id : null;
|
|
4392
4864
|
var threadRowType = (row) => row.type === "message" ? row.mine ? "mine" : "theirs" : row.type;
|
|
4865
|
+
function isAvatarData(a) {
|
|
4866
|
+
if (a === null || typeof a !== "object" || isValidElement(a)) return false;
|
|
4867
|
+
if ("$$typeof" in a) return false;
|
|
4868
|
+
return typeof a[Symbol.iterator] !== "function";
|
|
4869
|
+
}
|
|
4870
|
+
function ChatThreadTitle({ title, subtitle, avatar, onPress, pressHint, conversationId, tintColor, testID = "chat-thread-title" }) {
|
|
4871
|
+
if (subtitle === void 0 && conversationId) {
|
|
4872
|
+
return /* @__PURE__ */ jsx(AwayTitle, { conversationId, title, avatar, onPress, pressHint, tintColor, testID });
|
|
4873
|
+
}
|
|
4874
|
+
return /* @__PURE__ */ jsx(TitleBody, { title, subtitle: subtitle ?? null, avatar, onPress, pressHint, tintColor, testID });
|
|
4875
|
+
}
|
|
4876
|
+
function AwayTitle({ conversationId, ...rest }) {
|
|
4877
|
+
const { client, userId } = useChat();
|
|
4878
|
+
const { person, copy } = useChatNative();
|
|
4879
|
+
const members = useQuery({ queryKey: chatKeys.members(conversationId), queryFn: () => client.members(conversationId), staleTime: 6e4 }).data;
|
|
4880
|
+
const nameOf = useCallback((id) => person(id)?.name ?? copy.someone, [person, copy.someone]);
|
|
4881
|
+
const away = useAwayLine(conversationId, useMemo(() => members ?? [], [members]), userId, nameOf);
|
|
4882
|
+
return /* @__PURE__ */ jsx(TitleBody, { ...rest, subtitle: away });
|
|
4883
|
+
}
|
|
4884
|
+
function TitleBody({ title, subtitle, avatar, onPress, pressHint, tintColor, testID }) {
|
|
4885
|
+
const colors = useThemeRoles();
|
|
4886
|
+
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;
|
|
4887
|
+
const label = [title, subtitle].filter(Boolean).join(", ");
|
|
4888
|
+
const body = /* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "center", gap: 8, maxWidth: 260 }, children: [
|
|
4889
|
+
picture ? /* @__PURE__ */ jsx(View, { testID: `${testID}-avatar`, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", children: picture }) : null,
|
|
4890
|
+
/* @__PURE__ */ jsxs(View, { style: { flexShrink: 1, alignItems: picture ? "flex-start" : "center" }, children: [
|
|
4891
|
+
/* @__PURE__ */ jsx(NativeText, { numberOfLines: 1, style: { fontSize: 17, lineHeight: 22, fontWeight: "600", color: tintColor ?? colors.label }, children: title }),
|
|
4892
|
+
subtitle ? /* @__PURE__ */ jsx(NativeText, { testID: `${testID}-subtitle`, numberOfLines: 1, preset: "caption", style: { color: colors.secondaryLabel }, children: subtitle }) : null
|
|
4893
|
+
] })
|
|
4894
|
+
] });
|
|
4895
|
+
if (!onPress) {
|
|
4896
|
+
return /* @__PURE__ */ jsx(View, { testID, accessible: true, accessibilityRole: "header", accessibilityLabel: label, children: body });
|
|
4897
|
+
}
|
|
4898
|
+
return /* @__PURE__ */ jsx(Pressable, { testID, accessibilityRole: "button", accessibilityLabel: label, accessibilityHint: pressHint, onPress, hitSlop: 8, style: { minHeight: 44, justifyContent: "center" }, children: body });
|
|
4899
|
+
}
|
|
4393
4900
|
function chatThreadStackOptions(props, background) {
|
|
4901
|
+
const { avatar, subtitle, onPressTitle, titleHint, conversationId, ...header } = props;
|
|
4902
|
+
const custom = avatar !== void 0 || subtitle !== void 0 || onPressTitle !== void 0 || conversationId !== void 0;
|
|
4903
|
+
const title = header.headerTitle ?? "Conversation";
|
|
4394
4904
|
return getThreadPageStackOptions({
|
|
4395
|
-
...
|
|
4905
|
+
...header,
|
|
4396
4906
|
// Large titles collapse into the content scroll view, which is the flipped list here.
|
|
4397
4907
|
large: false,
|
|
4398
|
-
headerOptions: {
|
|
4908
|
+
headerOptions: {
|
|
4909
|
+
headerTransparent: false,
|
|
4910
|
+
headerStyle: { backgroundColor: background },
|
|
4911
|
+
...custom ? {
|
|
4912
|
+
headerTitle: ({ tintColor }) => createElement(ChatThreadTitle, { title, subtitle, avatar, onPress: onPressTitle, pressHint: titleHint, conversationId, tintColor })
|
|
4913
|
+
} : {},
|
|
4914
|
+
...props.headerOptions
|
|
4915
|
+
}
|
|
4399
4916
|
});
|
|
4400
4917
|
}
|
|
4401
4918
|
function useChatThreadStackOptions(props) {
|
|
@@ -4442,39 +4959,6 @@ function ChatStartButton({ onPress, testID = "chat-start-button" }) {
|
|
|
4442
4959
|
const colors = useThemeRoles();
|
|
4443
4960
|
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
4961
|
}
|
|
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
4962
|
|
|
4479
4963
|
// src/native/tus.ts
|
|
4480
4964
|
var TUS_CHUNK_BYTES = 6 * 1024 * 1024;
|
|
@@ -4940,6 +5424,6 @@ function useJumpToMessage({ target, rows, loading, has, loadUntil, scrollTo, onS
|
|
|
4940
5424
|
return { highlightedId, jumping: pending !== null };
|
|
4941
5425
|
}
|
|
4942
5426
|
|
|
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 };
|
|
5427
|
+
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, alertConfirm, 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
5428
|
//# sourceMappingURL=native.js.map
|
|
4945
5429
|
//# sourceMappingURL=native.js.map
|