@marktiderman/genesis-chat 0.7.0 → 0.9.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 +132 -3
- package/dist/{chunk-GBJ3YI4E.js → chunk-5XYDVUPS.js} +6 -3
- package/dist/chunk-5XYDVUPS.js.map +1 -0
- package/dist/{chunk-XQ2ULNHV.js → chunk-D4RPOYB7.js} +4 -4
- package/dist/chunk-D4RPOYB7.js.map +1 -0
- package/dist/{chunk-RYD6WJE5.js → chunk-O2QSBRSH.js} +3 -3
- package/dist/{chunk-RYD6WJE5.js.map → chunk-O2QSBRSH.js.map} +1 -1
- package/dist/{chunk-A4YJX7KT.js → chunk-ZQFREERR.js} +3 -3
- package/dist/{chunk-A4YJX7KT.js.map → chunk-ZQFREERR.js.map} +1 -1
- package/dist/{client-DUIG1hum.d.ts → client-DP7rhJ1U.d.ts} +17 -6
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/native.d.ts +35 -16
- package/dist/native.js +168 -490
- package/dist/native.js.map +1 -1
- package/dist/{outbox-B9NAWQ58.d.ts → outbox-C4LnqpKT.d.ts} +1 -1
- package/dist/push.d.ts +2 -2
- package/dist/react.d.ts +4 -8
- package/dist/react.js +3 -3
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/{thread-oPra7pkW.d.ts → thread-CSzdqNR_.d.ts} +1 -1
- package/dist/web.d.ts +201 -7
- package/dist/web.js +580 -56
- package/dist/web.js.map +1 -1
- package/migrations/0004_genesis_chat_tenants.sql +716 -0
- package/migrations/tests/0001_genesis_chat.test.sql +10 -2
- package/migrations/tests/0002_genesis_chat_coaching.test.sql +8 -0
- package/migrations/tests/0003_genesis_chat_search_threads.test.sql +8 -0
- package/migrations/tests/0004_genesis_chat_tenants.test.sql +259 -0
- package/package.json +18 -7
- package/src/__tests__/core.test.ts +12 -0
- package/src/__tests__/web-dock.test.tsx +465 -0
- package/src/__tests__/web-photo-viewer.test.tsx +43 -0
- package/src/__tests__/web.test.tsx +26 -0
- package/src/core/client.ts +5 -1
- package/src/core/types.ts +16 -0
- package/src/native/__tests__/photo-viewer.test.tsx +24 -5
- package/src/native/__tests__/thread-screen.test.tsx +40 -2
- package/src/native/message-bubble.tsx +1 -1
- package/src/native/photo-viewer.tsx +109 -422
- package/src/native/thread-screen.tsx +77 -207
- package/src/native/use-jump.ts +7 -1
- package/src/react/index.tsx +2 -1
- package/src/web/attachments.tsx +39 -55
- package/src/web/composer.tsx +5 -0
- package/src/web/dock.tsx +889 -0
- package/src/web/inbox.tsx +5 -0
- package/src/web/index.ts +23 -0
- package/src/web/memory-client.ts +1 -1
- package/src/web/thread.tsx +42 -3
- package/dist/chunk-GBJ3YI4E.js.map +0 -1
- package/dist/chunk-XQ2ULNHV.js.map +0 -1
package/dist/native.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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-O2QSBRSH.js';
|
|
2
|
+
export { attachmentPreview, cardTitle, messagePreview } from './chunk-O2QSBRSH.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-D4RPOYB7.js';
|
|
5
|
+
import { summarizeReactions, parseMentions, startsDay, dayLabel, itemTime, itemSender, startsGroup, activityLine } from './chunk-ZQFREERR.js';
|
|
6
|
+
import { formatDuration, nextPlaybackRate, ChatError, CHAT_LIMITS, fileExtension, isAllowedExtension, attachmentKindFor, awaySummary, WEEKDAYS, minutesOf, waveformFromMetering, recordingLimitMs, CHAT_BUCKET, randomId } from './chunk-5XYDVUPS.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
8
|
import { createContext, memo, useMemo, useState, useCallback, useRef, useContext, useSyncExternalStore, useLayoutEffect, useEffect, useReducer } from 'react';
|
|
9
|
-
import { NativeText, NativeAvatar, NativeImage, NativeIcon, NativeButton, NativeProgress, useToast, NativeSheet, NativeDatePicker, NativeTimePicker, NativeListItem, NativeSkeleton, NativeEmptyState, NativeTextarea, NativeSwitch, NativeCombobox, NativeChipGroup, NativeChip, NativeInput, NativeSearchBar, NativeInlineAlert,
|
|
9
|
+
import { NativeText, NativeAvatar, NativeImage, NativeIcon, NativeButton, LIGHTBOX_DISMISS_DISTANCE, LIGHTBOX_DISMISS_VELOCITY, LIGHTBOX_MAX_ZOOM, lightboxPanLimit, lightboxPinchScale, lightboxShouldDismiss, NativeProgress, useToast, NativeSheet, NativeDatePicker, NativeTimePicker, NativeListItem, NativeSkeleton, NativeEmptyState, NativeTextarea, NativeSwitch, NativeCombobox, NativeChipGroup, NativeChip, NativeInput, NativeSearchBar, NativeInlineAlert, NativeLightbox, useGenesisModules, NativeThreadList, NativeSheetScrollView, 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, TextInput, Platform, KeyboardAvoidingView, Alert } from 'react-native';
|
|
12
12
|
import { useThemeRoles, useReducedMotion } from '@marktiderman/genesis-ui-native/hooks';
|
|
@@ -1398,7 +1398,7 @@ function MessageBubbleImpl(props) {
|
|
|
1398
1398
|
testID,
|
|
1399
1399
|
accessibilityElementsHidden: invisible || void 0,
|
|
1400
1400
|
importantForAccessibility: invisible ? "no-hide-descendants" : void 0,
|
|
1401
|
-
style: {
|
|
1401
|
+
style: { paddingTop: row.groupStart ? 8 : 2, borderRadius: 12, backgroundColor: props.highlighted ? colors.fill : void 0, display: invisible ? "none" : void 0 },
|
|
1402
1402
|
children: [
|
|
1403
1403
|
row.showName && sender?.name ? /* @__PURE__ */ jsx(NativeText, { preset: "caption", style: { marginLeft: group ? 48 : 12, marginBottom: 2, color: colors.secondaryLabel }, children: sender.name }) : null,
|
|
1404
1404
|
/* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "flex-end", justifyContent: mine ? "flex-end" : "flex-start" }, children: [
|
|
@@ -2955,55 +2955,6 @@ function ChatTopicBar({ topics, value, onValueChange, canManage = false, onSetTo
|
|
|
2955
2955
|
)) }) })
|
|
2956
2956
|
] });
|
|
2957
2957
|
}
|
|
2958
|
-
function rowIndexOf(rows, messageId) {
|
|
2959
|
-
return rows.findIndex((r) => r.type === "message" && r.item.type === "message" && r.item.message.id === messageId);
|
|
2960
|
-
}
|
|
2961
|
-
function useJumpToMessage({ target, rows, loading, has, loadUntil, scrollTo, onStart, onLanded, onGone, onError }) {
|
|
2962
|
-
const [pending, setPending] = useState(target ? { ...target, phase: "new" } : null);
|
|
2963
|
-
const [highlightedId, setHighlightedId] = useState(null);
|
|
2964
|
-
useEffect(() => {
|
|
2965
|
-
if (target) setPending({ ...target, phase: "new" });
|
|
2966
|
-
}, [target?.messageId, target?.seq]);
|
|
2967
|
-
const latest = useRef({ rows, scrollTo, onStart, onLanded, onGone, onError });
|
|
2968
|
-
latest.current = { rows, scrollTo, onStart, onLanded, onGone, onError };
|
|
2969
|
-
const timer = useRef(null);
|
|
2970
|
-
useEffect(() => () => {
|
|
2971
|
-
if (timer.current) clearTimeout(timer.current);
|
|
2972
|
-
}, []);
|
|
2973
|
-
const go = useCallback((messageId) => {
|
|
2974
|
-
const index2 = rowIndexOf(latest.current.rows, messageId);
|
|
2975
|
-
if (index2 < 0) return;
|
|
2976
|
-
latest.current.onStart?.();
|
|
2977
|
-
latest.current.scrollTo(index2, messageId);
|
|
2978
|
-
latest.current.onLanded?.(messageId);
|
|
2979
|
-
setHighlightedId(messageId);
|
|
2980
|
-
if (timer.current) clearTimeout(timer.current);
|
|
2981
|
-
timer.current = setTimeout(() => setHighlightedId((h) => h === messageId ? null : h), 2e3);
|
|
2982
|
-
}, []);
|
|
2983
|
-
useEffect(() => {
|
|
2984
|
-
if (!pending || loading) return;
|
|
2985
|
-
const { messageId, seq: seq2, phase } = pending;
|
|
2986
|
-
if (has(messageId)) {
|
|
2987
|
-
setPending(null);
|
|
2988
|
-
go(messageId);
|
|
2989
|
-
return;
|
|
2990
|
-
}
|
|
2991
|
-
if (phase === "loading") return;
|
|
2992
|
-
if (phase === "loaded" || seq2 == null) {
|
|
2993
|
-
setPending(null);
|
|
2994
|
-
latest.current.onGone();
|
|
2995
|
-
return;
|
|
2996
|
-
}
|
|
2997
|
-
latest.current.onStart?.();
|
|
2998
|
-
setPending({ messageId, seq: seq2, phase: "loading" });
|
|
2999
|
-
const settle = () => setPending((p) => p && p.messageId === messageId ? { ...p, phase: "loaded" } : p);
|
|
3000
|
-
void loadUntil(seq2).then(settle, (e) => {
|
|
3001
|
-
latest.current.onError(e);
|
|
3002
|
-
settle();
|
|
3003
|
-
});
|
|
3004
|
-
}, [pending, loading, has, loadUntil, go]);
|
|
3005
|
-
return { highlightedId, jumping: pending !== null };
|
|
3006
|
-
}
|
|
3007
2958
|
|
|
3008
2959
|
// src/native/emoji-data.ts
|
|
3009
2960
|
var EMOJI_GROUP_DATA = {
|
|
@@ -3829,173 +3780,91 @@ function ChatAccessError({ onRetry, retrying = false, testID = "chat-access-erro
|
|
|
3829
3780
|
/* @__PURE__ */ jsx(NativeButton, { variant: "outline", size: "lg", onPress: onRetry, loading: retrying, testID: `${testID}-retry`, children: copy.retry })
|
|
3830
3781
|
] });
|
|
3831
3782
|
}
|
|
3832
|
-
var DISMISS_DISTANCE =
|
|
3833
|
-
var DISMISS_VELOCITY =
|
|
3834
|
-
var MAX_ZOOM =
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
function pinchScale(startScale, startDistance, distance) {
|
|
3839
|
-
if (startDistance <= 0) return startScale;
|
|
3840
|
-
return Math.min(MAX_ZOOM, Math.max(0.8, startScale * (distance / startDistance)));
|
|
3841
|
-
}
|
|
3842
|
-
function touchDistance(touches) {
|
|
3843
|
-
const [a, b] = touches;
|
|
3844
|
-
if (!a || !b) return 0;
|
|
3845
|
-
return Math.hypot(a.pageX - b.pageX, a.pageY - b.pageY);
|
|
3846
|
-
}
|
|
3847
|
-
function panLimit(scale, size) {
|
|
3848
|
-
return Math.max(0, (scale - 1) * size / 2);
|
|
3849
|
-
}
|
|
3783
|
+
var DISMISS_DISTANCE = LIGHTBOX_DISMISS_DISTANCE;
|
|
3784
|
+
var DISMISS_VELOCITY = LIGHTBOX_DISMISS_VELOCITY;
|
|
3785
|
+
var MAX_ZOOM = LIGHTBOX_MAX_ZOOM;
|
|
3786
|
+
var shouldDismiss = lightboxShouldDismiss;
|
|
3787
|
+
var pinchScale = lightboxPinchScale;
|
|
3788
|
+
var panLimit = lightboxPanLimit;
|
|
3850
3789
|
function isLocalUri(uri) {
|
|
3851
3790
|
return /^(file|ph|content|assets-library):/.test(uri);
|
|
3852
3791
|
}
|
|
3853
|
-
var clamp = (v, limit) => Math.max(-limit, Math.min(limit, v));
|
|
3854
|
-
var DOUBLE_TAP_MS = 400;
|
|
3855
3792
|
function ChatPhotoViewer({ photos, initialIndex = 0, onClose, testID = "chat-photo-viewer" }) {
|
|
3856
|
-
const open = photos !== null && photos.length > 0;
|
|
3857
|
-
return /* @__PURE__ */ jsx(NativeFullScreenModal, { open, onOpenChange: (o) => o ? void 0 : onClose(), tone: "none", testID, children: open ? /* @__PURE__ */ jsx(ViewerBody, { photos, initialIndex: Math.min(Math.max(0, initialIndex), photos.length - 1), onClose, testID }) : null });
|
|
3858
|
-
}
|
|
3859
|
-
function ViewerBody({ photos, initialIndex, onClose, testID }) {
|
|
3860
3793
|
const { copy, modules } = useChatNative();
|
|
3861
|
-
const { width, height } = useWindowDimensions();
|
|
3862
|
-
const insets = useSafeAreaInsets();
|
|
3863
|
-
const reducedMotion = useReducedMotion();
|
|
3864
3794
|
const [index2, setIndex] = useState(initialIndex);
|
|
3865
|
-
const [zoomed, setZoomed] = useState(false);
|
|
3866
|
-
const [chrome, setChrome] = useState(true);
|
|
3867
3795
|
const [busy, setBusy] = useState(false);
|
|
3868
3796
|
const [notice, setNotice] = useState(null);
|
|
3869
|
-
const
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3797
|
+
const items = useMemo(() => (photos ?? []).map((p) => ({ id: p.key, src: p.uri, alt: p.alt })), [photos]);
|
|
3798
|
+
useEffect(() => {
|
|
3799
|
+
if (!photos) return;
|
|
3800
|
+
setIndex(initialIndex);
|
|
3801
|
+
setNotice(null);
|
|
3802
|
+
setBusy(false);
|
|
3803
|
+
}, [photos, initialIndex]);
|
|
3873
3804
|
useEffect(() => {
|
|
3874
3805
|
if (!notice) return;
|
|
3875
3806
|
const t = setTimeout(() => setNotice(null), 2500);
|
|
3876
3807
|
return () => clearTimeout(t);
|
|
3877
3808
|
}, [notice]);
|
|
3878
|
-
const
|
|
3879
|
-
(i) => {
|
|
3880
|
-
if (i < 0 || i >= photos.length) return;
|
|
3881
|
-
setIndex(i);
|
|
3882
|
-
setZoomed(false);
|
|
3883
|
-
listRef.current?.scrollToIndex?.({ index: i, animated: !reducedMotion });
|
|
3884
|
-
},
|
|
3885
|
-
[photos.length, reducedMotion]
|
|
3886
|
-
);
|
|
3887
|
-
const onMomentumEnd = useCallback(
|
|
3888
|
-
(e) => {
|
|
3889
|
-
const i = Math.round(e.nativeEvent.contentOffset.x / Math.max(1, width));
|
|
3890
|
-
if (i !== index2 && i >= 0 && i < photos.length) {
|
|
3891
|
-
setIndex(i);
|
|
3892
|
-
setZoomed(false);
|
|
3893
|
-
}
|
|
3894
|
-
},
|
|
3895
|
-
[width, index2, photos.length]
|
|
3896
|
-
);
|
|
3809
|
+
const list = photos ?? [];
|
|
3897
3810
|
const local = async (uri) => isLocalUri(uri) ? uri : modules.downloadFile ? modules.downloadFile(uri) : null;
|
|
3898
|
-
const reachable = Boolean(modules.downloadFile) ||
|
|
3811
|
+
const reachable = Boolean(modules.downloadFile) || list.every((p) => isLocalUri(p.uri));
|
|
3899
3812
|
const canShare = Boolean(modules.sharing) && reachable;
|
|
3900
3813
|
const canSave = Boolean(modules.mediaLibrary) && reachable;
|
|
3901
|
-
const run =
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3814
|
+
const run = useCallback(
|
|
3815
|
+
async (what, uri) => {
|
|
3816
|
+
if (busy) return;
|
|
3817
|
+
setBusy(true);
|
|
3818
|
+
try {
|
|
3819
|
+
if (what === "save") {
|
|
3820
|
+
const lib = modules.mediaLibrary;
|
|
3821
|
+
const permission = await lib.requestPermissionsAsync(true);
|
|
3822
|
+
if (!permission.granted) {
|
|
3823
|
+
setNotice(copy.photosDenied);
|
|
3824
|
+
return;
|
|
3825
|
+
}
|
|
3826
|
+
const file = await local(uri);
|
|
3827
|
+
if (!file) throw new Error("no copy on the phone");
|
|
3828
|
+
await lib.saveToLibraryAsync(file);
|
|
3829
|
+
haptic(modules.haptics, "send");
|
|
3830
|
+
setNotice(copy.photoSaved);
|
|
3831
|
+
} else {
|
|
3832
|
+
const sharing = modules.sharing;
|
|
3833
|
+
if (!await sharing.isAvailableAsync()) throw new Error("sharing unavailable");
|
|
3834
|
+
const file = await local(uri);
|
|
3835
|
+
if (!file) throw new Error("no copy on the phone");
|
|
3836
|
+
await sharing.shareAsync(file, { dialogTitle: copy.sharePhoto });
|
|
3911
3837
|
}
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
} else {
|
|
3918
|
-
const sharing = modules.sharing;
|
|
3919
|
-
if (!await sharing.isAvailableAsync()) throw new Error("sharing unavailable");
|
|
3920
|
-
const file = await local(photo.uri);
|
|
3921
|
-
if (!file) throw new Error("no copy on the phone");
|
|
3922
|
-
await sharing.shareAsync(file, { dialogTitle: copy.sharePhoto });
|
|
3838
|
+
} catch {
|
|
3839
|
+
haptic(modules.haptics, "error");
|
|
3840
|
+
setNotice(copy.actionFailed);
|
|
3841
|
+
} finally {
|
|
3842
|
+
setBusy(false);
|
|
3923
3843
|
}
|
|
3924
|
-
}
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3844
|
+
},
|
|
3845
|
+
[busy, modules, copy]
|
|
3846
|
+
);
|
|
3847
|
+
return /* @__PURE__ */ jsx(
|
|
3848
|
+
NativeLightbox,
|
|
3849
|
+
{
|
|
3850
|
+
open: photos != null && photos.length > 0,
|
|
3851
|
+
onOpenChange: (open) => !open && onClose(),
|
|
3852
|
+
items,
|
|
3853
|
+
index: index2,
|
|
3854
|
+
onIndexChange: setIndex,
|
|
3855
|
+
labels: {
|
|
3856
|
+
close: copy.closeViewer,
|
|
3857
|
+
position: (n, count) => fill(copy.photoOf, { n, count }),
|
|
3858
|
+
pagerHint: copy.viewerHint
|
|
3859
|
+
},
|
|
3860
|
+
renderActions: (item) => /* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", gap: 8 }, children: [
|
|
3861
|
+
canSave ? /* @__PURE__ */ jsx(ViewerButton, { icon: "download", label: copy.savePhoto, onPress: () => void run("save", item.src), disabled: busy, testID: `${testID}-save` }) : null,
|
|
3862
|
+
canShare ? /* @__PURE__ */ jsx(ViewerButton, { icon: "share", label: copy.sharePhoto, onPress: () => void run("share", item.src), disabled: busy, testID: `${testID}-share` }) : null
|
|
3863
|
+
] }),
|
|
3864
|
+
renderCaption: () => notice ? /* @__PURE__ */ jsx(View, { accessibilityLiveRegion: "assertive", testID: `${testID}-notice`, style: { alignSelf: "center", backgroundColor: "rgba(40,40,40,0.92)", borderRadius: 14, paddingHorizontal: 16, paddingVertical: 10 }, children: /* @__PURE__ */ jsx(NativeText, { style: { color: "#FFFFFF", textAlign: "center" }, children: notice }) }) : null,
|
|
3865
|
+
testID
|
|
3929
3866
|
}
|
|
3930
|
-
};
|
|
3931
|
-
const toggleChrome = useCallback(() => setChrome((c) => !c), []);
|
|
3932
|
-
const onPull = useCallback((dy) => backdrop.setValue(Math.max(0.35, 1 - Math.max(0, dy) / 400)), [backdrop]);
|
|
3933
|
-
const renderItem = useCallback(
|
|
3934
|
-
({ item, index: i }) => /* @__PURE__ */ jsx(
|
|
3935
|
-
ZoomablePhoto,
|
|
3936
|
-
{
|
|
3937
|
-
photo: item,
|
|
3938
|
-
width,
|
|
3939
|
-
height,
|
|
3940
|
-
active: i === index2,
|
|
3941
|
-
onZoomChange: setZoomed,
|
|
3942
|
-
onPull,
|
|
3943
|
-
onDismiss: onClose,
|
|
3944
|
-
onTap: toggleChrome,
|
|
3945
|
-
testID: `${testID}-photo-${i}`
|
|
3946
|
-
}
|
|
3947
|
-
),
|
|
3948
|
-
[width, height, index2, onPull, onClose, toggleChrome, testID]
|
|
3949
3867
|
);
|
|
3950
|
-
const counter = many ? fill(copy.photoOf, { n: index2 + 1, count: photos.length }) : null;
|
|
3951
|
-
return /* @__PURE__ */ jsxs(View, { style: { flex: 1 }, children: [
|
|
3952
|
-
/* @__PURE__ */ jsx(Animated.View, { pointerEvents: "none", style: { position: "absolute", top: 0, right: 0, bottom: 0, left: 0, backgroundColor: FULL_SCREEN_DARK, opacity: backdrop } }),
|
|
3953
|
-
/* @__PURE__ */ jsx(
|
|
3954
|
-
View,
|
|
3955
|
-
{
|
|
3956
|
-
style: { flex: 1 },
|
|
3957
|
-
accessible: true,
|
|
3958
|
-
accessibilityRole: "adjustable",
|
|
3959
|
-
accessibilityLabel: photo.alt,
|
|
3960
|
-
accessibilityValue: counter ? { text: counter } : void 0,
|
|
3961
|
-
accessibilityHint: many ? copy.viewerHint : void 0,
|
|
3962
|
-
accessibilityActions: many ? [{ name: "increment" }, { name: "decrement" }] : [],
|
|
3963
|
-
onAccessibilityAction: (e) => {
|
|
3964
|
-
if (e.nativeEvent.actionName === "increment") goTo(index2 + 1);
|
|
3965
|
-
if (e.nativeEvent.actionName === "decrement") goTo(index2 - 1);
|
|
3966
|
-
},
|
|
3967
|
-
testID: `${testID}-pager`,
|
|
3968
|
-
children: /* @__PURE__ */ jsx(
|
|
3969
|
-
FlatList,
|
|
3970
|
-
{
|
|
3971
|
-
ref: listRef,
|
|
3972
|
-
testID: `${testID}-list`,
|
|
3973
|
-
data: photos,
|
|
3974
|
-
horizontal: true,
|
|
3975
|
-
pagingEnabled: true,
|
|
3976
|
-
scrollEnabled: many && !zoomed,
|
|
3977
|
-
showsHorizontalScrollIndicator: false,
|
|
3978
|
-
initialScrollIndex: initialIndex,
|
|
3979
|
-
getItemLayout: (_d, i) => ({ length: width, offset: width * i, index: i }),
|
|
3980
|
-
keyExtractor: (p) => p.key,
|
|
3981
|
-
renderItem,
|
|
3982
|
-
onMomentumScrollEnd: onMomentumEnd,
|
|
3983
|
-
extraData: index2,
|
|
3984
|
-
windowSize: 3,
|
|
3985
|
-
initialNumToRender: 1
|
|
3986
|
-
}
|
|
3987
|
-
)
|
|
3988
|
-
}
|
|
3989
|
-
),
|
|
3990
|
-
chrome ? /* @__PURE__ */ jsxs(View, { pointerEvents: "box-none", style: { position: "absolute", top: insets.top, left: 0, right: 0, flexDirection: "row", alignItems: "center", gap: 8, paddingHorizontal: 8, minHeight: 52 }, children: [
|
|
3991
|
-
/* @__PURE__ */ jsx(ViewerButton, { icon: "close", label: copy.closeViewer, onPress: onClose, testID: `${testID}-close` }),
|
|
3992
|
-
/* @__PURE__ */ jsx(View, { style: { flex: 1, alignItems: "center" }, children: counter ? /* @__PURE__ */ jsx(NativeText, { testID: `${testID}-counter`, accessibilityLiveRegion: "polite", style: { color: "#FFFFFF", fontWeight: "600", fontVariant: ["tabular-nums"] }, children: counter }) : null }),
|
|
3993
|
-
canSave ? /* @__PURE__ */ jsx(ViewerButton, { icon: "download", label: copy.savePhoto, onPress: () => void run("save"), disabled: busy, testID: `${testID}-save` }) : null,
|
|
3994
|
-
canShare ? /* @__PURE__ */ jsx(ViewerButton, { icon: "share", label: copy.sharePhoto, onPress: () => void run("share"), disabled: busy, testID: `${testID}-share` }) : null,
|
|
3995
|
-
!canSave && !canShare ? /* @__PURE__ */ jsx(View, { style: { width: 44 } }) : null
|
|
3996
|
-
] }) : null,
|
|
3997
|
-
notice ? /* @__PURE__ */ jsx(View, { pointerEvents: "none", style: { position: "absolute", left: 24, right: 24, bottom: insets.bottom + 24, alignItems: "center" }, children: /* @__PURE__ */ jsx(View, { accessibilityLiveRegion: "assertive", testID: `${testID}-notice`, style: { backgroundColor: "rgba(40,40,40,0.92)", borderRadius: 14, paddingHorizontal: 16, paddingVertical: 10 }, children: /* @__PURE__ */ jsx(NativeText, { style: { color: "#FFFFFF", textAlign: "center" }, children: notice }) }) }) : null
|
|
3998
|
-
] });
|
|
3999
3868
|
}
|
|
4000
3869
|
function ViewerButton({ icon, label, onPress, disabled = false, testID }) {
|
|
4001
3870
|
return /* @__PURE__ */ jsx(
|
|
@@ -4013,179 +3882,6 @@ function ViewerButton({ icon, label, onPress, disabled = false, testID }) {
|
|
|
4013
3882
|
}
|
|
4014
3883
|
);
|
|
4015
3884
|
}
|
|
4016
|
-
function ZoomablePhoto(props) {
|
|
4017
|
-
return Platform.OS === "ios" ? /* @__PURE__ */ jsx(ZoomableIos, { ...props }) : /* @__PURE__ */ jsx(ZoomablePan, { ...props });
|
|
4018
|
-
}
|
|
4019
|
-
function Photo({ photo, width, height, testID }) {
|
|
4020
|
-
return /* @__PURE__ */ jsx(NativeImage, { src: photo.uri, alt: photo.alt, width, height, contentFit: "contain", className: "bg-transparent", testID });
|
|
4021
|
-
}
|
|
4022
|
-
function useTaps(onSingle, onDouble) {
|
|
4023
|
-
const last = useRef(0);
|
|
4024
|
-
const timer = useRef(null);
|
|
4025
|
-
useEffect(
|
|
4026
|
-
() => () => {
|
|
4027
|
-
if (timer.current) clearTimeout(timer.current);
|
|
4028
|
-
},
|
|
4029
|
-
[]
|
|
4030
|
-
);
|
|
4031
|
-
return (e) => {
|
|
4032
|
-
const now = Date.now();
|
|
4033
|
-
const at = { locationX: e.nativeEvent?.locationX ?? 0, locationY: e.nativeEvent?.locationY ?? 0 };
|
|
4034
|
-
if (now - last.current < DOUBLE_TAP_MS) {
|
|
4035
|
-
last.current = 0;
|
|
4036
|
-
if (timer.current) clearTimeout(timer.current);
|
|
4037
|
-
onDouble(at);
|
|
4038
|
-
return;
|
|
4039
|
-
}
|
|
4040
|
-
last.current = now;
|
|
4041
|
-
timer.current = setTimeout(onSingle, DOUBLE_TAP_MS);
|
|
4042
|
-
};
|
|
4043
|
-
}
|
|
4044
|
-
function zoomTo(view, rect, animated) {
|
|
4045
|
-
view?.scrollResponderZoomTo?.({ ...rect, animated }, animated);
|
|
4046
|
-
}
|
|
4047
|
-
function ZoomableIos({ photo, width, height, active: active2, onZoomChange, onPull, onDismiss, onTap, testID }) {
|
|
4048
|
-
const ref = useRef(null);
|
|
4049
|
-
const scale = useRef(1);
|
|
4050
|
-
const reducedMotion = useReducedMotion();
|
|
4051
|
-
useEffect(() => {
|
|
4052
|
-
if (!active2 && scale.current > 1.01) {
|
|
4053
|
-
zoomTo(ref.current, { x: 0, y: 0, width, height }, false);
|
|
4054
|
-
scale.current = 1;
|
|
4055
|
-
}
|
|
4056
|
-
}, [active2, width, height]);
|
|
4057
|
-
const tap = useTaps(onTap, (at) => {
|
|
4058
|
-
if (scale.current > 1.01) return zoomTo(ref.current, { x: 0, y: 0, width, height }, !reducedMotion);
|
|
4059
|
-
const w = width / 2.5;
|
|
4060
|
-
const h = height / 2.5;
|
|
4061
|
-
zoomTo(ref.current, { x: at.locationX - w / 2, y: at.locationY - h / 2, width: w, height: h }, !reducedMotion);
|
|
4062
|
-
});
|
|
4063
|
-
return /* @__PURE__ */ jsx(
|
|
4064
|
-
ScrollView,
|
|
4065
|
-
{
|
|
4066
|
-
ref,
|
|
4067
|
-
testID,
|
|
4068
|
-
style: { width, height },
|
|
4069
|
-
contentContainerStyle: { width, height },
|
|
4070
|
-
maximumZoomScale: MAX_ZOOM,
|
|
4071
|
-
minimumZoomScale: 1,
|
|
4072
|
-
bouncesZoom: true,
|
|
4073
|
-
centerContent: true,
|
|
4074
|
-
alwaysBounceVertical: true,
|
|
4075
|
-
showsHorizontalScrollIndicator: false,
|
|
4076
|
-
showsVerticalScrollIndicator: false,
|
|
4077
|
-
scrollEventThrottle: 16,
|
|
4078
|
-
onScroll: (e) => {
|
|
4079
|
-
const z = e.nativeEvent.zoomScale ?? 1;
|
|
4080
|
-
if (z > 1.01 !== scale.current > 1.01) onZoomChange(z > 1.01);
|
|
4081
|
-
scale.current = z;
|
|
4082
|
-
if (z <= 1.01) onPull(-e.nativeEvent.contentOffset.y);
|
|
4083
|
-
},
|
|
4084
|
-
onScrollEndDrag: (e) => {
|
|
4085
|
-
if (scale.current > 1.01) return;
|
|
4086
|
-
if (shouldDismiss(-e.nativeEvent.contentOffset.y, -(e.nativeEvent.velocity?.y ?? 0))) onDismiss();
|
|
4087
|
-
else onPull(0);
|
|
4088
|
-
},
|
|
4089
|
-
children: /* @__PURE__ */ jsx(Pressable, { accessible: false, onPress: tap, style: { width, height }, children: /* @__PURE__ */ jsx(Photo, { photo, width, height, testID: `${testID}-image` }) })
|
|
4090
|
-
}
|
|
4091
|
-
);
|
|
4092
|
-
}
|
|
4093
|
-
function ZoomablePan({ photo, width, height, active: active2, onZoomChange, onPull, onDismiss, onTap, testID }) {
|
|
4094
|
-
const reducedMotion = useReducedMotion();
|
|
4095
|
-
const scale = useRef(new Animated.Value(1)).current;
|
|
4096
|
-
const tx = useRef(new Animated.Value(0)).current;
|
|
4097
|
-
const ty = useRef(new Animated.Value(0)).current;
|
|
4098
|
-
const s = useRef({ scale: 1, x: 0, y: 0, startScale: 1, startDistance: 0, startX: 0, startY: 0, pinching: false, dragging: false });
|
|
4099
|
-
const settle = useCallback(
|
|
4100
|
-
(to) => {
|
|
4101
|
-
s.current.scale = to.scale;
|
|
4102
|
-
s.current.x = to.x;
|
|
4103
|
-
s.current.y = to.y;
|
|
4104
|
-
onZoomChange(to.scale > 1.01);
|
|
4105
|
-
if (reducedMotion) {
|
|
4106
|
-
scale.setValue(to.scale);
|
|
4107
|
-
tx.setValue(to.x);
|
|
4108
|
-
ty.setValue(to.y);
|
|
4109
|
-
return;
|
|
4110
|
-
}
|
|
4111
|
-
Animated.parallel([
|
|
4112
|
-
Animated.spring(scale, { toValue: to.scale, useNativeDriver: true }),
|
|
4113
|
-
Animated.spring(tx, { toValue: to.x, useNativeDriver: true }),
|
|
4114
|
-
Animated.spring(ty, { toValue: to.y, useNativeDriver: true })
|
|
4115
|
-
]).start();
|
|
4116
|
-
},
|
|
4117
|
-
[reducedMotion, onZoomChange, scale, tx, ty]
|
|
4118
|
-
);
|
|
4119
|
-
useEffect(() => {
|
|
4120
|
-
if (!active2 && s.current.scale > 1.01) settle({ scale: 1, x: 0, y: 0 });
|
|
4121
|
-
}, [active2, settle]);
|
|
4122
|
-
const tap = useTaps(onTap, (at) => {
|
|
4123
|
-
if (s.current.scale > 1.01) return settle({ scale: 1, x: 0, y: 0 });
|
|
4124
|
-
const z = 2.5;
|
|
4125
|
-
settle({ scale: z, x: clamp((width / 2 - at.locationX) * (z - 1), panLimit(z, width)), y: clamp((height / 2 - at.locationY) * (z - 1), panLimit(z, height)) });
|
|
4126
|
-
});
|
|
4127
|
-
const responder = useMemo(
|
|
4128
|
-
() => PanResponder.create({
|
|
4129
|
-
onStartShouldSetPanResponder: () => false,
|
|
4130
|
-
onMoveShouldSetPanResponder: (e, g) => e.nativeEvent.touches.length >= 2 || s.current.scale > 1.01 || g.dy > 8 && Math.abs(g.dy) > Math.abs(g.dx) * 1.5,
|
|
4131
|
-
onPanResponderTerminationRequest: () => false,
|
|
4132
|
-
onPanResponderGrant: (e) => {
|
|
4133
|
-
const st = s.current;
|
|
4134
|
-
st.pinching = e.nativeEvent.touches.length >= 2;
|
|
4135
|
-
st.dragging = !st.pinching && st.scale <= 1.01;
|
|
4136
|
-
st.startScale = st.scale;
|
|
4137
|
-
st.startDistance = touchDistance(e.nativeEvent.touches);
|
|
4138
|
-
st.startX = st.x;
|
|
4139
|
-
st.startY = st.y;
|
|
4140
|
-
},
|
|
4141
|
-
onPanResponderMove: (e, g) => {
|
|
4142
|
-
const st = s.current;
|
|
4143
|
-
const touches = e.nativeEvent.touches;
|
|
4144
|
-
if (touches.length >= 2) {
|
|
4145
|
-
if (!st.pinching) {
|
|
4146
|
-
st.pinching = true;
|
|
4147
|
-
st.dragging = false;
|
|
4148
|
-
st.startScale = st.scale;
|
|
4149
|
-
st.startDistance = touchDistance(touches);
|
|
4150
|
-
}
|
|
4151
|
-
st.scale = pinchScale(st.startScale, st.startDistance, touchDistance(touches));
|
|
4152
|
-
scale.setValue(st.scale);
|
|
4153
|
-
return;
|
|
4154
|
-
}
|
|
4155
|
-
if (st.dragging) {
|
|
4156
|
-
st.y = Math.max(0, g.dy);
|
|
4157
|
-
ty.setValue(st.y);
|
|
4158
|
-
onPull(st.y);
|
|
4159
|
-
return;
|
|
4160
|
-
}
|
|
4161
|
-
if (st.scale > 1.01) {
|
|
4162
|
-
st.x = clamp(st.startX + g.dx, panLimit(st.scale, width));
|
|
4163
|
-
st.y = clamp(st.startY + g.dy, panLimit(st.scale, height));
|
|
4164
|
-
tx.setValue(st.x);
|
|
4165
|
-
ty.setValue(st.y);
|
|
4166
|
-
}
|
|
4167
|
-
},
|
|
4168
|
-
onPanResponderRelease: (_e, g) => {
|
|
4169
|
-
const st = s.current;
|
|
4170
|
-
if (st.dragging) {
|
|
4171
|
-
st.dragging = false;
|
|
4172
|
-
if (shouldDismiss(g.dy, g.vy)) return onDismiss();
|
|
4173
|
-
onPull(0);
|
|
4174
|
-
return settle({ scale: 1, x: 0, y: 0 });
|
|
4175
|
-
}
|
|
4176
|
-
st.pinching = false;
|
|
4177
|
-
const z = Math.max(1, st.scale);
|
|
4178
|
-
settle({ scale: z, x: clamp(st.x, panLimit(z, width)), y: clamp(st.y, panLimit(z, height)) });
|
|
4179
|
-
},
|
|
4180
|
-
onPanResponderTerminate: () => {
|
|
4181
|
-
onPull(0);
|
|
4182
|
-
settle({ scale: Math.max(1, s.current.scale), x: 0, y: 0 });
|
|
4183
|
-
}
|
|
4184
|
-
}),
|
|
4185
|
-
[width, height, onPull, onDismiss, settle, scale, tx, ty]
|
|
4186
|
-
);
|
|
4187
|
-
return /* @__PURE__ */ jsx(View, { testID, style: { width, height, overflow: "hidden" }, ...responder.panHandlers, children: /* @__PURE__ */ jsx(Animated.View, { style: { width, height, transform: [{ translateX: tx }, { translateY: ty }, { scale }] }, children: /* @__PURE__ */ jsx(Pressable, { accessible: false, onPress: tap, style: { width, height }, children: /* @__PURE__ */ jsx(Photo, { photo, width, height, testID: `${testID}-image` }) }) }) });
|
|
4188
|
-
}
|
|
4189
3885
|
function galleryFor(messages, urls, uri, alt, label) {
|
|
4190
3886
|
for (const m of messages) {
|
|
4191
3887
|
const images = m.attachments.filter((a) => a.kind === "image").map((a) => fromServer(a, urls));
|
|
@@ -4376,22 +4072,8 @@ function ChatThreadScreen(props) {
|
|
|
4376
4072
|
const colors = useThemeRoles();
|
|
4377
4073
|
const reducedMotion = useReducedMotion();
|
|
4378
4074
|
const genesis = useGenesisModules();
|
|
4379
|
-
const List = genesis.list ?? FlatList;
|
|
4380
|
-
const mode = threadListMode(Boolean(genesis.list), reducedMotion);
|
|
4381
4075
|
const listRef = useRef(null);
|
|
4382
|
-
const
|
|
4383
|
-
const placed = useRef(!mode.followsByHand);
|
|
4384
|
-
const toBottom = useCallback(
|
|
4385
|
-
(animated) => {
|
|
4386
|
-
const go = (a) => listRef.current?.scrollToEnd?.({ animated: a && !reducedMotion });
|
|
4387
|
-
requestAnimationFrame(() => {
|
|
4388
|
-
go(animated);
|
|
4389
|
-
placed.current = true;
|
|
4390
|
-
});
|
|
4391
|
-
if (animated) setTimeout(() => go(true), 180);
|
|
4392
|
-
},
|
|
4393
|
-
[reducedMotion]
|
|
4394
|
-
);
|
|
4076
|
+
const toNewest = useCallback(() => listRef.current?.scrollToEnd({ animated: true }), []);
|
|
4395
4077
|
const composer = useChatComposer(conversationId, threadRootId, userId);
|
|
4396
4078
|
const { setReply } = composer;
|
|
4397
4079
|
const [actionsFor, setActionsFor] = useState(null);
|
|
@@ -4504,47 +4186,29 @@ function ChatThreadScreen(props) {
|
|
|
4504
4186
|
);
|
|
4505
4187
|
const observer = conv.role === "observer";
|
|
4506
4188
|
const { loadUntil } = conv;
|
|
4507
|
-
const
|
|
4508
|
-
const
|
|
4509
|
-
|
|
4510
|
-
|
|
4511
|
-
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
rows,
|
|
4517
|
-
loading: conv.isLoading,
|
|
4518
|
-
has: useCallback((id) => byId.has(id), [byId]),
|
|
4519
|
-
loadUntil,
|
|
4520
|
-
scrollTo: (index2, id) => {
|
|
4521
|
-
jumpingTo.current = { id, tries: 0 };
|
|
4522
|
-
const scroll = (at) => listRef.current?.scrollToIndex?.({ index: at, animated: !reducedMotion, viewPosition: 0.5 });
|
|
4523
|
-
requestAnimationFrame(() => scroll(index2));
|
|
4524
|
-
if (retryTimer.current) clearTimeout(retryTimer.current);
|
|
4525
|
-
retryTimer.current = setTimeout(() => {
|
|
4526
|
-
const at = rowIndexOf(rowsNow.current, id);
|
|
4527
|
-
if (at >= 0) scroll(at);
|
|
4528
|
-
}, 250);
|
|
4529
|
-
},
|
|
4530
|
-
onStart: () => {
|
|
4531
|
-
atBottom.current = false;
|
|
4532
|
-
placed.current = true;
|
|
4533
|
-
},
|
|
4534
|
-
onLanded: (id) => {
|
|
4535
|
-
const m = byId.get(id);
|
|
4536
|
-
if (m) AccessibilityInfo.announceForAccessibility?.(fill(copy.jumpedTo, { name: nameOf(m.senderId), text: attachmentPreview(displayBody(m.body), m.attachments[0], attachmentKinds, Boolean(m.deletedAt)) }));
|
|
4189
|
+
const jumpSeq = jumpTo?.seq;
|
|
4190
|
+
const jumpMessageId = jumpTo?.messageId ?? null;
|
|
4191
|
+
const onLoadUntil = useCallback(
|
|
4192
|
+
(id) => {
|
|
4193
|
+
if (id !== jumpMessageId || jumpSeq == null) return Promise.resolve(false);
|
|
4194
|
+
return loadUntil(jumpSeq).catch(() => {
|
|
4195
|
+
fail();
|
|
4196
|
+
return false;
|
|
4197
|
+
});
|
|
4537
4198
|
},
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4199
|
+
[jumpMessageId, jumpSeq, loadUntil, fail]
|
|
4200
|
+
);
|
|
4201
|
+
const jumpAnnouncement = useCallback(
|
|
4202
|
+
(row) => {
|
|
4203
|
+
const m = row.type === "message" && row.item.type === "message" ? row.item.message : null;
|
|
4204
|
+
return m ? fill(copy.jumpedTo, { name: nameOf(m.senderId), text: attachmentPreview(displayBody(m.body), m.attachments[0], attachmentKinds, Boolean(m.deletedAt)) }) : "";
|
|
4542
4205
|
},
|
|
4543
|
-
|
|
4544
|
-
|
|
4206
|
+
[copy.jumpedTo, nameOf, attachmentKinds]
|
|
4207
|
+
);
|
|
4208
|
+
const onJumpFailed = useCallback(() => toast.show({ title: copy.messageGone }), [toast, copy.messageGone]);
|
|
4545
4209
|
const reattachable = useCallback((files) => files.every((f) => !f.lost || f.kind === "image" || f.kind === "video"), []);
|
|
4546
4210
|
const renderItem = useCallback(
|
|
4547
|
-
({
|
|
4211
|
+
(row, { highlighted }) => {
|
|
4548
4212
|
if (row.type === "day") return /* @__PURE__ */ jsx(DaySeparator, { label: row.label, testID: `${testID}-day-${row.key}` });
|
|
4549
4213
|
if (row.type === "unread") return /* @__PURE__ */ jsx(UnreadDivider, { label: copy.newMessages, testID: `${testID}-unread` });
|
|
4550
4214
|
const m = row.item.type === "message" ? row.item.message : null;
|
|
@@ -4567,7 +4231,7 @@ function ChatThreadScreen(props) {
|
|
|
4567
4231
|
onToggleReaction: allowed ? react : void 0,
|
|
4568
4232
|
onOpenImage,
|
|
4569
4233
|
observer,
|
|
4570
|
-
highlighted
|
|
4234
|
+
highlighted,
|
|
4571
4235
|
linkPreview: m ? previewToShow(previews[m.id]) : null,
|
|
4572
4236
|
linkPreviewImages,
|
|
4573
4237
|
attachmentKinds,
|
|
@@ -4578,7 +4242,7 @@ function ChatThreadScreen(props) {
|
|
|
4578
4242
|
}
|
|
4579
4243
|
);
|
|
4580
4244
|
},
|
|
4581
|
-
[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
|
|
4245
|
+
[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]
|
|
4582
4246
|
);
|
|
4583
4247
|
const [videoOpen, setVideoOpen] = useState(false);
|
|
4584
4248
|
const preparedVideo = useRef(null);
|
|
@@ -4602,10 +4266,9 @@ function ChatThreadScreen(props) {
|
|
|
4602
4266
|
(video) => {
|
|
4603
4267
|
videoUploads.start({ conversationId, userId, video, extra: { replyToId: replyNow, threadRootId }, send: outbox.send, videoUpload, prepared: takePrepared(), openFile: modules.openFile });
|
|
4604
4268
|
if (replyNow) setReply(null);
|
|
4605
|
-
|
|
4606
|
-
toBottom(true);
|
|
4269
|
+
toNewest();
|
|
4607
4270
|
},
|
|
4608
|
-
[conversationId, userId, replyNow, threadRootId, outbox, videoUpload, takePrepared, modules.openFile, setReply,
|
|
4271
|
+
[conversationId, userId, replyNow, threadRootId, outbox, videoUpload, takePrepared, modules.openFile, setReply, toNewest]
|
|
4609
4272
|
);
|
|
4610
4273
|
const activity = activityLine(conv.activity, (id) => nameOf(id));
|
|
4611
4274
|
const topics = topicsState.topics;
|
|
@@ -4623,57 +4286,35 @@ function ChatThreadScreen(props) {
|
|
|
4623
4286
|
setRetryingAccess(true);
|
|
4624
4287
|
void Promise.resolve(refetchAccess()).finally(() => setRetryingAccess(false));
|
|
4625
4288
|
}, [refetchAccess]);
|
|
4626
|
-
const
|
|
4289
|
+
const keyboardModule = modules.keyboardAvoidingView ?? genesis.keyboardAvoidingView;
|
|
4290
|
+
const KeyboardAvoiding = keyboardModule ?? KeyboardAvoidingView;
|
|
4627
4291
|
const offset = keyboardVerticalOffset ?? measuredTop;
|
|
4628
|
-
const keyboardProps =
|
|
4629
|
-
const empty = !conv.isLoading && rows.length === 0;
|
|
4292
|
+
const keyboardProps = keyboardModule ? { behavior: "translate-with-padding", keyboardVerticalOffset: offset } : { behavior: Platform.OS === "ios" ? "padding" : void 0, keyboardVerticalOffset: offset };
|
|
4630
4293
|
return /* @__PURE__ */ jsx(ChatPeopleScope, { userIds: peopleIds, children: /* @__PURE__ */ jsxs(SafeAreaView, { ref: rootRef, onLayout: measureTop, testID, edges: ["left", "right", "bottom"], style: { flex: 1, backgroundColor: colors.groupedBackground }, children: [
|
|
4631
4294
|
/* @__PURE__ */ jsxs(KeyboardAvoiding, { style: { flex: 1 }, ...keyboardProps, children: [
|
|
4632
4295
|
showTopicBar ? /* @__PURE__ */ jsx(ChatTopicBar, { topics, value: topic ?? null, onValueChange: setChosenTopic, canManage: canManageTopics(conv.role), onSetTopic: topicsState.setTopic, testID: `${testID}-topics` }) : null,
|
|
4633
4296
|
/* @__PURE__ */ jsx(ChatAwayLine, { text: awayLine, testID: `${testID}-away` }),
|
|
4634
|
-
/* @__PURE__ */ jsx(View, { style: { flex: 1 }, children:
|
|
4635
|
-
|
|
4297
|
+
/* @__PURE__ */ jsx(View, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
|
|
4298
|
+
NativeThreadList,
|
|
4636
4299
|
{
|
|
4637
4300
|
ref: listRef,
|
|
4638
4301
|
testID: `${testID}-list`,
|
|
4639
4302
|
data: rows,
|
|
4303
|
+
keyExtractor: threadRowKey,
|
|
4304
|
+
jumpId: threadRowMessageId,
|
|
4305
|
+
getItemType: threadRowType,
|
|
4640
4306
|
renderItem,
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
onScrollToIndexFailed: ({ index: index2, averageItemLength }) => {
|
|
4653
|
-
listRef.current?.scrollToOffset?.({ offset: Math.max(0, index2 * averageItemLength - 200), animated: false });
|
|
4654
|
-
const target = jumpingTo.current;
|
|
4655
|
-
if (!target || target.tries >= 3) return;
|
|
4656
|
-
target.tries += 1;
|
|
4657
|
-
if (retryTimer.current) clearTimeout(retryTimer.current);
|
|
4658
|
-
retryTimer.current = setTimeout(() => {
|
|
4659
|
-
const at = rowIndexOf(rowsNow.current, target.id);
|
|
4660
|
-
if (at >= 0) listRef.current?.scrollToIndex?.({ index: at, animated: !reducedMotion, viewPosition: 0.5 });
|
|
4661
|
-
}, 250);
|
|
4662
|
-
},
|
|
4663
|
-
...mode.followsByHand ? {
|
|
4664
|
-
scrollEventThrottle: 32,
|
|
4665
|
-
onScroll: (e) => {
|
|
4666
|
-
atBottom.current = nearBottom(e.nativeEvent);
|
|
4667
|
-
},
|
|
4668
|
-
onContentSizeChange: () => {
|
|
4669
|
-
if (atBottom.current) toBottom(false);
|
|
4670
|
-
},
|
|
4671
|
-
onLayout: () => {
|
|
4672
|
-
if (atBottom.current) toBottom(false);
|
|
4673
|
-
}
|
|
4674
|
-
} : {},
|
|
4675
|
-
ListHeaderComponent: conv.hasEarlier ? /* @__PURE__ */ jsx(EarlierAnchor, { loading: conv.loadingEarlier, label: copy.loadEarlier, onPress: () => void conv.loadEarlier(), testID: `${testID}-earlier` }) : null,
|
|
4676
|
-
ListFooterComponent: activity ? /* @__PURE__ */ jsx(ActivityLine, { text: activity, testID: `${testID}-activity` }) : null
|
|
4307
|
+
loading: conv.isLoading,
|
|
4308
|
+
hasEarlier: conv.hasEarlier,
|
|
4309
|
+
onLoadEarlier: () => void conv.loadEarlier(),
|
|
4310
|
+
loadingEarlier: conv.loadingEarlier,
|
|
4311
|
+
earlierLabel: copy.loadEarlier,
|
|
4312
|
+
jumpTo: jumpMessageId,
|
|
4313
|
+
onLoadUntil,
|
|
4314
|
+
jumpAnnouncement,
|
|
4315
|
+
onJumpFailed,
|
|
4316
|
+
footer: activity ? /* @__PURE__ */ jsx(ActivityLine, { text: activity, testID: `${testID}-activity` }) : null,
|
|
4317
|
+
empty: /* @__PURE__ */ jsx(NativeEmptyState, { variant: "first-run", title: copy.threadEmptyTitle, body: currentTopic?.closedAt ? copy.topicClosedNotice : copy.threadEmptyBody, testID: `${testID}-empty` })
|
|
4677
4318
|
}
|
|
4678
4319
|
) }),
|
|
4679
4320
|
scheduling && !threadRootId ? /* @__PURE__ */ jsx(ChatScheduledBar, { conversationId, testID: `${testID}-scheduled` }) : null,
|
|
@@ -4690,8 +4331,7 @@ function ChatThreadScreen(props) {
|
|
|
4690
4331
|
role: conv.role,
|
|
4691
4332
|
onSend: ({ input, files }) => {
|
|
4692
4333
|
void conv.send(input, files).catch(fail);
|
|
4693
|
-
|
|
4694
|
-
toBottom(true);
|
|
4334
|
+
toNewest();
|
|
4695
4335
|
},
|
|
4696
4336
|
signalTyping: conv.signalTyping,
|
|
4697
4337
|
signalRecording: conv.signalRecording,
|
|
@@ -4744,20 +4384,9 @@ function ActivityLine({ text, testID }) {
|
|
|
4744
4384
|
const colors = useThemeRoles();
|
|
4745
4385
|
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 }) });
|
|
4746
4386
|
}
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
/* @__PURE__ */ jsx(NativeSkeleton, { width: 180, height: 14 }),
|
|
4751
|
-
/* @__PURE__ */ jsx(NativeSkeleton, { width: 120, height: 14 })
|
|
4752
|
-
] }) : /* @__PURE__ */ jsx(Pressable, { testID, accessibilityRole: "button", accessibilityLabel: label, onPress, style: { minHeight: 44, justifyContent: "center", paddingHorizontal: 16 }, children: /* @__PURE__ */ jsx(NativeText, { preset: "label", style: { color: colors.tint }, children: label }) }) });
|
|
4753
|
-
}
|
|
4754
|
-
function LoadingThread({ testID }) {
|
|
4755
|
-
return /* @__PURE__ */ jsxs(View, { testID, style: { flex: 1, justifyContent: "flex-end", padding: 16, gap: 10 }, children: [
|
|
4756
|
-
/* @__PURE__ */ jsx(NativeSkeleton, { width: 200, height: 36, className: "rounded-2xl" }),
|
|
4757
|
-
/* @__PURE__ */ jsx(View, { style: { alignItems: "flex-end" }, children: /* @__PURE__ */ jsx(NativeSkeleton, { width: 160, height: 36, className: "rounded-2xl" }) }),
|
|
4758
|
-
/* @__PURE__ */ jsx(NativeSkeleton, { width: 240, height: 36, className: "rounded-2xl" })
|
|
4759
|
-
] });
|
|
4760
|
-
}
|
|
4387
|
+
var threadRowKey = (row) => row.key;
|
|
4388
|
+
var threadRowMessageId = (row) => row.type === "message" && row.item.type === "message" ? row.item.message.id : null;
|
|
4389
|
+
var threadRowType = (row) => row.type === "message" ? row.mine ? "mine" : "theirs" : row.type;
|
|
4761
4390
|
function chatThreadStackOptions(props, background) {
|
|
4762
4391
|
return getThreadPageStackOptions({
|
|
4763
4392
|
...props,
|
|
@@ -5258,6 +4887,55 @@ function HitRow({ testID, accessibilityLabel, onPress, children }) {
|
|
|
5258
4887
|
}
|
|
5259
4888
|
);
|
|
5260
4889
|
}
|
|
4890
|
+
function rowIndexOf(rows, messageId) {
|
|
4891
|
+
return rows.findIndex((r) => r.type === "message" && r.item.type === "message" && r.item.message.id === messageId);
|
|
4892
|
+
}
|
|
4893
|
+
function useJumpToMessage({ target, rows, loading, has, loadUntil, scrollTo, onStart, onLanded, onGone, onError }) {
|
|
4894
|
+
const [pending, setPending] = useState(target ? { ...target, phase: "new" } : null);
|
|
4895
|
+
const [highlightedId, setHighlightedId] = useState(null);
|
|
4896
|
+
useEffect(() => {
|
|
4897
|
+
if (target) setPending({ ...target, phase: "new" });
|
|
4898
|
+
}, [target?.messageId, target?.seq]);
|
|
4899
|
+
const latest = useRef({ rows, scrollTo, onStart, onLanded, onGone, onError });
|
|
4900
|
+
latest.current = { rows, scrollTo, onStart, onLanded, onGone, onError };
|
|
4901
|
+
const timer = useRef(null);
|
|
4902
|
+
useEffect(() => () => {
|
|
4903
|
+
if (timer.current) clearTimeout(timer.current);
|
|
4904
|
+
}, []);
|
|
4905
|
+
const go = useCallback((messageId) => {
|
|
4906
|
+
const index2 = rowIndexOf(latest.current.rows, messageId);
|
|
4907
|
+
if (index2 < 0) return;
|
|
4908
|
+
latest.current.onStart?.();
|
|
4909
|
+
latest.current.scrollTo(index2, messageId);
|
|
4910
|
+
latest.current.onLanded?.(messageId);
|
|
4911
|
+
setHighlightedId(messageId);
|
|
4912
|
+
if (timer.current) clearTimeout(timer.current);
|
|
4913
|
+
timer.current = setTimeout(() => setHighlightedId((h) => h === messageId ? null : h), 2e3);
|
|
4914
|
+
}, []);
|
|
4915
|
+
useEffect(() => {
|
|
4916
|
+
if (!pending || loading) return;
|
|
4917
|
+
const { messageId, seq: seq2, phase } = pending;
|
|
4918
|
+
if (has(messageId)) {
|
|
4919
|
+
setPending(null);
|
|
4920
|
+
go(messageId);
|
|
4921
|
+
return;
|
|
4922
|
+
}
|
|
4923
|
+
if (phase === "loading") return;
|
|
4924
|
+
if (phase === "loaded" || seq2 == null) {
|
|
4925
|
+
setPending(null);
|
|
4926
|
+
latest.current.onGone();
|
|
4927
|
+
return;
|
|
4928
|
+
}
|
|
4929
|
+
latest.current.onStart?.();
|
|
4930
|
+
setPending({ messageId, seq: seq2, phase: "loading" });
|
|
4931
|
+
const settle = () => setPending((p) => p && p.messageId === messageId ? { ...p, phase: "loaded" } : p);
|
|
4932
|
+
void loadUntil(seq2).then(settle, (e) => {
|
|
4933
|
+
latest.current.onError(e);
|
|
4934
|
+
settle();
|
|
4935
|
+
});
|
|
4936
|
+
}, [pending, loading, has, loadUntil, go]);
|
|
4937
|
+
return { highlightedId, jumping: pending !== null };
|
|
4938
|
+
}
|
|
5261
4939
|
|
|
5262
4940
|
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 };
|
|
5263
4941
|
//# sourceMappingURL=native.js.map
|