@robono/messaging-react-native 0.23.0 → 0.25.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/CHANGELOG.md +27 -0
- package/README.md +157 -4
- package/RobonoMessagingRuntime.podspec +16 -0
- package/SBOM.spdx.json +2709 -813
- package/android/build.gradle +10 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/robono/messaging/RobonoBackupCrypto.java +27 -0
- package/android/src/main/java/com/robono/messaging/RobonoBackupGoogle.java +76 -0
- package/android/src/main/java/com/robono/messaging/RobonoHistoryStore.java +173 -0
- package/android/src/main/java/com/robono/messaging/RobonoMessagingPackage.java +11 -0
- package/app.plugin.cjs +22 -3
- package/cloudkit/backup-schema.ckdb +13 -0
- package/dist/account-pages.d.ts +51 -0
- package/dist/account-pages.js +65 -0
- package/dist/account.d.ts +6 -2
- package/dist/account.js +37 -11
- package/dist/attachment-preview.d.ts +11 -10
- package/dist/attachment-preview.js +15 -12
- package/dist/backup-background.d.ts +25 -0
- package/dist/backup-background.js +71 -0
- package/dist/backup-base64.d.ts +3 -0
- package/dist/backup-base64.js +41 -0
- package/dist/backup-google-authorization.d.ts +23 -0
- package/dist/backup-google-authorization.js +95 -0
- package/dist/backup.d.ts +24 -0
- package/dist/backup.js +202 -0
- package/dist/brand.js +4 -4
- package/dist/bubble-design.d.ts +1 -1
- package/dist/bubble-design.js +5 -3
- package/dist/cloudkit-backup.d.ts +14 -0
- package/dist/cloudkit-backup.js +193 -0
- package/dist/contact-directory.d.ts +3 -1
- package/dist/contact-directory.js +3 -3
- package/dist/conversation-details.js +2 -2
- package/dist/customization.d.ts +1 -0
- package/dist/delivery-bar.d.ts +3 -2
- package/dist/delivery-bar.js +7 -4
- package/dist/delivery-notice.d.ts +9 -0
- package/dist/delivery-notice.js +15 -0
- package/dist/directory-navigation.d.ts +25 -0
- package/dist/directory-navigation.js +69 -0
- package/dist/expo-backup-background.d.ts +17 -0
- package/dist/expo-backup-background.js +57 -0
- package/dist/expo-backup-cloudkit.d.ts +6 -0
- package/dist/expo-backup-cloudkit.js +11 -0
- package/dist/expo-backup-crypto.d.ts +3 -0
- package/dist/expo-backup-crypto.js +17 -0
- package/dist/expo-backup-google.d.ts +7 -0
- package/dist/expo-backup-google.js +16 -0
- package/dist/expo-backup-network.d.ts +8 -0
- package/dist/expo-backup-network.js +18 -0
- package/dist/expo-backup-passkeys.d.ts +14 -0
- package/dist/expo-backup-passkeys.js +46 -0
- package/dist/expo-backup-settings.d.ts +4 -0
- package/dist/expo-backup-settings.js +59 -0
- package/dist/expo-backup.d.ts +14 -0
- package/dist/expo-backup.js +22 -0
- package/dist/expo-bridge.d.ts +2 -0
- package/dist/expo-bridge.js +3 -1
- package/dist/expo-cache.js +20 -1
- package/dist/expo-device-history.d.ts +24 -0
- package/dist/expo-device-history.js +88 -0
- package/dist/expo-durable-history.d.ts +26 -0
- package/dist/expo-durable-history.js +56 -0
- package/dist/expo-history-backup.d.ts +3 -0
- package/dist/expo-history-backup.js +79 -0
- package/dist/expo-history-maintenance.d.ts +4 -0
- package/dist/expo-history-maintenance.js +23 -0
- package/dist/expo-history-previews.d.ts +5 -0
- package/dist/expo-history-previews.js +57 -0
- package/dist/expo-history.d.ts +1 -1
- package/dist/expo-history.js +2 -2
- package/dist/expo-inbox-preferences.d.ts +3 -0
- package/dist/expo-inbox-preferences.js +9 -0
- package/dist/expo-media.d.ts +2 -0
- package/dist/expo-media.js +18 -24
- package/dist/expo-messenger.d.ts +8 -0
- package/dist/expo-messenger.js +27 -11
- package/dist/expo-notifications.d.ts +17 -1
- package/dist/expo-notifications.js +36 -16
- package/dist/expo-outbox.d.ts +2 -0
- package/dist/expo-outbox.js +1 -1
- package/dist/expo-oversight.d.ts +15 -0
- package/dist/expo-oversight.js +15 -0
- package/dist/expo-reviews.d.ts +6 -0
- package/dist/expo-reviews.js +145 -0
- package/dist/expo-screen.js +62 -28
- package/dist/expo-thumbnails.d.ts +6 -2
- package/dist/expo-thumbnails.js +73 -8
- package/dist/expo.d.ts +14 -0
- package/dist/expo.js +12 -0
- package/dist/forward.js +2 -2
- package/dist/header-calls.js +1 -1
- package/dist/header-colors.d.ts +5 -0
- package/dist/header-colors.js +7 -0
- package/dist/inbox-search.d.ts +1 -1
- package/dist/inbox-search.js +7 -3
- package/dist/inbox.d.ts +6 -2
- package/dist/inbox.js +27 -55
- package/dist/index.d.ts +14 -6
- package/dist/index.js +195 -78
- package/dist/linked-apps.d.ts +45 -0
- package/dist/linked-apps.js +40 -0
- package/dist/loading-messages.d.ts +5 -0
- package/dist/loading-messages.js +10 -0
- package/dist/media-access.d.ts +8 -0
- package/dist/media-access.js +6 -1
- package/dist/media-controller.d.ts +2 -0
- package/dist/native-history-authorization.d.ts +4 -0
- package/dist/native-history-authorization.js +69 -0
- package/dist/native-history-backup.d.ts +16 -0
- package/dist/native-history-backup.js +144 -0
- package/dist/native-history.d.ts +14 -0
- package/dist/native-history.js +186 -0
- package/dist/native-outbox.d.ts +2 -0
- package/dist/oversight-session.d.ts +4 -0
- package/dist/oversight-session.js +14 -0
- package/dist/popup.d.ts +6 -3
- package/dist/popup.js +6 -6
- package/dist/preview-layout.d.ts +12 -0
- package/dist/preview-layout.js +102 -0
- package/dist/recent-media.js +2 -1
- package/dist/reviews.d.ts +19 -0
- package/dist/reviews.js +231 -0
- package/dist/scheduled.js +6 -6
- package/dist/search.js +18 -8
- package/ios/RobonoBackupCloudKit.m +96 -0
- package/ios/RobonoBackupCrypto.m +30 -0
- package/ios/RobonoHistoryStore.m +170 -0
- package/package.json +34 -7
- package/plugin/backup-expiration.cjs +23 -0
- package/plugin/prepare-native.cjs +12 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
export { MessagingLinkedAppsScreen } from './linked-apps.js';
|
|
3
|
+
import { MessagingAccountPageScreen, messagingAccountPages, messagingAccountPageLabels } from './account-pages.js';
|
|
4
|
+
export { messagingLanguages } from './account-pages.js';
|
|
5
|
+
import { deliveryNotice } from './delivery-notice.js';
|
|
6
|
+
import { messagingHeaderColors } from './header-colors.js';
|
|
7
|
+
import { MessagingLoadingMessages } from './loading-messages.js';
|
|
8
|
+
export { messagingHeaderColors } from './header-colors.js';
|
|
9
|
+
export { MessagingReviewInbox } from './reviews.js';
|
|
10
|
+
import { messageParts, selectMessagePart, composeMessageItems } from '@robono/messaging';
|
|
2
11
|
import { DeliveryBar } from './delivery-bar.js';
|
|
3
12
|
import { bubbleCorners, bubbleDelivery } from './bubble-design.js';
|
|
4
13
|
import { compareMessageOrder, isMessageIdentity } from '@robono/messaging';
|
|
@@ -11,6 +20,7 @@ import { MessagingKeyboardContainer } from './keyboard-container.js';
|
|
|
11
20
|
import { conversationMessages } from '@robono/messaging';
|
|
12
21
|
import { ConversationSelector } from './conversation-selector.js';
|
|
13
22
|
import { useAttachmentPreview } from './attachment-preview.js';
|
|
23
|
+
import { readPreviewSize, rememberPreviewSize } from './preview-layout.js';
|
|
14
24
|
import { MessagingRoomModeration, MessagingRoomRemoval } from './room-moderation.js';
|
|
15
25
|
export { MessagingConnectionState, MessagingSignIn, MessagingPhoneInput, MessagingChoicePicker } from './sign-in.js';
|
|
16
26
|
import { CustomMessage } from './custom-message.js';
|
|
@@ -30,7 +40,7 @@ import { MessageMenu, MessageMenuRow, messageMenuPosition } from './message-menu
|
|
|
30
40
|
import { TranslationSettings } from './translation-settings.js';
|
|
31
41
|
import { AttachmentMenu } from './attachment-menu.js';
|
|
32
42
|
import { QuickSendButton } from './quick-send.js';
|
|
33
|
-
import { MessageExtra, MessagingPrivacyLayer, privacyReadingStripHeight, openChatAddress
|
|
43
|
+
import { MessageExtra, MessagingPrivacyLayer, privacyReadingStripHeight, openChatAddress } from './extras.js';
|
|
34
44
|
export { MessagingPrivacyLayer } from './extras.js';
|
|
35
45
|
import { orderChatMessages } from './message-order.js';
|
|
36
46
|
import { MessagingPopup, MessagingPopupHost, MessagingPopupHeaderBoundary, useMessagingPopupColors } from './popup.js';
|
|
@@ -44,8 +54,8 @@ import { MessagingSafety } from './safety.js';
|
|
|
44
54
|
export { MessagingSafety } from './safety.js';
|
|
45
55
|
import { PollMessage, PollComposer } from "./polls.js";
|
|
46
56
|
export { PollMessage, PollComposer } from "./polls.js";
|
|
47
|
-
import React, { createContext, useContext, useMemo, useCallback, useEffect, useRef, useState, useSyncExternalStore, } from "react";
|
|
48
|
-
import { Animated, ActivityIndicator, AppState, BackHandler, FlatList, Image, Keyboard, Linking, Platform, Pressable, ScrollView,
|
|
57
|
+
import React, { createContext, useContext, useMemo, useCallback, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore, } from "react";
|
|
58
|
+
import { Animated, ActivityIndicator, AppState, BackHandler, FlatList, Image, Keyboard, Linking, Platform, Pressable, ScrollView, View, useWindowDimensions, } from "react-native";
|
|
49
59
|
import { useQuoteGesture, messageInfoRevealWidth, messageReplyRevealWidth } from "./use-quote-gesture.js";
|
|
50
60
|
import { MessageIcon, duration, fileSize, chatSurface, composerSurface } from "./icons.js";
|
|
51
61
|
import { VoiceMessageComposer } from "./voice-composer.js";
|
|
@@ -165,7 +175,7 @@ function MessagingProviderContent({ children, ...props }) {
|
|
|
165
175
|
setForwarding([m]);
|
|
166
176
|
else
|
|
167
177
|
setDeleting([m]); }, [props.requestedMessageAction]);
|
|
168
|
-
const effectiveAppearance = props.appearance ?? state.settings?.appearance ?? defaultMessagingSettings().appearance;
|
|
178
|
+
const effectiveAppearance = props.appearance ?? state.settings?.appearance ?? props.initialAppearance ?? defaultMessagingSettings().appearance;
|
|
169
179
|
const styleScreen = state.conversation?.kind === 'group' ? (state.conversation.supergroup ? 'supergroupChat' : 'groupChat') : 'chat';
|
|
170
180
|
const design = useMemo(() => localizeMessagingAppearance(messagingScreenAppearance(effectiveAppearance, styleScreen), uiText), [effectiveAppearance, styleScreen, uiText]);
|
|
171
181
|
const messagingPopupColors = useMessagingPopupColors(design);
|
|
@@ -268,28 +278,26 @@ export function GroupDiscussion({ threadRoot, onClose }) {
|
|
|
268
278
|
context.setReply({ ...message, threadRoot: message.id }); }).catch(() => { }); }; setVisible(false); };
|
|
269
279
|
const rows = root ? [root, ...messages.filter(m => m.id !== root.id)] : messages;
|
|
270
280
|
return _jsxs(MessagingPopup, { screen: threadRoot ? 'replies' : 'pins', visible: visible, onDismiss: dismiss, title: threadRoot ? uiText("Replies") : uiText("Pinned messages"), onClose: () => setVisible(false), background: messagingPopupColors.background, children: [_jsx(Context.Provider, { value: { ...context, discussionPreview: true, discussionRoot: threadRoot, state: { ...state, messages: rows }, setReply: message => { if (message)
|
|
271
|
-
open(root ?? message, true); }, openAttachment: context.openAttachment ? async (message) => { pending.current = () => { void context.openAttachment(message).catch(() => { }); }; setVisible(false); } : undefined }, children: _jsx(FlatList, { data: rows, keyExtractor: m => m.id, style: { flex: 1 }, contentContainerStyle: { paddingVertical: 12, gap: 10 }, ListHeaderComponent: next ? _jsx(Pressable, { accessibilityRole: "button", disabled: busy, onPress: () => void load(true), style: { minHeight: 44, justifyContent: 'center', alignItems: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Earlier replies") }) }) : null, renderItem: ({ item, index }) => _jsxs(View, { children: [root && index === 0 && _jsx(Text, { style: { color: messagingPopupColors.secondary, marginBottom: 8 }, children: uiText("Original message") }), _jsx(MessagingBubble, { message: item }), !threadRoot && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Go to pinned message"), onPress: () => open(item), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Go to message") }) })] }), ListEmptyComponent: !busy && !error ? _jsx(Text, { style: { color: messagingPopupColors.secondary, textAlign: 'center', padding: 20 }, children: uiText("No pinned messages.") }) : null }) }), busy && _jsx(ActivityIndicator, { color: design.colors.accent }), !!error && _jsxs(View, { children: [_jsx(Text, { accessibilityRole: "alert", style: { color: messagingPopupColors.foreground }, children: error }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => void load(), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Try again") }) })] }), root && state.conversation?.canSend !== false && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Reply in conversation"), onPress: () => open(root, true), style: { minHeight: 48, alignItems: 'center', justifyContent: 'center', borderTopWidth: 1, borderTopColor: '#ffffff20' }, children: _jsx(Text, { style: { color: design.colors.accent, fontSize: 16, fontWeight: '600' }, children: uiText("Reply") }) })] });
|
|
272
|
-
}
|
|
273
|
-
export function messagingHeaderColors(design, group) {
|
|
274
|
-
const screen = design.screens?.chat;
|
|
275
|
-
const background = group ? (screen?.groupHeaderBackground ?? '#1F5F7A') : (screen?.headerBackground ?? design.colors.accent);
|
|
276
|
-
const rgb = background.slice(1).match(/.{2}/g)?.map(v => parseInt(v, 16)) ?? [0, 0, 0];
|
|
277
|
-
const foreground = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000 > 150 ? '#050505' : '#F7F7F7';
|
|
278
|
-
return { background, foreground: (group ? screen?.groupHeaderText : screen?.headerText) ?? foreground };
|
|
281
|
+
open(root ?? message, true); }, openAttachment: context.openAttachment ? async (message) => { pending.current = () => { void context.openAttachment(message).catch(() => { }); }; setVisible(false); } : undefined }, children: _jsx(FlatList, { data: rows, keyExtractor: m => m.id, style: { flex: 1 }, contentContainerStyle: { paddingVertical: 12, gap: 10 }, ListHeaderComponent: next ? _jsx(Pressable, { accessibilityRole: "button", disabled: busy, onPress: () => void load(true), style: { minHeight: 44, justifyContent: 'center', alignItems: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Earlier replies") }) }) : null, renderItem: ({ item, index }) => _jsxs(View, { children: [root && index === 0 && _jsx(Text, { style: { color: messagingPopupColors.secondary, marginBottom: 8 }, children: uiText("Original message") }), _jsx(MessagingBubble, { message: item }), !threadRoot && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Go to pinned message"), onPress: () => open(item), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Go to message") }) })] }), ListEmptyComponent: !busy && !error ? _jsx(Text, { style: { color: messagingPopupColors.secondary, textAlign: 'center', padding: 20 }, children: uiText("No pinned messages.") }) : null }) }), busy && _jsx(View, { pointerEvents: "none", style: { position: 'absolute', top: 0, left: 0, right: 0, height: 48, alignItems: 'center', justifyContent: 'center' }, children: _jsx(ActivityIndicator, { color: design.colors.accent }) }), !!error && _jsxs(View, { children: [_jsx(Text, { accessibilityRole: "alert", style: { color: messagingPopupColors.foreground }, children: error }), _jsx(Pressable, { accessibilityRole: "button", onPress: () => void load(), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Try again") }) })] }), root && state.conversation?.canSend !== false && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Reply in conversation"), onPress: () => open(root, true), style: { minHeight: 48, alignItems: 'center', justifyContent: 'center', borderTopWidth: 1, borderTopColor: '#ffffff20' }, children: _jsx(Text, { style: { color: design.colors.accent, fontSize: 16, fontWeight: '600' }, children: uiText("Reply") }) })] });
|
|
279
282
|
}
|
|
280
283
|
function MessagingActivity({ ink }) {
|
|
281
284
|
const { text: uiText, count: uiCount, locale: uiLocale } = useRobonoLocale();
|
|
282
|
-
const { state, design, participants } = useMessagingUI(), [now, setNow] = useState(Date.now());
|
|
285
|
+
const { state, design, participants, contact, companyName } = useMessagingUI(), [now, setNow] = useState(Date.now());
|
|
283
286
|
useEffect(() => { setNow(Date.now()); if (!state.presence?.peers.length)
|
|
284
287
|
return; const timer = setInterval(() => setNow(Date.now()), 1000); return () => clearInterval(timer); }, [state.presence]);
|
|
285
288
|
const typing = state.settings?.features.typing ? state.presence?.peers.filter(peer => peer.typingUntil > now) ?? [] : [];
|
|
286
289
|
const online = state.settings?.features.online && state.presence?.peers.some(peer => peer.onlineUntil > now);
|
|
287
290
|
const group = state.conversation?.kind === 'group';
|
|
291
|
+
const network = group ? '' : contact.networkName?.trim() || companyName?.trim() || design.name;
|
|
292
|
+
const showActivity = design.screens?.chat?.showActivity !== false;
|
|
288
293
|
const lastSeen = state.settings?.features.lastSeen ? state.presence?.peers.find(peer => Number.isFinite(peer.lastSeenAt) && peer.lastSeenAt > 0)?.lastSeenAt : null;
|
|
289
294
|
const lastSeenLabel = lastSeen ? new Date(lastSeen).toLocaleString(uiLocale, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : '';
|
|
290
295
|
const names = typing.map(peer => participants?.[peer.userId]?.name ?? uiText('Someone'));
|
|
296
|
+
// Connection recovery uses the existing activity slot, never a new chat row.
|
|
297
|
+
if (showActivity && (state.connection === 'reconnecting' || state.offline?.refreshing) && !state.error)
|
|
298
|
+
return _jsxs(View, { testID: "messaging-chat-activity", accessibilityLabel: uiText("Waiting for connection"), accessibilityState: { busy: true }, ...(Platform.OS === 'web' ? { 'aria-busy': true } : {}), accessibilityLiveRegion: "polite", style: { height: 18, flexDirection: 'row', gap: 6, alignItems: 'center' }, children: [!!network && _jsx(Text, { numberOfLines: 1, style: { color: ink, opacity: .8, fontSize: 14, lineHeight: 18, flexShrink: 1 }, children: network }), _jsx(ActivityIndicator, { size: "small", color: ink, style: { width: 16, height: 16, transform: [{ scale: .75 }] } })] });
|
|
291
299
|
const text = typing.length ? (group ? (typing.length > 2 ? uiText('Several people are typing…') : typing.length === 2 ? uiText('{first} and {second} are typing…', { first: names[0], second: names[1] }) : uiText('{name} is typing…', { name: names[0] })) : uiText('Typing…')) : !group && online ? uiText('Online now') : !group && lastSeenLabel ? uiText('Last seen {time}', { time: lastSeenLabel }) : group ? uiCount(state.conversation?.memberCount ?? state.conversation?.memberIds?.length ?? 0, '{count} member', '{count} members') : '';
|
|
292
|
-
return
|
|
300
|
+
return _jsx(Text, { testID: "messaging-chat-activity", numberOfLines: 1, style: { color: ink, opacity: .8, fontSize: 14, lineHeight: 18, minHeight: 18 }, children: [network, showActivity ? text : ''].filter(Boolean).join(' · ') || " " });
|
|
293
301
|
}
|
|
294
302
|
export function MessagingHeader({ children } = {}) {
|
|
295
303
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
@@ -307,9 +315,9 @@ export function MessagingHeader({ children } = {}) {
|
|
|
307
315
|
alignItems: "center",
|
|
308
316
|
paddingHorizontal: 12,
|
|
309
317
|
paddingVertical: 4,
|
|
310
|
-
minHeight: chatDesign?.headerSize === 'roomy' ? 72 : chatDesign?.headerSize === 'compact' ? 44 :
|
|
318
|
+
minHeight: Math.max(chatDesign?.headerSize === 'roomy' ? 72 : chatDesign?.headerSize === 'compact' ? 44 : 52, Math.max(44, design.showAvatars ? (chatDesign?.avatarSize ?? 38) : 0, Math.ceil((chatDesign?.titleSize ?? 18) * 1.25) + 18) + (headerOptions?.paddingTop ?? 4) + (headerOptions?.paddingBottom ?? 4)), paddingTop: headerOptions?.paddingTop ?? 4, paddingBottom: headerOptions?.paddingBottom ?? 4, paddingStart: headerOptions?.paddingStart ?? 12, paddingEnd: headerOptions?.paddingEnd ?? 12,
|
|
311
319
|
backgroundColor: header.background,
|
|
312
|
-
gap:
|
|
320
|
+
gap: 0,
|
|
313
321
|
}, children: [(onBack || selection.length > 0) && (_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: selection.length ? uiText("Clear message selection") : uiText("Back"), onPress: () => selection.length ? setSelection([]) : onBack?.(), style: { width: 44, flexShrink: 0, alignSelf: "stretch", marginStart: -12, marginEnd: -4, marginVertical: -4, alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: "back", color: header.foreground, size: 32 }) })), _jsxs(Pressable, { onPress: headerOptions?.onProfile, disabled: !headerOptions?.onProfile, accessibilityRole: headerOptions?.onProfile ? "button" : undefined, accessibilityLabel: headerOptions?.onProfile ? uiText("View profile") : undefined, testID: "messaging-chat-identity", style: { flex: 1, minWidth: 0, flexDirection: "row", alignItems: "center", gap: 8 }, children: [design.showAvatars && (contact.avatarUrl
|
|
314
322
|
? (_jsx(Image, { source: { uri: contact.avatarUrl }, style: { ...avatar, borderWidth: 1, borderColor: "#ffffff" } }))
|
|
315
323
|
: (_jsx(View, { style: {
|
|
@@ -319,16 +327,7 @@ export function MessagingHeader({ children } = {}) {
|
|
|
319
327
|
backgroundColor: c.incoming,
|
|
320
328
|
alignItems: "center",
|
|
321
329
|
justifyContent: "center",
|
|
322
|
-
}, children: _jsx(Text, { style: { color: c.incomingText }, children: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Group').slice(0, 1) : contact.name.slice(0, 1) }) }))), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: header.foreground, fontSize: chatDesign?.titleSize ?? 18, textAlign: chatDesign?.titleAlign ?? 'left', fontWeight: "800" }, children: state.conversation?.kind === 'group' ? state.conversation.name : contact.name }),
|
|
323
|
-
}
|
|
324
|
-
function PrivacyControl({ color }) {
|
|
325
|
-
const messagingPopupColors = useMessagingPopupColors();
|
|
326
|
-
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
327
|
-
const { extras, extrasState, design } = useMessagingUI();
|
|
328
|
-
const [error, setError] = useState(''), [busy, setBusy] = useState(false);
|
|
329
|
-
if (!extras || !extrasState || !extrasState.available.privacyLens && !extrasState.privacyLens)
|
|
330
|
-
return null;
|
|
331
|
-
return _jsxs(_Fragment, { children: [_jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: extrasState.privacyLens ? uiText("Turn off Privacy Lens") : uiText("Turn on Privacy Lens"), disabled: busy, onPress: () => { setBusy(true); void extras.setPrivacy(!extrasState.privacyLens).catch(() => setError(uiText("Privacy Lens could not change. Try again."))).finally(() => setBusy(false)); }, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: extrasState.privacyLens ? "eye-off" : "eye", color: color, size: 23 }) }), !!error && _jsx(ExtraPopup, { title: uiText("Privacy Lens"), background: design.colors.background, foreground: design.colors.foreground, onClose: () => setError(''), children: _jsx(Text, { style: { color: messagingPopupColors.foreground }, children: error }) })] });
|
|
330
|
+
}, children: _jsx(Text, { style: { color: c.incomingText }, children: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Group').slice(0, 1) : contact.name.slice(0, 1) }) }))), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: header.foreground, fontSize: chatDesign?.titleSize ?? 18, lineHeight: Math.ceil((chatDesign?.titleSize ?? 18) * 1.25), textAlign: chatDesign?.titleAlign ?? 'left', fontWeight: "800" }, children: state.conversation?.kind === 'group' ? state.conversation.name : contact.name }), _jsx(MessagingActivity, { ink: header.foreground })] })] }), messagingHeaderOrder(design).map(action => _jsx(React.Fragment, { children: action === 'switcher' ? chatDesign?.showSwitcher !== false && _jsx(ConversationSelector, { options: headerOptions, selectedId: state.conversationId, color: header.foreground, background: header.background }) : action === 'close' ? chatDesign?.showClose !== false && headerOptions?.onClose && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close conversation"), onPress: headerOptions.onClose, style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: "close", color: header.foreground, size: 24 }) }) : action === 'calls' ? _jsxs(_Fragment, { children: [children, components?.HeaderActions && _jsx(components.HeaderActions, { conversationId: state.conversationId, contact: contact, appearance: design }), state.conversation?.canSend !== false && _jsx(MessagingHeaderCalls, { actions: callActions ? { ...callActions, ...(chatDesign?.showVoiceCall === false ? { voice: undefined, phoneNumber: undefined } : {}), ...(chatDesign?.showVideoCall === false ? { video: undefined } : {}) } : undefined, name: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Group') : contact.name, group: state.conversation?.kind === 'group', color: header.foreground }, state.conversationId)] }) : action === 'privacy' ? null : _jsx(View, { style: { width: 44, height: 44 }, children: (onContactOptions || extrasState?.available.privacyLens || extrasState?.privacyLens || conversationActions || state.settings?.enabled || state.conversation?.safety || state.searchAvailable || state.scheduledMessagesAvailable || translationAvailable) && (_jsx(Pressable, { accessibilityRole: "button", testID: "messaging-contact-options", accessibilityLabel: uiText("Contact options"), ref: menuButton, accessibilityState: { expanded: safetyOpen }, onPress: onContactOptions ?? openContactMenu, style: { width: 44, height: 44, alignItems: "center", justifyContent: "center" }, children: _jsx(MessageIcon, { name: "more", color: header.foreground, size: 25 }) })) }) }, action)), safetyOpen && _jsx(MessagingSafety, { onMedia: state.sharedMediaAvailable ? () => { setSafetyOpen(false); setDetailsTab('media'); setDetailsOpen(true); } : undefined, onOptions: state.presence?.visibilityAvailable || conversationActions || extrasState?.available.privacyLens || extrasState?.privacyLens ? () => { setSafetyOpen(false); setOptionsOpen(true); } : undefined, onScheduled: state.scheduledMessagesAvailable ? () => { setSafetyOpen(false); setScheduledOpen(true); } : undefined, onDetails: state.settings?.enabled ? () => { setSafetyOpen(false); setDetailsTab('profile'); setDetailsOpen(true); } : undefined, onPins: state.discussionAvailable ? () => { setSafetyOpen(false); openDiscussion(); } : undefined, menuAnchor: menuAnchor, client: client, state: state, appearance: design, name: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Conversation') : contact.name, onSearch: state.searchAvailable && state.settings?.enabled ? () => { setSafetyOpen(false); setSearchOpen(true); } : undefined, onClose: () => setSafetyOpen(false), children: translationAvailable && _jsx(TranslationSettings, { client: client, appearance: design, preference: state.translationPreference, language: languageTools?.preferredLanguage ?? language, sourceLanguage: contact.language, voiceAvailable: languageTools?.voiceOutput !== false && !!components?.TranslationVoice, onSaved: () => setSafetyOpen(false) }, state.conversationId) })] }), scheduledOpen && _jsx(ScheduledMessages, { client: client, accent: c.accent, onClose: () => setScheduledOpen(false) }, state.conversationId), groupOpen && _jsx(MessagingGroupEditor, { client: client, userId: userId, contacts: participants ?? {}, conversation: state.conversation, groups: state.settings?.groups, accent: c.accent, onClose: () => setGroupOpen(false), onSaved: () => setGroupOpen(false) }), moderationOpen && _jsx(MessagingRoomModeration, { client: client, userId: userId, participants: participants, accent: c.accent, onClose: () => setModerationOpen(false) }), optionsOpen && _jsx(ChatOptions, { online: state.presence?.visibilityAvailable ? { hidden: state.presence.hidden === true, set: hidden => client.setOnlineStatusHidden(hidden) } : undefined, actions: conversationActions, accent: c.accent, onClose: () => setOptionsOpen(false), privacy: extras && extrasState && (extrasState.available.privacyLens || extrasState.privacyLens) ? { enabled: extrasState.privacyLens, set: enabled => extras.setPrivacy(enabled) } : undefined }), detailsOpen && _jsx(ConversationDetails, { initialTab: detailsTab, onOptions: state.presence?.visibilityAvailable || conversationActions ? () => setOptionsOpen(true) : undefined, onModerate: () => setModerationOpen(true), onEditGroup: () => setGroupOpen(true), onLeft: onBack, client: client, state: state, userId: userId, contact: contact, participants: participants, accent: c.accent, onClose: () => setDetailsOpen(false), attachmentPreview: attachmentPreview, openAttachment: openAttachment }), searchOpen && state.searchAvailable && state.settings?.enabled && _jsx(MessagingSearch, { client: client, appearance: design, onClose: () => setSearchOpen(false), resolveName: id => id === userId ? 'You' : participants?.[id]?.name ?? (state.conversation?.kind === 'direct' ? contact.name : 'Chat member') }, state.conversationId)] }));
|
|
332
331
|
}
|
|
333
332
|
const mediaNames = {
|
|
334
333
|
voice: "Voice message",
|
|
@@ -337,8 +336,8 @@ const mediaNames = {
|
|
|
337
336
|
document: "File",
|
|
338
337
|
};
|
|
339
338
|
function quoteSummary(message, uiText) { return message?.poll?.question ?? message?.text ?? uiText(message && message.kind !== "text" && message.kind !== "poll" ? mediaNames[message.kind] : "Earlier message"); }
|
|
340
|
-
/**
|
|
341
|
-
function QuotedPreview({ message, ink }) {
|
|
339
|
+
/** Composer previews stay compact; delivered quotes display the complete text. */
|
|
340
|
+
function QuotedPreview({ message, ink, expanded = false }) {
|
|
342
341
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
343
342
|
const { attachmentPreview, userId, participants, contact, state, design } = useMessagingUI();
|
|
344
343
|
const [thumbnail, setThumbnail] = useState();
|
|
@@ -352,11 +351,11 @@ function QuotedPreview({ message, ink }) {
|
|
|
352
351
|
}, [message?.id, message?.conversationId, message?.media?.assetId, message?.deleted, attachmentPreview]);
|
|
353
352
|
const name = message && !message.deleted ? (message.senderId === userId ? 'You' : participants?.[message.senderId]?.name ?? (state.conversation?.kind === 'direct' ? contact.name : 'Chat member')) : null;
|
|
354
353
|
const media = message && !message.deleted && message.kind !== 'text' && message.kind !== 'poll';
|
|
355
|
-
return _jsxs(View, { testID: "quoted-message-preview", style: { flexDirection: 'row', alignItems: 'flex-start', gap: 8, minWidth: 0 }, children: [media && (thumbnail ? _jsx(Image, { accessibilityLabel: uiText("Quoted attachment thumbnail"), source: { uri: thumbnail }, onError: () => setThumbnail(undefined), resizeMode: "
|
|
354
|
+
return _jsxs(View, { testID: "quoted-message-preview", style: { flexDirection: 'row', alignItems: 'flex-start', gap: 8, minWidth: 0 }, children: [media && (thumbnail ? _jsx(Image, { accessibilityLabel: uiText("Quoted attachment thumbnail"), source: { uri: thumbnail }, onError: () => setThumbnail(undefined), resizeMode: "contain", style: { width: 42, height: 42, borderRadius: 8 } }) : _jsx(MessageIcon, { name: message.kind === 'voice' ? 'mic' : message.kind, color: design.colors.accent, size: 24 })), _jsxs(View, { style: { flexShrink: 1, minWidth: 0 }, children: [name && _jsx(Text, { numberOfLines: 1, style: { color: design.colors.accent, fontSize: expanded ? 12 : 11, lineHeight: expanded ? 16 : 14, fontWeight: '900' }, children: name === 'You' ? uiText('You') : name }), _jsxs(Text, { numberOfLines: expanded ? undefined : 2, style: { color: ink, fontSize: expanded ? 16 : 12, lineHeight: expanded ? 22 : 16, opacity: expanded ? 1 : .8, marginTop: name ? 1 : 0 }, children: [message?.deleted ? uiText("Message deleted") : quoteSummary(message, uiText), message?.kind === 'voice' && message.media?.durationMs ? ` · ${duration(message.media.durationMs)}` : ''] })] })] });
|
|
356
355
|
}
|
|
357
356
|
/** Thumbnails stay local to the view and are discarded on conversation/message changes. */
|
|
358
357
|
const heardVoiceMessages = new WeakMap();
|
|
359
|
-
function MediaContent({ message, ink, footer, onOpen, onLongPress }) {
|
|
358
|
+
function MediaContent({ message, ink, footer, onOpen, onLongPress, sendRetry }) {
|
|
360
359
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
361
360
|
const { attachmentPreview, components, design, userId, client } = useMessagingUI();
|
|
362
361
|
const [, updateHeard] = useState(0), voiceKey = message.conversationId + ':' + message.id + ':' + message.media?.assetId;
|
|
@@ -368,13 +367,49 @@ function MediaContent({ message, ink, footer, onOpen, onLongPress }) {
|
|
|
368
367
|
return; rows.add(voiceKey); if (rows.size > 2048)
|
|
369
368
|
rows.delete(rows.values().next().value); updateHeard(n => n + 1); };
|
|
370
369
|
const { preview, failed, retry, onImageError } = useAttachmentPreview(message, attachmentPreview, useMessagingUI().active !== false);
|
|
370
|
+
const sizeKey = JSON.stringify([message.conversationId, message.id, message.revision, message.media]);
|
|
371
|
+
// The preview callback is recreated when the conversation screen remounts.
|
|
372
|
+
// Keep geometry with the account client; a current matching preview URI is
|
|
373
|
+
// still required before the hint can be used.
|
|
374
|
+
const sizeScope = client;
|
|
375
|
+
const [imageSize, setImageSize] = useState();
|
|
376
|
+
const decodedSize = (uri, width, height) => {
|
|
377
|
+
const size = rememberPreviewSize(sizeScope, sizeKey, uri, width, height);
|
|
378
|
+
if (size)
|
|
379
|
+
setImageSize({ uri, key: sizeKey, ...size });
|
|
380
|
+
};
|
|
381
|
+
useEffect(() => {
|
|
382
|
+
if (Platform.OS !== 'web' || !preview.uri)
|
|
383
|
+
return;
|
|
384
|
+
let current = true;
|
|
385
|
+
const uri = preview.uri;
|
|
386
|
+
// Web's image loader does not supply React Native's source dimensions.
|
|
387
|
+
// Decode the same local preview URL, never the full attachment.
|
|
388
|
+
Image.getSize(uri, (width, height) => { if (current)
|
|
389
|
+
decodedSize(uri, width, height); }, () => { });
|
|
390
|
+
return () => { current = false; };
|
|
391
|
+
}, [preview.uri, sizeKey, sizeScope]);
|
|
392
|
+
// Size the decoded preview, never the full attachment. A recycled row cannot
|
|
393
|
+
// reuse the previous image's shape.
|
|
394
|
+
const size = imageSize && imageSize.uri === preview.uri && imageSize.key === sizeKey ? imageSize : readPreviewSize(sizeScope, sizeKey, preview.uri);
|
|
395
|
+
// Disk and fresh previews may use different resolutions of the same photo.
|
|
396
|
+
// Keep the displayed proportions and bounds independent of that resolution.
|
|
397
|
+
const scale = size ? Math.min(220 / size.width, 280 / size.height) : 1;
|
|
398
|
+
const previewWidth = size ? size.width * scale : 220, previewHeight = size ? size.height * scale : 155;
|
|
371
399
|
if (message.kind === 'voice') {
|
|
372
400
|
const Voice = components?.VoiceMessage;
|
|
373
|
-
return Voice ? _jsx(Voice, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, message: message, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, footer: footer, onOpen: onOpen, onLongPress: onLongPress }) : _jsx(VoicePlayback, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, durationMs: message.media?.durationMs, footer: footer, onToggle: onOpen, onLongPress: onLongPress });
|
|
401
|
+
return Voice ? _jsx(Voice, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, message: message, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, footer: _jsxs(_Fragment, { children: [footer, sendRetry] }), onOpen: onOpen, onLongPress: onLongPress }) : _jsx(VoicePlayback, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, durationMs: message.media?.durationMs, footer: _jsxs(_Fragment, { children: [footer, sendRetry] }), onToggle: onOpen, onLongPress: onLongPress });
|
|
374
402
|
}
|
|
375
403
|
if (message.kind === 'image' || message.kind === 'video')
|
|
376
|
-
return _jsx(View, { style: { width:
|
|
377
|
-
|
|
404
|
+
return _jsx(View, { style: { width: previewWidth, maxWidth: '100%', gap: 0 }, children: _jsxs(View, { testID: "media-bubble-surface", style: { width: '100%', aspectRatio: previewWidth / previewHeight, ...bubbleCorners(design, message.senderId === userId, !!message.text), overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: '#00000012' }, children: [preview.uri ? _jsx(Image, { source: { uri: preview.uri }, accessibilityLabel: message.media?.fileName ?? uiText(mediaNames[message.kind]), resizeMode: "contain", onLoad: event => {
|
|
405
|
+
const source = event.nativeEvent.source;
|
|
406
|
+
// React Native Web supplies the decoded HTML image as the event target.
|
|
407
|
+
const target = event.nativeEvent.target;
|
|
408
|
+
const width = source?.width ?? target?.naturalWidth, height = source?.height ?? target?.naturalHeight;
|
|
409
|
+
if (width && height && preview.uri)
|
|
410
|
+
decodedSize(preview.uri, width, height);
|
|
411
|
+
}, onError: onImageError, style: { width: '100%', height: '100%' } }) : _jsx(MessageIcon, { name: message.kind, color: ink, size: 36 }), failed && !preview.uri && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Retry preview'), onPress: event => { event.stopPropagation(); retry(); }, style: { position: 'absolute', bottom: 6, right: 6, minHeight: 44, paddingHorizontal: 12, justifyContent: 'center', backgroundColor: design.colors.incoming, borderRadius: 18 }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText('Retry preview') }) }), sendRetry && _jsx(View, { testID: "media-send-retry", style: { position: 'absolute', backgroundColor: design.colors.incoming, borderRadius: 18, paddingHorizontal: 12 }, children: sendRetry }), message.kind === 'video' && !sendRetry && _jsxs(_Fragment, { children: [_jsx(View, { style: { position: 'absolute', borderRadius: 24, padding: 10, backgroundColor: '#00000099' }, children: _jsx(MessageIcon, { name: "play", color: "#ffffff" }) }), _jsx(Text, { style: { position: 'absolute', left: 8, bottom: 8, color: '#ffffff', backgroundColor: '#000000aa', borderRadius: 4, paddingHorizontal: 5, fontSize: 12 }, children: duration(message.media?.durationMs) })] })] }) });
|
|
412
|
+
return _jsxs(View, { testID: "file-message-content", style: { flexDirection: 'row', alignItems: 'center', gap: 10, width: 220, maxWidth: '100%', minHeight: 56, paddingHorizontal: 12, paddingVertical: 6, ...bubbleCorners(design, message.senderId === userId), ...(message.senderId === userId && design.messageStatus?.style === 'circle' ? { paddingRight: 28 } : {}) }, children: [_jsx(MessageIcon, { name: "document", color: design.colors.accent, size: 24 }), _jsxs(View, { style: { flex: 1, gap: 2 }, children: [_jsx(Text, { numberOfLines: 2, style: { color: ink, fontSize: 14, fontWeight: '600' }, children: message.media?.fileName ?? uiText("File") }), _jsxs(Text, { style: { color: ink, fontSize: 12, opacity: 0.75 }, children: [message.media?.fileName?.split('.').pop()?.toUpperCase(), " \u00B7 ", fileSize(message.media?.byteSize)] }), sendRetry] })] });
|
|
378
413
|
}
|
|
379
414
|
function messageTimeLabel(message, format, text) { return (message.editedAt && !message.deleted ? text('edited') + ' · ' : '') + format(message.createdAt); }
|
|
380
415
|
function MessageMetadata(_props) { return null; }
|
|
@@ -407,12 +442,16 @@ export function MessagingBubble(props) {
|
|
|
407
442
|
const context = useMessagingUI(), last = useRef(null);
|
|
408
443
|
const selected = selectBubbleUI(context, props, last.current);
|
|
409
444
|
last.current = selected;
|
|
410
|
-
return _jsx(
|
|
445
|
+
return _jsx(MessagingBubbleItems, { message: props.message, pendingStatus: props.pendingStatus, ui: selected });
|
|
446
|
+
}
|
|
447
|
+
function MessagingBubbleItems({ message, pendingStatus, ui }) {
|
|
448
|
+
return _jsx(_Fragment, { children: messageParts(message).map((item, index) => _jsx(MessagingBubbleView, { message: item, pendingStatus: pendingStatus, ui: index ? { ...ui, grouped: true } : ui }, item.part ?? 'whole')) });
|
|
411
449
|
}
|
|
412
450
|
const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, pendingStatus, ui }) {
|
|
413
451
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
414
452
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
415
453
|
const { userId, design, state, client, participants, openDiscussion, discussionPreview, discussionRoot, setReply, setEditing, setForwarding, setDeleting, selectionActive, setSelection, saved, saving, toggleSaved, onMessageOptions, openAttachment, language, contact, copyText, components, extras, onCallHistory, linkHandling, languageTools } = ui;
|
|
454
|
+
const notice = message.senderId === userId ? deliveryNotice(message) : { text: undefined, retry: false };
|
|
416
455
|
const deliveryStatus = pendingStatus ?? (message.senderId === userId && message.delivery?.state === 'pending' ? 'sending' : message.senderId === userId && message.delivery?.state === 'failed' ? 'failed' : undefined);
|
|
417
456
|
const candidateExtra = !message.custom && !pendingStatus && !message.deleted ? ui.candidateExtra : undefined;
|
|
418
457
|
const extra = candidateExtra?.address && (linkHandling?.addresses === false || linkHandling?.openAddress) ? undefined : candidateExtra;
|
|
@@ -424,6 +463,8 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
424
463
|
const corners = bubbleCorners(design, mine), bubbleRadius = corners.borderTopRightRadius;
|
|
425
464
|
const status = bubbleDelivery(message, deliveryStatus, !!state.settings?.features.readReceipts, design);
|
|
426
465
|
const circleStatus = mine && status.style === 'circle';
|
|
466
|
+
const timePosition = design.messageTime?.position ?? 'slide', circlePosition = design.messageStatus?.position ?? 'inside';
|
|
467
|
+
const statusLabel = uiText(notice.text ?? (status.phase === 'failed' ? 'Message not sent' : status.phase === 'sent' ? 'Sending message' : status.phase === 'consumed' ? (message.kind === 'voice' ? 'Heard' : message.kind === 'video' ? 'Watched' : 'Seen') : 'Delivered'));
|
|
427
468
|
const messageGap = design.presentation?.messageSpacing === 'compact' ? 4 : design.presentation?.messageSpacing === 'relaxed' ? 12 : 8;
|
|
428
469
|
const visual = message.kind === 'image' || message.kind === 'video', voice = message.kind === 'voice';
|
|
429
470
|
const grouped = ui.grouped;
|
|
@@ -433,7 +474,8 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
433
474
|
const leaveMenu = (next) => { afterMenu.current = next; setActions(false); if (Platform.OS !== 'ios')
|
|
434
475
|
menuDismissed(); };
|
|
435
476
|
useEffect(() => () => { afterMenu.current = null; }, [client, message.id]);
|
|
436
|
-
const
|
|
477
|
+
const wholeMessage = message.part ? client.getSnapshot().messages.find(m => m.id === message.id) ?? message : message;
|
|
478
|
+
const canChange = (!message.part || wholeMessage !== message) && !extra?.weather && !extra?.call && mine && !pendingStatus && !message.deleted && !!state.messageActionsAvailable && !!state.settings?.enabled && state.conversation?.canSend !== false && !wholeMessage.readAt && !wholeMessage.textReadAt;
|
|
437
479
|
const anchor = useRef(null), viewport = useWindowDimensions();
|
|
438
480
|
const [menuPosition, setMenuPosition] = useState({ x: 12, y: 12, above: false, available: 400 }), [hovered, setHovered] = useState(false);
|
|
439
481
|
const [addressBubbleHeight, setAddressBubbleHeight] = useState(44);
|
|
@@ -447,7 +489,7 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
447
489
|
const translation = state.translationPreference;
|
|
448
490
|
const translationLanguage = translation?.language ?? languageTools?.preferredLanguage ?? language;
|
|
449
491
|
const sourceLanguage = participants?.[message.senderId]?.language ?? (state.conversation?.kind === 'direct' ? contact.language : undefined) ?? translation?.sourceLanguage;
|
|
450
|
-
const canTranslate = languageTools?.translation !== false && !mine && !extra?.weather && !extra?.call && !pendingStatus && ['text', 'voice', 'video'].includes(message.kind) && !!state.settings?.enabled && !!state.settings.features.translation && client.hasLanguageTools() && !message.deleted && translation?.mode !== undefined && translation.mode !== 'off' && needsMessageTranslation(sourceLanguage, translationLanguage) && (translation.mode !== 'voice' || languageTools?.voiceOutput === false || !!TranslationVoice);
|
|
492
|
+
const canTranslate = message.part !== 'text' && languageTools?.translation !== false && !mine && !extra?.weather && !extra?.call && !pendingStatus && ['text', 'voice', 'video'].includes(message.kind) && !!state.settings?.enabled && !!state.settings.features.translation && client.hasLanguageTools() && !message.deleted && translation?.mode !== undefined && translation.mode !== 'off' && needsMessageTranslation(sourceLanguage, translationLanguage) && (translation.mode !== 'voice' || languageTools?.voiceOutput === false || !!TranslationVoice);
|
|
451
493
|
const transformGeneration = useRef(0), transformAbort = useRef(null);
|
|
452
494
|
useEffect(() => { transformAbort.current?.abort(); transformGeneration.current++; setTransformed(null); setTransforming(false); setShowOriginal(false); setTranslationAutoPlay(false); return () => { transformAbort.current?.abort(); transformGeneration.current++; }; }, [message.id, message.deleted, message.text, message.media?.assetId, translationLanguage, translation?.mode, sourceLanguage, state.settings?.enabled, state.settings?.features.transcription, state.settings?.features.translation, languageTools?.translation, languageTools?.transcription, languageTools?.voiceOutput, languageTools?.revision]);
|
|
453
495
|
useEffect(() => { if (!transformed?.audio)
|
|
@@ -511,8 +553,8 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
511
553
|
const renderLinks = (text) => messageLinks(text).map((part, index) => part.url && linkHandling?.webLinks !== false ? _jsx(Text, { accessibilityRole: "link", onLongPress: menu, onPress: event => { event.stopPropagation(); void Promise.resolve().then(() => linkHandling?.openUrl ? linkHandling.openUrl(part.url, message) : Linking.openURL(part.url)).catch(() => setError(uiText("This link could not be opened."))); }, style: { textDecorationLine: 'underline' }, children: part.text }, index) : part.text);
|
|
512
554
|
const renderText = (text) => { const address = linkHandling?.addresses === false ? null : findChatAddress(text); return address ? _jsxs(_Fragment, { children: [renderLinks(text.slice(0, address.start)), _jsx(Text, { accessibilityRole: "link", onLongPress: menu, onPress: event => { event.stopPropagation(); void Promise.resolve().then(() => linkHandling?.openAddress ? linkHandling.openAddress(address.text, message) : openChatAddress(address.text)).catch(() => setError(uiText("Maps could not be opened."))); }, style: { color: c.accent, textDecorationLine: 'underline' }, children: address.text }), renderLinks(text.slice(address.end))] }) : renderLinks(text); };
|
|
513
555
|
const extraCard = extra && extras ? _jsx(MessageExtra, { ref: extraRef, addressBubbleHeight: addressBubbleHeight, extra: extra, messageId: message.id, userId: userId, extras: extras, ink: ink, accent: c.accent, background: c.background, foreground: c.foreground, Map: components?.TrackingMap, onLongPress: menu, onCall: onCallHistory, footer: _jsx(MessageMetadata, { message: message, mine: mine, ink: ink }), renderAddress: (action, people) => _jsxs(_Fragment, { children: [_jsxs(Pressable, { onLayout: event => { const h = event.nativeEvent.layout.height; setAddressBubbleHeight(old => Math.abs(old - h) < .5 ? old : h); }, testID: "address-message-bubble", accessibilityRole: "button", accessibilityLabel: uiText("Show live tracking map"), hitSlop: { top: 6, bottom: 6, left: 4, right: 4 }, onLongPress: menu, onPress: event => { event.stopPropagation(); if (!quoteGesture.suppressPress())
|
|
514
|
-
extraRef.current?.open(); }, style: { flexShrink: 1, minWidth: 0, minHeight: 44, justifyContent: 'center', position: 'relative', backgroundColor: mine ? c.outgoing : c.incoming, borderRadius: bubbleRadius, paddingHorizontal: 6, paddingVertical: 3 }, children: [bubbleBody, people] }), action] }) }) : null;
|
|
515
|
-
const socialCard = socialReady && components?.SocialPlayer ? _jsx(SocialMessagePreview, { ref: socialRef, onLongPress: menu, message: message, client: client, Player: components.SocialPlayer, origin: socialOrigin, accent: c.accent, foreground: c.foreground, background: c.background, renderMessage: action => _jsxs(_Fragment, { children: [_jsx(View, { testID: "social-message-bubble", style: { flexShrink: 1, minWidth: 0, minHeight: 44, justifyContent: 'center', position: 'relative', backgroundColor: mine ? c.outgoing : c.incoming, borderRadius: bubbleRadius, paddingHorizontal: 6, paddingVertical: 3 }, children: bubbleBody }), action] }) }) : null;
|
|
556
|
+
extraRef.current?.open(); }, style: { flexShrink: 1, minWidth: 0, minHeight: 44, justifyContent: 'center', position: 'relative', backgroundColor: mine ? c.outgoing : c.incoming, borderRadius: bubbleRadius, paddingHorizontal: 6, paddingVertical: 3, ...(mine ? { paddingRight: 12 } : { paddingLeft: 12 }) }, children: [bubbleBody, people] }), action] }) }) : null;
|
|
557
|
+
const socialCard = socialReady && components?.SocialPlayer ? _jsx(SocialMessagePreview, { ref: socialRef, onLongPress: menu, message: message, client: client, Player: components.SocialPlayer, origin: socialOrigin, accent: c.accent, foreground: c.foreground, background: c.background, renderMessage: action => _jsxs(_Fragment, { children: [_jsx(View, { testID: "social-message-bubble", style: { flexShrink: 1, minWidth: 0, minHeight: 44, justifyContent: 'center', position: 'relative', backgroundColor: mine ? c.outgoing : c.incoming, borderRadius: bubbleRadius, paddingHorizontal: 6, paddingVertical: 3, ...(mine ? { paddingRight: 12 } : { paddingLeft: 12 }) }, children: bubbleBody }), action] }) }) : null;
|
|
516
558
|
const canCopy = !!message.text && (!!copyText || Platform.OS === 'web');
|
|
517
559
|
const reactionDesign = design.menus?.message;
|
|
518
560
|
const reactionPicker = actions && !mine && canInteract && state.settings?.features.reactions && _jsx(View, { testID: "message-reaction-picker", accessibilityLabel: uiText("Choose a reaction"), style: { height: 50, borderRadius: reactionDesign?.corners === 'square' ? 0 : reactionDesign?.corners === 'soft' ? 8 : 25, backgroundColor: reactionDesign?.reactionBackground ?? '#171717', borderWidth: .5, borderColor: (reactionDesign?.foreground ?? '#ffffff') + '24', justifyContent: 'center', boxShadow: '0 6px 14px #0006' }, children: _jsx(ScrollView, { horizontal: true, showsHorizontalScrollIndicator: false, keyboardShouldPersistTaps: "handled", contentContainerStyle: { alignItems: 'center', paddingHorizontal: 8, gap: 4 }, children: messageReactions.map(emoji => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("React {value1}", { value1: emoji }), accessibilityState: { selected: !!message.reactions?.some(r => r.emoji === emoji && r.userIds.includes(userId)) }, disabled: busy, onPress: () => void react(emoji), style: { width: 40, height: 38, borderRadius: 19, alignItems: 'center', justifyContent: 'center', backgroundColor: message.reactions?.some(r => r.emoji === emoji && r.userIds.includes(userId)) ? (reactionDesign?.reactionSelected ?? '#f0843433') : 'transparent' }, children: _jsx(Text, { style: { fontSize: reactionDesign?.reactionSize ?? 23, lineHeight: 32 }, children: emoji }) }, emoji)) }) });
|
|
@@ -520,21 +562,42 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
520
562
|
const bigEmoji = message.kind === 'text' && !message.replyTo && !extra && !canTranslate && !transformed && isBigEmojiText(message.text);
|
|
521
563
|
const showingTransform = !!transformed && !showOriginal && (transformed.kind === 'transcript' || canTranslate);
|
|
522
564
|
const languageActions = (canTranscript || canTranslate || transformed) && _jsxs(View, { testID: "message-language-actions", style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: voice && !showingTransform ? 'flex-end' : 'flex-start', columnGap: 8, rowGap: 0 }, children: [transforming && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel"), onPress: () => { transformAbort.current?.abort(); transformGeneration.current++; setTransforming(false); }, hitSlop: 8, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: uiText("Cancel") }) }), transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original"), onPress: () => { setTranslationAutoPlay(false); setShowOriginal(v => !v); }, hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original") }) }), canTranscript && !transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Read transcript"), disabled: transforming, onPress: () => void transform('transcript'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: transforming ? uiText("Transcribing…") : uiText("Transcript") }) }), canTranslate && transformed?.kind !== 'translation' && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play translation") : uiText("Translate message"), disabled: transforming, onPress: () => void transform('translation', translation.mode === 'voice' && languageTools?.voiceOutput !== false ? 'voice' : 'text'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play Translation") : uiText("Translate") }) })] });
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
|
|
565
|
+
const messageMeta = (placement) => {
|
|
566
|
+
const time = timePosition === placement, circle = circleStatus && circlePosition === placement;
|
|
567
|
+
if (!time && !circle)
|
|
568
|
+
return null;
|
|
569
|
+
const textColor = placement === 'below' ? c.secondary : visual ? '#ffffff' : ink;
|
|
570
|
+
const circleColor = status.phase === 'delivered' ? textColor : status.phase === 'sent' ? c.secondary : status.phase === 'consumed' ? c.accent : status.color;
|
|
571
|
+
const rgb = circleColor.slice(1).match(/../g)?.map(v => parseInt(v, 16)) ?? [0, 0, 0];
|
|
572
|
+
const checkColor = rgb[0] * .299 + rgb[1] * .587 + rgb[2] * .114 > 150 ? '#111111' : '#ffffff';
|
|
573
|
+
return _jsxs(View, { testID: 'message-meta-' + placement, pointerEvents: "none", style: { flexDirection: 'row', alignItems: 'center', alignSelf: 'flex-end', gap: 4, ...(placement === 'inside' ? visual ? { position: 'absolute', bottom: 5, right: 5, zIndex: 40, backgroundColor: '#00000088', borderRadius: 4, paddingHorizontal: 4, paddingVertical: 2 } : voice ? {} : { marginTop: 2, paddingHorizontal: 2, paddingBottom: 1 } : {}) }, children: [time && _jsx(Text, { testID: "message-timestamp", accessibilityLabel: uiText('SENT:') + ' ' + ui.formatMessageTime(message.createdAt), style: { fontSize: 10, lineHeight: 12, color: textColor, fontVariant: ['tabular-nums'] }, children: messageTimeLabel(message, ui.formatMessageTime, uiText) }), circle && _jsx(View, { testID: 'message-status-' + status.phase, accessibilityLabel: statusLabel, style: { width: 12, height: 12, borderRadius: 6, borderWidth: 1, borderColor: circleColor, backgroundColor: status.phase === 'consumed' ? circleColor : 'transparent', alignItems: 'center', justifyContent: 'center' }, children: status.phase !== 'sent' && _jsx(MessageIcon, { name: status.phase === 'failed' ? 'warning' : 'check', color: status.phase === 'consumed' ? checkColor : circleColor, size: 8 }) })] });
|
|
574
|
+
};
|
|
575
|
+
const insideMeta = messageMeta('inside'), belowMeta = messageMeta('below');
|
|
576
|
+
const sendRetry = deliveryStatus === 'failed' && (!!pendingStatus || notice.retry) ? _jsx(Pressable, { testID: "message-send-retry", accessibilityRole: "button", accessibilityLabel: uiText("Retry sending message"), onPress: event => { event.stopPropagation(); void client.retry(message.clientMessageId).catch(() => { }); }, hitSlop: voice ? 4 : undefined, style: { minHeight: voice ? 20 : 32, paddingHorizontal: 4, justifyContent: 'center', alignSelf: 'flex-end' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 12, lineHeight: 16 }, children: design.labels.retry }) }) : null;
|
|
577
|
+
const fallbackContent = _jsx(View, { testID: "message-original-text", children: _jsx(Text, { selectable: true, style: { color: ink, fontSize: 16, lineHeight: 22, textAlign: 'left' }, children: renderText(message.text ?? '') }) });
|
|
578
|
+
const originalContent = message.custom && !message.deleted ? _jsxs(Pressable, { onLongPress: menu, children: [_jsx(CustomMessage, { message: message, mine: mine, appearance: design, pendingStatus: pendingStatus, components: components, enabled: canInteract, children: fallbackContent }), pendingStatus && footer] }) : extra?.weather || extra?.call ? extraCard : message.kind === 'poll' ? _jsx(PollMessage, { onLongPress: menu, message: message, userId: userId, ink: ink, accent: c.accent, background: c.background, foreground: c.foreground, resolveVoterName: id => id === userId ? 'You' : participants?.[id]?.name ?? (state.conversation?.kind === 'direct' ? contextContactName : 'Chat member'), enabled: canInteract && !!state.settings?.features.poll, onVote: options => client.vote(message.id, options), onClose: () => client.closePoll(message.id) }) : message.kind === 'text' ? _jsxs(View, { testID: "message-original-text", children: [_jsx(Text, { selectable: true, style: { color: ink, fontSize: bigEmoji ? 48 : 16, lineHeight: bigEmoji ? 58 : 22, textAlign: 'left' }, children: renderText(message.text ?? '') }), pendingStatus && footer] }) : _jsx(MediaContent, { sendRetry: sendRetry, message: message, ink: ink, accent: c.accent, footer: voice ? _jsxs(_Fragment, { children: [languageActions, insideMeta] }) : undefined, onOpen: () => void open(), onLongPress: menu });
|
|
579
|
+
const content = showingTransform ? _jsxs(View, { children: [_jsx(Text, { style: { color: ink, fontSize: 11, opacity: .65, marginBottom: 2 }, children: transformed.kind === 'transcript' ? uiText("Transcript") : 'Translated · ' + supportedLanguageLabel(translationLanguage) }), transformed.audio && TranslationVoice ? _jsx(View, { testID: "message-translated-voice", children: _jsx(TranslationVoice, { transform: transformed, ink: ink, accent: c.accent, showWaveform: design.showWaveform !== false, autoPlay: translationAutoPlay }) }) : _jsx(Text, { testID: "message-language-result", selectable: true, style: { color: ink, fontSize: 16, lineHeight: 22, textAlign: 'left' }, children: transformed.text }), !voice && footer] }) : originalContent;
|
|
526
580
|
const regionProps = { message, mine, appearance: design, pendingStatus };
|
|
527
581
|
const bodyContent = components?.MessageBody && !message.deleted ? _jsx(components.MessageBody, { ...regionProps, children: content }) : content;
|
|
528
|
-
const
|
|
582
|
+
const topTail = design.presentation?.bubbleStyle === 'top-tail' && !visual && !voice && !extra && !socialReady && !bigEmoji;
|
|
583
|
+
const hasQuote = !!message.replyTo && message.replyTo !== discussionRoot;
|
|
584
|
+
const quoteBackground = chatSurface(c.background) === '#ffffff' ? '#f3f3f3' : '#242424';
|
|
585
|
+
// Extend the gray quote to the bubble edges, leaving the reply in its own
|
|
586
|
+
// normal message color below. Media/file/voice containers have no outer inset.
|
|
587
|
+
const quoteInset = extra?.address || socialReady ? 6 : visual || (voice || message.kind === 'document') && !showingTransform ? 0 : message.kind === 'poll' ? 8 : 6;
|
|
588
|
+
const quoteTopInset = message.kind === 'poll' ? 4 : quoteInset;
|
|
589
|
+
const paddedBubble = !visual && (!(voice || message.kind === 'document') || showingTransform) && !bigEmoji && !extra?.address && !socialReady;
|
|
590
|
+
const quoteExtraInset = paddedBubble || extra?.address || socialReady ? 6 : 0;
|
|
591
|
+
const statusTopRadius = voice && !showingTransform ? 24 : topTail ? 0 : bubbleRadius, statusBottomRadius = voice && !message.text && !showingTransform ? 24 : corners.borderBottomRightRadius;
|
|
529
592
|
// Cover the full inside edge; each curved end tapers to the bubble's corner.
|
|
530
|
-
const bubbleBody = _jsxs(_Fragment, { children: [mine && _jsx(View, { testID: 'message-status-' + status.phase, pointerEvents: "none", accessibilityLabel:
|
|
593
|
+
const bubbleBody = _jsxs(_Fragment, { children: [mine && !circleStatus && _jsx(View, { testID: 'message-status-' + status.phase, pointerEvents: "none", accessibilityLabel: statusLabel, style: { position: 'absolute', top: topTail ? 10 : 0, bottom: 0, end: 0, width: Math.max(statusTopRadius, statusBottomRadius) + 2, zIndex: 40, overflow: 'hidden' }, children: _jsx(DeliveryBar, { color: status.color, topRadius: statusTopRadius, bottomRadius: statusBottomRadius, roundedStart: topTail }) }), hasQuote && _jsx(Pressable, { testID: "message-quote-section", accessibilityRole: "button", accessibilityLabel: uiText("Go to quoted message"), onLongPress: menu, onPress: () => { void client.focusMessage(message.replyTo).catch(e => setError(e instanceof Error ? e.message : uiText("This message is unavailable."))); }, style: { alignSelf: 'stretch', minHeight: 44, borderTopLeftRadius: topTail && !mine ? 0 : bubbleRadius, borderTopRightRadius: topTail && mine ? 0 : bubbleRadius, backgroundColor: quoteBackground, paddingLeft: mine ? 8 : 14, paddingRight: mine ? 14 : 8, paddingVertical: 8, marginLeft: -quoteInset - (mine ? 0 : quoteExtraInset), marginRight: -quoteInset - (mine ? quoteExtraInset : 0), marginTop: -quoteTopInset, marginBottom: 6, overflow: 'hidden' }, children: _jsx(QuotedPreview, { expanded: true, message: ui.quoted ? selectMessagePart(ui.quoted, message.replyPart) : undefined, ink: c.foreground }) }), !mine && !grouped && state.conversation?.kind === 'group' && _jsx(Text, { style: { color: ink, fontSize: 12, fontWeight: '600', marginBottom: 5 }, children: message.deleted ? uiText("Former member") : participants?.[message.senderId]?.name ?? uiText("Member") }), message.custom || extra?.address || extra?.weather || extra?.call || voice || message.kind === 'poll' ? bodyContent : _jsx(Pressable, { accessibilityRole: message.kind === 'text' ? undefined : 'button', accessibilityLabel: message.kind === 'text' ? undefined : uiText('{kind}: {name}', { kind: uiText(mediaNames[message.kind]), name: message.media?.fileName ?? uiText('Open attachment') }), disabled: busy, onLongPress: menu, onPress: message.kind === 'text' ? () => { if (quoteGesture.suppressPress())
|
|
531
594
|
return; if (extra?.address)
|
|
532
595
|
extraRef.current?.open();
|
|
533
596
|
else
|
|
534
|
-
socialRef.current?.open(); } : () => void open(), children: bodyContent }), !discussionPreview && state.discussionAvailable && !!message.replyCount && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: message.replyCount + ' ' + (message.replyCount === 1 ? 'reply' : 'replies'), onPress: () => openDiscussion(message.id), style: { minHeight: 32, justifyContent: 'center' }, children: _jsxs(Text, { style: { color: c.accent, fontSize: 12, fontWeight: '600' }, children: [message.replyCount, " ", message.replyCount === 1 ? uiText("reply") : uiText("replies")] }) }), message.kind !== 'text' && !!message.text && _jsx(View, { testID: voice ? 'voice-message-caption' : undefined, style: voice && !showingTransform ? { maxWidth: 220, alignSelf: mine ? 'flex-end' : 'flex-start', marginTop: 1, paddingTop: 4, paddingBottom: 1, borderRadius: 14, ...(mine ? { borderBottomEndRadius: 3 } : { borderBottomStartRadius: 3 }), backgroundColor: mine ? c.outgoing : c.incoming } : visual ? { backgroundColor: mine ? c.outgoing : c.incoming, ...corners, borderTopLeftRadius: 0, borderTopRightRadius: 0, paddingHorizontal: 6, paddingVertical: 3, ...(circleStatus ? { paddingEnd: 24 } : {}) } : undefined, children: _jsx(Text, { testID: "attachment-caption", selectable: true, onLongPress: menu, style: { color: ink, fontSize: 16, lineHeight: 22, marginTop: voice ? 0 : 2, textAlign:
|
|
535
|
-
return _jsxs(View, { ...(Platform.OS === 'web' ? { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onContextMenu: (event) => { event.preventDefault(); menu(); } } : {}), style: { width: '100%', position: 'relative', marginTop: messageGap + (message.reactions?.length ? 16 : 0), marginBottom: 0 }, children: [quoteGesture.infoLoaded && _jsxs(Animated.View, { pointerEvents: "none", testID: "message-info-reveal", accessible: false, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, minHeight: 52, width: messageInfoRevealWidth, justifyContent: 'center', ...(mine ? { start: 0, alignItems: 'flex-start' } : { end: 0, alignItems: 'flex-end' }), opacity: quoteGesture.infoOpacity }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("SENT:") }), _jsx(Text, { style: { color: c.foreground, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: messageTimeLabel(message, ui.formatMessageTime, uiText) })] }), mine && state.settings?.features.readReceipts && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("READ:") }), _jsx(Text, { style: { color: message.readAt ? c.foreground : c.secondary, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: message.readAt ? ui.formatMessageTime(message.readAt) : uiText("Not yet") })] })] }), quoting && _jsxs(Animated.View, { pointerEvents: "none", ...(Platform.OS === 'web' ? { 'aria-hidden': true } : { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' }), testID: `quote-reveal-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, ...(mine ? { end: 0 } : { start: 0 }), width: messageReplyRevealWidth, minHeight: 52, gap: 3, alignItems: 'center', justifyContent: 'center', opacity: quoteGesture.revealOpacity }, children: [_jsx(View, { style: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center', backgroundColor: chatSurface(c.background), borderWidth: 1.5, borderColor: c.secondary + '40' }, children: _jsx(MessageIcon, { name: "quote", color: c.accent, size: 30 }) }), _jsx(Text, { style: { color: c.secondary, fontSize: 10, fontWeight: '900' }, children: uiText("QUOTE MESSAGE") })] }), _jsxs(Animated.View, { ref: node => { anchor.current = node; if (quoteGesture.webRef)
|
|
597
|
+
socialRef.current?.open(); } : () => void open(), children: bodyContent }), !discussionPreview && state.discussionAvailable && !!message.replyCount && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: message.replyCount + ' ' + (message.replyCount === 1 ? 'reply' : 'replies'), onPress: () => openDiscussion(message.id), style: { minHeight: 32, justifyContent: 'center' }, children: _jsxs(Text, { style: { color: c.accent, fontSize: 12, fontWeight: '600' }, children: [message.replyCount, " ", message.replyCount === 1 ? uiText("reply") : uiText("replies")] }) }), message.kind !== 'text' && !!message.text && _jsx(View, { testID: voice ? 'voice-message-caption' : undefined, style: voice && !showingTransform ? { maxWidth: 220, alignSelf: mine ? 'flex-end' : 'flex-start', marginTop: 1, paddingTop: 4, paddingBottom: 1, borderRadius: 14, ...(mine ? { borderBottomEndRadius: 3 } : { borderBottomStartRadius: 3 }), backgroundColor: mine ? c.outgoing : c.incoming } : visual ? { backgroundColor: mine ? c.outgoing : c.incoming, ...corners, borderTopLeftRadius: 0, borderTopRightRadius: 0, paddingHorizontal: 6, paddingVertical: 3, ...(mine ? { paddingRight: 12 } : { paddingLeft: 12 }), ...(circleStatus ? { paddingEnd: 24 } : {}) } : undefined, children: _jsx(Text, { testID: "attachment-caption", selectable: true, onLongPress: menu, style: { color: ink, fontSize: 16, lineHeight: 22, marginTop: voice ? 0 : 2, textAlign: 'left', alignSelf: 'stretch', paddingHorizontal: voice || message.kind === 'document' ? 8 : 2, ...(voice || message.kind === 'document' ? (mine ? { paddingRight: 14 } : { paddingLeft: 14 }) : {}), paddingBottom: 2 }, children: renderText(message.text) }) }), deliveryStatus && message.kind !== 'text' && message.kind !== 'poll' && !voice && !visual && _jsx(View, { style: { marginTop: 4, alignSelf: 'flex-end' }, children: footer }), (!voice || showingTransform) && languageActions, (!voice || showingTransform) && insideMeta, components?.MessageFooter && !message.deleted && _jsx(components.MessageFooter, { ...regionProps }), transforming && !voice && _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: ink, fontSize: 11 }, children: uiText("Converting…") }), !!error && _jsxs(MessagingPopup, { screen: "alerts", compact: true, contentWidth: 640, title: uiText("Message"), foreground: c.foreground, background: chatSurface(c.background), onClose: () => setError(''), children: [_jsx(Text, { accessibilityRole: "alert", style: { color: messagingPopupColors.foreground, fontSize: 15, lineHeight: 21, marginTop: 8 }, children: error }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Close message alert"), onPress: () => setError(''), style: { alignSelf: 'flex-end', minHeight: 44, justifyContent: 'center', paddingHorizontal: 8, marginTop: 8 }, children: _jsx(Text, { style: { color: c.accent }, children: uiText("OK") }) })] }), (showingTransform || message.custom || extra?.weather || extra?.call || message.kind === 'text' || message.kind === 'poll') && sendRetry, Platform.OS === 'web' && !mine && canInteract && state.settings?.features.reactions && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("React to message"), onFocus: () => setHovered(true), onBlur: () => setHovered(false), onPress: openMenu, style: { opacity: hovered || actions ? 1 : 0, position: 'absolute', top: 6, ...(mine ? { left: -34 } : { right: -34 }), width: 32, height: 32, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "reaction", color: c.secondary, size: 20 }) }), !!message.reactions?.length && _jsx(View, { testID: "message-reaction-badge", pointerEvents: "none", accessibilityLabel: message.reactions.slice(-3).map(r => r.emoji).join(' '), style: { position: 'absolute', zIndex: 41, top: -16, ...(mine ? { end: -9 } : { start: -9 }), minWidth: 30, height: 20, alignItems: 'center', justifyContent: 'center' }, children: _jsx(Text, { style: { fontSize: 16, lineHeight: 20 }, children: message.reactions.slice(-3).map(r => r.emoji).join(' ') }) }), _jsx(MessageMenu, { visible: actions, position: menuPosition, screenHeight: viewport.height, mine: mine, reactions: reactionPicker, onClose: () => setActions(false), onDismiss: menuDismissed, children: actions && _jsxs(_Fragment, { children: [quoting && _jsx(MessageMenuRow, { icon: "quote", label: uiText("Quote message"), onPress: () => { setActions(false); setReply(message); } }), !discussionPreview && state.discussionAvailable && !pendingStatus && !message.deleted && _jsx(MessageMenuRow, { icon: "quote", label: uiText("Replies"), onPress: () => leaveMenu(() => openDiscussion(message.threadRoot ?? message.id)) }), state.discussionAvailable && canInteract && state.conversation?.ownerId === userId && _jsx(MessageMenuRow, { icon: "bookmark", label: message.pinned ? uiText("Unpin for group") : uiText("Pin for group"), onPress: () => { setActions(false); void client.pinMessage(message.id, !message.pinned).catch(e => setError(e instanceof Error ? e.message : uiText("The pin could not change."))); } }), canCopy && _jsx(MessageMenuRow, { icon: "copy", label: uiText("Copy"), onPress: () => { setActions(false); void (copyText ? copyText(message.text) : navigator.clipboard.writeText(message.text)).catch(() => setError(uiText("The text could not be copied."))); } }), canInteract && client.canForward(message) && _jsx(MessageMenuRow, { icon: "redo", label: uiText("Forward"), onPress: () => leaveMenu(() => setForwarding([message])) }), !pendingStatus && !message.deleted && message.kind !== 'poll' && client.hasSavedMessages() && _jsx(MessageMenuRow, { icon: "bookmark", label: saved.some(r => r.key === savedMessageKey(wholeMessage)) ? uiText("Remove from Saved") : uiText(message.part ? "Save both items" : "Save"), disabled: saving, onPress: () => { setActions(false); void toggleSaved(wholeMessage); } }), canChange && !message.custom && message.kind !== 'poll' && state.settings?.features[message.kind] && _jsx(MessageMenuRow, { icon: "edit", label: uiText(message.part ? "Edit both items" : "Edit"), onPress: () => { setActions(false); setEditing(wholeMessage); } }), !mine && state.conversation?.safety?.canReport && _jsx(MessageMenuRow, { icon: "flag", label: uiText("Report"), danger: true, onPress: () => leaveMenu(() => setReportOpen(true)) }), !pendingStatus && !message.deleted && ['owner', 'moderator'].includes(state.conversation?.roomRole ?? '') && _jsx(MessageMenuRow, { icon: "trash", label: uiText('Remove from group'), danger: true, onPress: () => leaveMenu(() => setRoomRemoval(true)) }), canChange && _jsx(MessageMenuRow, { icon: "trash", label: uiText(message.part ? "Delete both items" : "Delete"), danger: true, onPress: () => leaveMenu(() => setDeleting([wholeMessage])) }), (pendingStatus === 'failed' || pendingStatus === 'queued') && _jsx(MessageMenuRow, { icon: "trash", label: uiText("Remove unsent message"), danger: true, onPress: () => { setActions(false); void client.discardPending(message.clientMessageId).catch(() => setError(uiText("The unsent message could not be removed."))); } }), !pendingStatus && onMessageOptions && _jsx(MessageMenuRow, { icon: "more", label: uiText("More options"), onPress: () => leaveMenu(() => onMessageOptions(message)) }), !pendingStatus && !message.deleted && _jsx(MessageMenuRow, { icon: "check", label: uiText(message.part ? "Select both items" : "Select Multiple"), divider: true, onPress: () => { setActions(false); setSelection([wholeMessage]); Keyboard.dismiss(); } })] }) }), roomRemoval && _jsx(MessagingRoomRemoval, { client: client, message: message, accent: c.accent, onClose: () => setRoomRemoval(false) }), reportOpen && _jsx(MessagingSafety, { client: client, state: state, appearance: design, name: participants?.[message.senderId]?.name ?? 'Contact', messageId: message.id, onClose: () => setReportOpen(false) })] });
|
|
598
|
+
return _jsxs(View, { ...(Platform.OS === 'web' ? { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onContextMenu: (event) => { event.preventDefault(); menu(); } } : {}), style: { width: '100%', position: 'relative', marginTop: messageGap + (message.reactions?.length ? 16 : 0), marginBottom: 0 }, children: [quoteGesture.infoLoaded && _jsxs(Animated.View, { pointerEvents: "none", testID: "message-info-reveal", accessible: false, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, minHeight: 52, width: messageInfoRevealWidth, justifyContent: 'center', ...(mine ? { start: 0, alignItems: 'flex-start' } : { end: 0, alignItems: 'flex-end' }), opacity: quoteGesture.infoOpacity }, children: [_jsx(_Fragment, { children: timePosition === 'slide' && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("SENT:") }), _jsx(Text, { testID: "message-slide-time", style: { color: c.foreground, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: messageTimeLabel(message, ui.formatMessageTime, uiText) })] }) }), mine && state.settings?.features.readReceipts && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("READ:") }), _jsx(Text, { style: { color: message.readAt ? c.foreground : c.secondary, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: message.readAt ? ui.formatMessageTime(message.readAt) : uiText("Not yet") })] })] }), quoting && _jsxs(Animated.View, { pointerEvents: "none", ...(Platform.OS === 'web' ? { 'aria-hidden': true } : { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' }), testID: `quote-reveal-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, ...(mine ? { end: 0 } : { start: 0 }), width: messageReplyRevealWidth, minHeight: 52, gap: 3, alignItems: 'center', justifyContent: 'center', opacity: quoteGesture.revealOpacity }, children: [_jsx(View, { style: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center', backgroundColor: chatSurface(c.background), borderWidth: 1.5, borderColor: c.secondary + '40' }, children: _jsx(MessageIcon, { name: "quote", color: c.accent, size: 30 }) }), _jsx(Text, { style: { color: c.secondary, fontSize: 10, fontWeight: '900' }, children: uiText("QUOTE MESSAGE") })] }), _jsxs(Animated.View, { ref: node => { anchor.current = node; if (quoteGesture.webRef)
|
|
536
599
|
quoteGesture.webRef.current = node; }, ...quoteGesture.handlers, accessibilityActions: quoting ? [{ name: "quote", label: uiText("Quote message") }] : undefined, onAccessibilityAction: event => { if (quoting && event.nativeEvent.actionName === "quote")
|
|
537
|
-
setReply(message); }, testID: `message-${message.kind}-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.webStyle, transform: [{ translateX: quoteGesture.offset }], ...(Platform.OS === "web" && !pendingStatus ? { touchAction: "pan-y", userSelect: "none" } : {}), alignSelf: mine ? 'flex-end' : 'flex-start', maxWidth: `${design.screens?.chat?.messageWidth ?? 88}%`, backgroundColor: visual ? 'transparent' : mine ? c.outgoing : c.incoming, ...corners, ...(
|
|
600
|
+
setReply(message); }, testID: `message-${message.kind}-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.webStyle, transform: [{ translateX: quoteGesture.offset }], ...(Platform.OS === "web" && !pendingStatus ? { touchAction: "pan-y", userSelect: "none" } : {}), alignSelf: mine ? 'flex-end' : 'flex-start', maxWidth: `${design.screens?.chat?.messageWidth ?? 88}%`, backgroundColor: visual ? 'transparent' : mine ? c.outgoing : c.incoming, ...corners, ...(topTail ? (mine ? { borderTopRightRadius: 0 } : { borderTopLeftRadius: 0 }) : {}), padding: visual ? 0 : 6, paddingBottom: visual ? 0 : canTranscript || canTranslate ? 3 : 6, boxShadow: bigEmoji ? undefined : '0 1px 1px #00000010', ...((voice || message.kind === 'document') && !showingTransform ? { padding: 0, paddingBottom: 0, boxShadow: undefined, ...(voice ? { backgroundColor: 'transparent' } : {}) } : {}), ...(message.kind === 'poll' ? { backgroundColor: chatSurface(c.background), borderWidth: 1, borderColor: c.accent + '60', paddingHorizontal: 8, paddingTop: 4, paddingBottom: 2 } : {}), ...(bigEmoji ? { backgroundColor: 'transparent', paddingHorizontal: 4, paddingTop: 0, paddingBottom: 0 } : {}), ...(extra?.address || socialReady ? { flexDirection: mine ? 'row-reverse' : 'row', alignItems: 'center', gap: 8, padding: 0, paddingBottom: 0, backgroundColor: 'transparent', boxShadow: undefined } : {}), ...(paddedBubble ? (mine ? { paddingRight: quoteInset + 6 } : { paddingLeft: quoteInset + 6 }) : {}) }, children: [topTail && _jsx(View, { testID: "message-top-tail", pointerEvents: "none", style: { position: 'absolute', top: 0, ...(mine ? { right: -7 } : { left: -7 }), width: 0, height: 0, borderTopWidth: 10, borderTopColor: hasQuote ? quoteBackground : mine ? c.outgoing : c.incoming, ...(mine ? { borderRightWidth: 8, borderRightColor: 'transparent' } : { borderLeftWidth: 8, borderLeftColor: 'transparent' }) } }), extra?.address ? extraCard : socialReady ? socialCard : bubbleBody] }), notice.text && _jsx(Text, { testID: "message-delivery-notice", accessibilityLiveRegion: "polite", style: { alignSelf: 'flex-end', maxWidth: `${design.screens?.chat?.messageWidth ?? 88}%`, color: c.secondary, fontSize: 11, lineHeight: 15, paddingHorizontal: 3, marginTop: 3 }, children: uiText(notice.text) }), belowMeta && _jsx(Animated.View, { pointerEvents: "none", style: { ...quoteGesture.webStyle, transform: [{ translateX: quoteGesture.offset }], alignSelf: mine ? 'flex-end' : 'flex-start', maxWidth: `${design.screens?.chat?.messageWidth ?? 88}%`, paddingHorizontal: 3, marginTop: 3 }, children: belowMeta })] });
|
|
538
601
|
});
|
|
539
602
|
export function MessageDeletion({ messages, onClose }) {
|
|
540
603
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
@@ -576,7 +639,7 @@ const MessagingHistoryRow = React.memo(function MessagingHistoryRow({ item, prev
|
|
|
576
639
|
const date = new Date(item.createdAt), start = !previous || date.toDateString() !== new Date(previous.createdAt).toDateString();
|
|
577
640
|
const checked = selection.some(m => m.id === item.id), selectable = selection.length > 0 && !item.pendingStatus && !item.deleted;
|
|
578
641
|
const toggle = () => setSelection(checked ? selection.filter(m => m.id !== item.id) : [...selection, item]);
|
|
579
|
-
return _jsxs(View, { testID: highlighted ? 'focused-message' : undefined, style: highlighted || checked ? { backgroundColor: design.colors.accent + '20', borderRadius: 8 } : undefined, children: [start && design.screens?.chat?.showDates !== false && _jsx(Text, { testID: "messaging-date-separator", style: { alignSelf: 'center', fontSize: design.screens?.chat?.dateSize ?? 12, color: design.screens?.chat?.dateText ?? design.colors.secondary, backgroundColor: design.screens?.chat?.dateBackground ?? chatSurface(design.colors.background), borderRadius: 7, paddingHorizontal: 12, paddingVertical: 5, marginTop: 4, marginBottom: 10 }, children: date.toDateString() === new Date().toDateString() ? uiText("Today") : date.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric' }) }), _jsx(View, { style: { paddingLeft: selection.length ? 32 : 0 }, pointerEvents: selection.length ? 'none' : 'auto', accessibilityElementsHidden: selection.length > 0, importantForAccessibility: selection.length ? 'no-hide-descendants' : 'auto', ...(Platform.OS === 'web' && selection.length ? { 'aria-hidden': true } : {}), children: Message ? _jsx(Message, { message: item }) : _jsx(
|
|
642
|
+
return _jsxs(View, { testID: highlighted ? 'focused-message' : undefined, style: highlighted || checked ? { backgroundColor: design.colors.accent + '20', borderRadius: 8 } : undefined, children: [start && design.screens?.chat?.showDates !== false && _jsx(Text, { testID: "messaging-date-separator", style: { alignSelf: 'center', fontSize: design.screens?.chat?.dateSize ?? 12, color: design.screens?.chat?.dateText ?? design.colors.secondary, backgroundColor: design.screens?.chat?.dateBackground ?? chatSurface(design.colors.background), borderRadius: 7, paddingHorizontal: 12, paddingVertical: 5, marginTop: 4, marginBottom: 10 }, children: date.toDateString() === new Date().toDateString() ? uiText("Today") : date.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric' }) }), _jsx(View, { style: { paddingLeft: selection.length ? 32 : 0 }, pointerEvents: selection.length ? 'none' : 'auto', accessibilityElementsHidden: selection.length > 0, importantForAccessibility: selection.length ? 'no-hide-descendants' : 'auto', ...(Platform.OS === 'web' && selection.length ? { 'aria-hidden': true } : {}), children: Message ? _jsx(Message, { message: item }) : _jsx(MessagingBubbleItems, { message: item, pendingStatus: item.pendingStatus, ui: bubbleUI }) }), selectable && _jsx(Pressable, { accessibilityRole: "checkbox", accessibilityLabel: uiText('Select message: {message}', { message: item.text || item.media?.fileName || uiText(mediaNames[item.kind] || 'Message') }), accessibilityState: { checked }, onPress: toggle, style: { position: 'absolute', inset: 0, justifyContent: 'center' }, children: _jsx(View, { style: { width: 24, height: 24, borderRadius: 12, borderWidth: 1, borderColor: design.colors.accent, backgroundColor: checked ? design.colors.accent : design.colors.background, alignItems: 'center', justifyContent: 'center' }, children: checked && _jsx(MessageIcon, { name: "check", size: 16, color: "#ffffff" }) }) })] });
|
|
580
643
|
});
|
|
581
644
|
const conversationReadingPositions = new WeakMap();
|
|
582
645
|
export function MessagingList() {
|
|
@@ -589,6 +652,9 @@ export function MessagingList() {
|
|
|
589
652
|
createdAt: p.createdAt ?? new Date().toISOString(), readAt: null, pendingStatus: p.status,
|
|
590
653
|
}))]).reverse(), [state.messages, state.pending, state.conversationId, userId]);
|
|
591
654
|
const list = useRef(null);
|
|
655
|
+
const historyInteraction = useRef({ conversationId: state.conversationId, dragged: false });
|
|
656
|
+
if (historyInteraction.current.conversationId !== state.conversationId)
|
|
657
|
+
historyInteraction.current = { conversationId: state.conversationId, dragged: false };
|
|
592
658
|
const nearLatest = useRef(true), lastNewest = useRef(''), lastPending = useRef('');
|
|
593
659
|
const [away, setAway] = useState(false), [newMessages, setNewMessages] = useState(false);
|
|
594
660
|
const [historyHeight, setHistoryHeight] = useState(0);
|
|
@@ -693,7 +759,7 @@ export function MessagingList() {
|
|
|
693
759
|
// Existing Bridge receipts belong to individual messages. A visible
|
|
694
760
|
// thumbnail is not a read/heard event; its viewer reports consumption.
|
|
695
761
|
if (ui.state.chronologicalHistory && ui.state.attachmentReceiptsAvailable) {
|
|
696
|
-
for (const item of visible.filter(m => m.kind === 'text'
|
|
762
|
+
for (const item of visible.filter(m => !m.deleted && (m.kind === 'text' ? !m.readAt : !!m.text && !m.textReadAt))) {
|
|
697
763
|
const key = item.conversationId + ':' + item.id;
|
|
698
764
|
if (bridgeReads.current.has(key))
|
|
699
765
|
continue;
|
|
@@ -748,15 +814,24 @@ export function MessagingList() {
|
|
|
748
814
|
target.retryTimer = setTimeout(() => { target.retryTimer = undefined; if (scrollTarget.current === target)
|
|
749
815
|
list.current?.scrollToIndex({ index: target.index, viewPosition: .5, animated: false }); }, 150);
|
|
750
816
|
list.current?.scrollToOffset({ offset: info.averageItemLength * info.index, animated: false });
|
|
751
|
-
}, onScrollBeginDrag: () => { scrollTarget.current = null; scrollingStarted(); },
|
|
817
|
+
}, onScrollBeginDrag: () => { historyInteraction.current.dragged = true; scrollTarget.current = null; scrollingStarted(); }, ...(Platform.OS === 'web' ? {
|
|
818
|
+
// Browser wheel/keyboard/scrollbar input does not emit native drag events.
|
|
819
|
+
onWheel: () => { historyInteraction.current.dragged = true; },
|
|
820
|
+
onPointerDown: () => { historyInteraction.current.dragged = true; },
|
|
821
|
+
onKeyDown: (event) => { if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown', 'Home', 'End', ' '].includes(event.key))
|
|
822
|
+
historyInteraction.current.dragged = true; },
|
|
823
|
+
} : {}), onScrollEndDrag: scrollingSettled, onMomentumScrollBegin: scrollingStarted, onMomentumScrollEnd: scrollingSettled, onScroll: event => { scrollingStarted(); scrollingSettled(); const near = event.nativeEvent.contentOffset.y < 80; nearLatest.current = near; setAway(!near); if (near)
|
|
752
824
|
setNewMessages(false); }, scrollEventThrottle: 32, data: items, inverted: true, keyExtractor: (m) => m.senderId + ':' + m.clientMessageId, style: { flex: 1 }, keyboardShouldPersistTaps: "handled", contentContainerStyle: { paddingHorizontal: 12, paddingVertical: 10, paddingTop: context.extrasState?.privacyLens ? privacyReadingStripHeight + 10 : 10, flexGrow: 1, justifyContent: context.extrasState?.privacyLens ? "flex-start" : "flex-end" }, onViewableItemsChanged: onVisible, viewabilityConfig: {
|
|
753
825
|
itemVisiblePercentThreshold: 50,
|
|
754
826
|
minimumViewTime: 500,
|
|
755
827
|
}, renderItem: renderHistoryItem, onEndReached: () => {
|
|
756
|
-
|
|
828
|
+
// Native lists can report their end before the first content layout.
|
|
829
|
+
// Do not load successive older pages while the opening screen settles.
|
|
830
|
+
// Short histories still expose the explicit “Load earlier messages”.
|
|
831
|
+
if (historyInteraction.current.dragged && state.hasMore && !state.loading && !state.historyError) {
|
|
757
832
|
void client.loadOlder().catch(() => { });
|
|
758
833
|
}
|
|
759
|
-
}, onEndReachedThreshold: 0.2, ListHeaderComponent: state.historyWindow && state.hasNewer ? _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Load newer messages"), disabled: state.loading, onPress: () => void client.loadNewer().catch(() => { }), style: { padding: 10, minHeight: 44, alignItems: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Load newer messages") }) }) : null, ListFooterComponent: _jsxs(_Fragment, { children: [state.messages.length > 0 && (state.loading || state.historyError || state.hasMore) ? _jsx(View, { style: { padding: 10, alignItems: 'center' }, children: state.loading ? _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading earlier messages"), color: design.colors.accent }) : _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: state.historyError ? uiText("Retry earlier messages") : uiText("Load earlier messages"), onPress: () => void client.loadOlder().catch(() => { }), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: state.historyError ? uiText("Earlier messages could not load. Retry") : uiText("Load earlier messages") }) }) }) : null, context.extrasState?.privacyLens && _jsx(View, { testID: "privacy-history-spacer", style: { height: Math.max(0, historyHeight - privacyReadingStripHeight) } })] }), ListEmptyComponent: _jsx(
|
|
834
|
+
}, onEndReachedThreshold: 0.2, ListHeaderComponent: _jsxs(_Fragment, { children: [(state.heldMessages ?? []).map(item => _jsxs(View, { testID: "held-message", style: { padding: 12, marginVertical: 4, borderWidth: 1, borderColor: design.colors.secondary, borderRadius: 8 }, children: [_jsx(Text, { style: { color: design.colors.foreground }, children: item.content.text ?? item.content.media?.fileName ?? 'Message' }), _jsx(Text, { accessibilityLiveRegion: "polite", style: { color: design.colors.secondary, fontSize: 12, marginTop: 4 }, children: uiText(item.state === 'pending' ? 'Waiting for review — not delivered' : item.state === 'approved' ? 'Approved — waiting for delivery' : item.state === 'rejected' ? 'Not approved — not delivered' : 'Review expired — not delivered') })] }, item.id)), state.historyWindow && state.hasNewer ? _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Load newer messages"), disabled: state.loading, onPress: () => void client.loadNewer().catch(() => { }), style: { padding: 10, minHeight: 44, alignItems: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Load newer messages") }) }) : null] }), ListFooterComponent: _jsxs(_Fragment, { children: [state.messages.length > 0 && (state.loading || state.historyError || state.hasMore) ? _jsx(View, { style: { padding: 10, minHeight: 64, justifyContent: 'center', alignItems: 'center' }, children: state.loading ? _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading earlier messages"), color: design.colors.accent }) : _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: state.historyError ? uiText("Retry earlier messages") : uiText("Load earlier messages"), onPress: () => void client.loadOlder().catch(() => { }), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: state.historyError ? uiText("Earlier messages could not load. Retry") : uiText("Load earlier messages") }) }) }) : null, context.extrasState?.privacyLens && _jsx(View, { testID: "privacy-history-spacer", style: { height: Math.max(0, historyHeight - privacyReadingStripHeight) } })] }), ListEmptyComponent: state.loading ? _jsx(MessagingLoadingMessages, { color: design.colors.secondary }, state.conversationId) : state.error ? null : _jsx(Text, { style: { color: design.colors.secondary }, children: design.labels.empty }) }, state.conversationId + (context.extrasState?.privacyLens ? "privacy-reading" : "regular-history")) }), (away || state.historyWindow) && _jsx(Animated.View, { testID: "latest-message-control", pointerEvents: showLatest ? 'auto' : 'none', accessibilityElementsHidden: !showLatest, importantForAccessibility: showLatest ? 'auto' : 'no-hide-descendants', ...(Platform.OS === 'web' ? { 'aria-hidden': !showLatest } : {}), style: { position: 'absolute', left: '50%', marginLeft: -22, bottom: 8, opacity: Platform.OS === 'web' ? (showLatest ? 1 : 0) : latestOpacity, ...(Platform.OS === 'web' ? { transitionProperty: 'opacity', transitionDuration: '200ms' } : {}) }, children: _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: newMessages ? uiText("New messages. Go to latest") : uiText("Go to latest message"), disabled: !showLatest, onPress: () => jumpToLatest(), style: { width: 44, height: 44, borderRadius: 22, borderWidth: 1.5, borderColor: design.colors.accent, backgroundColor: chatSurface(design.colors.background), justifyContent: 'center', alignItems: 'center' }, children: _jsx(MessageIcon, { name: "arrow-down", color: design.colors.accent, size: 26 }) }) }), _jsx(MessageSelection, {})] }));
|
|
760
835
|
}
|
|
761
836
|
/** One horizontal media row on phones and in the browser preview. */
|
|
762
837
|
function AttachmentStrip({ children, label, height, recent = false }) {
|
|
@@ -884,7 +959,7 @@ export function MessagingComposer() {
|
|
|
884
959
|
const outgoing = {
|
|
885
960
|
...content,
|
|
886
961
|
...(content.text && mentionsFor(content.text).length ? { mentions: mentionsFor(content.text) } : {}),
|
|
887
|
-
...(reply && features?.replies ? { replyTo: reply.id, ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {}),
|
|
962
|
+
...(reply && features?.replies ? { replyTo: reply.id, ...(reply.part ? { replyPart: reply.part } : {}), ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {}),
|
|
888
963
|
};
|
|
889
964
|
const prepare = content.media && prepareAttachment && content.kind !== 'text' && content.kind !== 'poll'
|
|
890
965
|
? async () => ({ ...outgoing, media: await prepareAttachment(content.kind, content.media) })
|
|
@@ -925,10 +1000,10 @@ export function MessagingComposer() {
|
|
|
925
1000
|
return;
|
|
926
1001
|
inFlight.current = true;
|
|
927
1002
|
const conversationId = state.conversationId;
|
|
928
|
-
const quote = reply && features?.replies ? { replyTo: reply.id, ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {};
|
|
1003
|
+
const quote = reply && features?.replies ? { replyTo: reply.id, ...(reply.part ? { replyPart: reply.part } : {}), ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {};
|
|
929
1004
|
const attachments = [...selectedRef.current];
|
|
930
1005
|
const batchId = attachments.length > 1 ? 'batch-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2) : null;
|
|
931
|
-
const outgoing = attachments
|
|
1006
|
+
const outgoing = composeMessageItems(attachments, draft, quote, mentionsFor(draft), batchId ?? '');
|
|
932
1007
|
setSelected([]);
|
|
933
1008
|
setDraft('');
|
|
934
1009
|
setMentionIds([]);
|
|
@@ -957,7 +1032,7 @@ export function MessagingComposer() {
|
|
|
957
1032
|
let requested = false;
|
|
958
1033
|
try {
|
|
959
1034
|
const attachments = [...selectedRef.current];
|
|
960
|
-
const quote = reply && features?.replies ? { replyTo: reply.id, ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {};
|
|
1035
|
+
const quote = reply && features?.replies ? { replyTo: reply.id, ...(reply.part ? { replyPart: reply.part } : {}), ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {};
|
|
961
1036
|
const signature = JSON.stringify({ draft, attachments, quote });
|
|
962
1037
|
let attempt = scheduleAttempt.current;
|
|
963
1038
|
if (!attempt || attempt.signature !== signature) {
|
|
@@ -1081,7 +1156,7 @@ export function MessagingComposer() {
|
|
|
1081
1156
|
function removeSelected(id) { const item = selectedRef.current.find(item => item.id === id); setSelected(items => items.filter(item => item.id !== id)); if (item && (!editing || item.media.assetId !== editing.media?.assetId))
|
|
1082
1157
|
void releaseAttachment?.(item.media); }
|
|
1083
1158
|
function renderAttachments(voiceReview, blocked = busy) {
|
|
1084
|
-
return selected.length > 0 || voiceReview ? _jsxs(AttachmentStrip, { label: uiText("Pending attachments"), height: selected.some(item => item.kind === 'document') ? 104 : 86, children: [selected.map(item => item.kind === 'voice' && item.media.assetId !== editing?.media?.assetId && components?.VoiceAttachment ? _jsx(components.VoiceAttachment, { media: item.media, appearance: design, disabled: blocked, onRemove: () => removeSelected(item.id) }, item.id) : _jsxs(View, { style: { width: 88, paddingTop: 8, paddingRight: 10 }, children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Preview {name}', { name: item.media.fileName ?? uiText(mediaNames[item.kind]) }), disabled: blocked || !openAttachment, onPress: () => void openAttachment?.({ ...item, id: item.id, clientMessageId: item.id, conversationId: state.conversationId, senderId: userId, createdAt: new Date().toISOString(), readAt: null }).catch(() => setError(uiText("This attachment could not be opened."))), style: { width: 76, height: 76, borderRadius: 9, overflow: 'hidden', backgroundColor: c.incoming, borderWidth: 1, borderColor: c.secondary + '40', alignItems: 'center', justifyContent: 'center' }, children: [item.thumbnail ? _jsx(Image, { source: { uri: item.thumbnail }, accessibilityLabel: item.media.fileName ?? uiText(mediaNames[item.kind]), resizeMode: "
|
|
1159
|
+
return selected.length > 0 || voiceReview ? _jsxs(AttachmentStrip, { label: uiText("Pending attachments"), height: selected.some(item => item.kind === 'document') ? 104 : 86, children: [selected.map(item => item.kind === 'voice' && item.media.assetId !== editing?.media?.assetId && components?.VoiceAttachment ? _jsx(components.VoiceAttachment, { media: item.media, appearance: design, disabled: blocked, onRemove: () => removeSelected(item.id) }, item.id) : _jsxs(View, { style: { width: 88, paddingTop: 8, paddingRight: 10 }, children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Preview {name}', { name: item.media.fileName ?? uiText(mediaNames[item.kind]) }), disabled: blocked || !openAttachment, onPress: () => void openAttachment?.({ ...item, id: item.id, clientMessageId: item.id, conversationId: state.conversationId, senderId: userId, createdAt: new Date().toISOString(), readAt: null }).catch(() => setError(uiText("This attachment could not be opened."))), style: { width: 76, height: 76, borderRadius: 9, overflow: 'hidden', backgroundColor: c.incoming, borderWidth: 1, borderColor: c.secondary + '40', alignItems: 'center', justifyContent: 'center' }, children: [item.thumbnail ? _jsx(Image, { source: { uri: item.thumbnail }, accessibilityLabel: item.media.fileName ?? uiText(mediaNames[item.kind]), resizeMode: "contain", style: { width: '100%', height: '100%' } }) : _jsx(MessageIcon, { name: item.kind === 'voice' ? 'mic' : item.kind, color: c.accent, size: 28 }), item.kind === 'video' && _jsx(View, { style: { position: 'absolute', bottom: 0, left: 0, right: 0, padding: 4, backgroundColor: '#0009' }, children: _jsx(Text, { style: { color: '#fff', fontSize: 10 }, children: duration(item.media.durationMs) }) })] }), item.kind === 'document' && _jsx(Text, { numberOfLines: 1, style: { fontSize: 10, color: c.foreground, marginTop: 3 }, children: item.media.fileName ?? uiText(mediaNames[item.kind]) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Remove {name}', { name: item.media.fileName ?? uiText(mediaNames[item.kind]) }), disabled: blocked, onPress: () => removeSelected(item.id), style: { position: 'absolute', right: 0, top: 0, width: 30, height: 30, alignItems: 'center', justifyContent: 'center' }, children: _jsx(View, { style: { backgroundColor: c.foreground, borderRadius: 11, padding: 3 }, children: _jsx(MessageIcon, { name: "close", size: 16, color: c.background }) }) })] }, item.id)), voiceReview] }) : null;
|
|
1085
1160
|
}
|
|
1086
1161
|
function renderTextComposer(voice = { hasVoice: false, blocked: false }) {
|
|
1087
1162
|
const blocked = voice.blocked || busy;
|
|
@@ -1111,31 +1186,59 @@ export function MessagingComposer() {
|
|
|
1111
1186
|
attachmentActions.push({ key: 'poll', label: state.conversation?.kind === 'group' ? uiText("Poll") : uiText("Yes/No question"), icon: 'poll', run: () => setPollOpen(true) });
|
|
1112
1187
|
if (!editing && weatherAllowed)
|
|
1113
1188
|
attachmentActions.push({ key: 'weather', label: uiText("Weather"), icon: 'weather', run: () => { setBusy(true); setError(''); void extras?.sendWeather().then(() => client.refresh()).catch(e => setError(e instanceof Error ? e.message : uiText("Weather could not be sent."))).finally(() => setBusy(false)); } });
|
|
1189
|
+
// No settings means access is still unknown (or the screen is showing its
|
|
1190
|
+
// request error). Do not briefly announce a disabled conversation on open.
|
|
1191
|
+
// Keep the normal 44-point composer plus its vertical padding reserved.
|
|
1192
|
+
if (!state.settings || state.offline?.refreshing)
|
|
1193
|
+
return _jsx(View, { testID: "messaging-composer-pending", accessibilityState: { busy: state.loading || !!state.offline?.refreshing }, ...(Platform.OS === 'web' ? { 'aria-busy': state.loading || !!state.offline?.refreshing } : {}), style: { height: 52, backgroundColor: design.composer?.background ?? c.background } });
|
|
1114
1194
|
if (!enabled || state.conversation?.canSend === false) {
|
|
1195
|
+
if (enabled && state.conversation?.access === 'review')
|
|
1196
|
+
return _jsx(Text, { accessibilityRole: "text", style: { paddingHorizontal: 16, paddingVertical: 10, color: c.secondary, fontSize: 13 }, children: uiText('Read-only history') });
|
|
1115
1197
|
return (_jsx(Text, { style: { padding: 16, color: c.secondary }, children: state.offline ? uiText("Offline · Recent messages only. Connect to send and load more.") : state.conversation?.safety?.blockedByMe ? uiText("You blocked this contact. Use contact options to unblock.") : state.conversation?.canSend === false ? (state.conversation.kind === 'group' ? uiText('Only members allowed to send can post in this group.') : uiText('Messaging is unavailable for this conversation.')) : design.labels.unavailable }));
|
|
1116
1198
|
}
|
|
1117
1199
|
return (_jsxs(View, { testID: "messaging-composer", style: { paddingStart: 8, paddingEnd: 0, paddingVertical: 4, gap: 8, backgroundColor: design.composer?.background ?? c.background }, children: [mentionSuggestions.length > 0 && _jsx(ScrollView, { keyboardShouldPersistTaps: "handled", style: { maxHeight: 144 }, children: mentionSuggestions.map(id => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Mention {name}', { name: participants[id].name }), onPress: () => chooseMention(id), style: { minHeight: 44, paddingHorizontal: 12, justifyContent: 'center', borderBottomWidth: .5, borderBottomColor: c.secondary + '30' }, children: _jsxs(Text, { style: { color: c.accent, fontSize: 16 }, children: ["@", participants[id].name] }) }, id)) }), mentionQuery !== undefined && !!mentionError && _jsx(Text, { style: { color: c.secondary, fontSize: 13 }, children: mentionError }), editing && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [_jsxs(Text, { numberOfLines: 1, style: { flex: 1, color: c.secondary }, children: [uiText("Editing:"), editing.text || editing.media?.fileName] }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel editing"), disabled: busy, onPress: () => setEditing(null), style: { minHeight: 36, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent }, children: uiText("Cancel") }) })] }), !editing && reply && (_jsxs(View, { testID: "composer-quote", style: { flexDirection: "row", gap: 8 }, children: [_jsx(View, { style: { flex: 1 }, children: _jsx(QuotedPreview, { message: reply, ink: c.secondary }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel quote"), onPress: () => setReply(null), children: _jsx(Text, { style: { color: c.foreground }, children: uiText("Cancel") }) })] })), state.settings?.history?.mode === 'last_two' && _jsx(Text, { style: { color: c.secondary, fontSize: 11, textAlign: 'center' }, children: uiText("Only the latest two messages are kept.") }), editing ? _jsxs(_Fragment, { children: [renderAttachments(), renderTextComposer()] }) : features?.voice ? _jsx(VoiceComposer, { appearance: design, maxSeconds: state.settings?.voice?.maxDurationSeconds ?? 60, busy: busy, onRecord: () => { Keyboard.dismiss(); void pick('voice'); }, renderAttachments: renderAttachments, renderTextComposer: features?.text || selected.length ? renderTextComposer : undefined, actions: _jsx(_Fragment, { children: (camera || library.image || library.video || library.document || !editing && (features?.poll || weatherAllowed)) && _jsx(Pressable, { ref: attachmentButton, accessibilityRole: "button", accessibilityLabel: uiText("Attach"), accessibilityState: { expanded: attachmentsOpen }, disabled: busy, onPress: () => setAttachmentsOpen(!attachmentsOpen), style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: attachmentsOpen ? 'close' : 'plus', color: c.foreground, size: 25 }) }) }) }) : _jsxs(_Fragment, { children: [renderAttachments(), renderTextComposer()] }), attachmentsOpen && _jsx(AttachmentMenu, { anchor: attachmentButton, accent: c.accent, onClose: () => setAttachmentsOpen(false), actions: attachmentActions }), scheduleOpen && _jsx(ScheduleTimePicker, { initial: scheduleAttempt.current?.time, retryAt: scheduleError ? scheduleAttempt.current?.time : undefined, accent: c.accent, busy: busy, error: scheduleError, onSave: time => void schedule(time), onClose: () => setScheduleOpen(false) }), pollOpen && features?.poll && _jsx(PollComposer, { yesNo: state.conversation?.kind !== 'group', appearance: design, onSend: poll => submit({ kind: 'poll', poll }), onCancel: () => setPollOpen(false) }), error && (_jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: error }))] }));
|
|
1118
1200
|
}
|
|
1119
1201
|
/** Account navigation. Mount in the inbox/app toolbar, never in a contact menu. */
|
|
1120
|
-
export function MessagingAccountMenu({
|
|
1121
|
-
const { text
|
|
1122
|
-
const
|
|
1123
|
-
const [open, setOpen] = useState(false), [accountOpen, setAccountOpen] = useState(false), pending = useRef(null);
|
|
1202
|
+
export function MessagingAccountMenu({ inbox, onNewGroup, onMaps, onPublicRooms } = {}) {
|
|
1203
|
+
const { text } = useRobonoLocale(), { client, design, setSavedOpen, account, companyName } = useMessagingUI();
|
|
1204
|
+
const [open, setOpen] = useState(false), [accountOpen, setAccountOpen] = useState(false), [page, setPage] = useState(null), pending = useRef(null);
|
|
1124
1205
|
const menu = messagingMenuColors(design, 'friends'), items = design.menus?.friends?.items, layout = messagingMenuLayout(design.menus?.friends);
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
if (items?.
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1206
|
+
const pages = messagingAccountPages.filter(key => items?.[key] !== false && (key === 'blocked' ? !!account?.blocked : key === 'linkedApps' ? !!account?.onLinkedApps || !!account?.linkedApps : key === 'transfer' ? !!account?.onPhoneTransfer || !!account?.backup && design.showChatBackup !== false : true));
|
|
1207
|
+
const rows = [];
|
|
1208
|
+
if (items?.account !== false)
|
|
1209
|
+
rows.push({ key: 'account', label: 'Account', icon: 'person-circle-outline' });
|
|
1210
|
+
for (const key of messagingAccountPages) {
|
|
1211
|
+
if (pages.includes(key))
|
|
1212
|
+
rows.push({ key, label: messagingAccountPageLabels[key], icon: key === 'language' ? 'language-outline' : key === 'stats' ? 'stats-chart-outline' : key === 'blocked' ? 'ban-outline' : key === 'linkedApps' ? 'link-outline' : key === 'transfer' ? 'phone-portrait-outline' : 'information-circle-outline' });
|
|
1213
|
+
if (key === 'language' && client.hasSavedMessages() && items?.saved !== false)
|
|
1214
|
+
rows.push({ key: 'saved', label: 'Saved', icon: 'bookmark-outline' });
|
|
1215
|
+
}
|
|
1216
|
+
if (onMaps && items?.maps !== false)
|
|
1217
|
+
rows.push({ key: 'maps', label: 'Maps', icon: 'location' });
|
|
1218
|
+
if (onPublicRooms && items?.publicGroups !== false)
|
|
1219
|
+
rows.push({ key: 'rooms', label: 'Public groups', icon: 'people-outline' });
|
|
1220
|
+
if (onNewGroup && items?.newGroup !== false)
|
|
1221
|
+
rows.push({ key: 'group', label: 'New group', icon: 'people-outline' });
|
|
1134
1222
|
const button = useRef(null), viewport = useWindowDimensions(), [anchor, setAnchor] = useState({ x: 12, y: 12 });
|
|
1135
|
-
const width = Math.min(218, viewport.width - 24), menuHeight =
|
|
1136
|
-
const show = () => button.current?.measureInWindow((x, y, w, h) => { setAnchor({ x: Math.max(12, Math.min(x + w - width, viewport.width - width - 12)), y:
|
|
1223
|
+
const width = Math.min(218, viewport.width - 24), menuHeight = rows.length * layout.rowHeight + 8;
|
|
1224
|
+
const show = () => button.current?.measureInWindow((x, y, w, h) => { setAnchor({ x: Math.max(12, Math.min(x + w - width, viewport.width - width - 12)), y: y + h + 4 }); setOpen(true); });
|
|
1137
1225
|
const dismissed = () => { const next = pending.current; if (!next)
|
|
1138
|
-
return; pending.current = null; requestAnimationFrame(() =>
|
|
1226
|
+
return; pending.current = null; requestAnimationFrame(() => { if (next === 'saved')
|
|
1227
|
+
setSavedOpen(true);
|
|
1228
|
+
else if (next === 'group')
|
|
1229
|
+
onNewGroup?.();
|
|
1230
|
+
else if (next === 'maps')
|
|
1231
|
+
onMaps?.();
|
|
1232
|
+
else if (next === 'rooms')
|
|
1233
|
+
onPublicRooms?.();
|
|
1234
|
+
else if (next === 'account')
|
|
1235
|
+
setAccountOpen(true);
|
|
1236
|
+
else if (next === 'linkedApps' && account?.onLinkedApps)
|
|
1237
|
+
account.onLinkedApps();
|
|
1238
|
+
else if (next === 'transfer' && account?.onPhoneTransfer)
|
|
1239
|
+
account.onPhoneTransfer();
|
|
1240
|
+
else
|
|
1241
|
+
setPage(next); }); };
|
|
1139
1242
|
useEffect(() => { if (!open && Platform.OS !== 'ios')
|
|
1140
1243
|
dismissed(); }, [open]);
|
|
1141
1244
|
useEffect(() => { if (!open || Platform.OS !== 'web')
|
|
@@ -1143,10 +1246,7 @@ export function MessagingAccountMenu({ onNewConversation, onNewGroup, onMaps, on
|
|
|
1143
1246
|
event.stopPropagation();
|
|
1144
1247
|
setOpen(false);
|
|
1145
1248
|
} }; document.addEventListener('keydown', key, true); return () => document.removeEventListener('keydown', key, true); }, [open]);
|
|
1146
|
-
return _jsxs(_Fragment, { children: [_jsx(Pressable, { ref: button, accessibilityRole: "button", accessibilityLabel:
|
|
1147
|
-
const top = Math.max(8, Math.min(anchor.y - rect.top, rect.height - menuHeight - 8));
|
|
1148
|
-
return _jsxs(View, { accessibilityViewIsModal: true, style: { flex: 1 }, children: [_jsx(Pressable, { accessibilityLabel: uiText("Close messaging menu"), onPress: () => setOpen(false), style: { position: 'absolute', inset: 0 } }), _jsx(View, { testID: "messaging-account-dropdown", style: { position: 'absolute', left: Math.max(8, Math.min(anchor.x - rect.left, rect.width - Math.min(width, rect.width - 16) - 8)), top, width: Math.min(width, rect.width - 16), maxHeight: Math.max(0, rect.height - top - 8), borderRadius: layout.radius, borderWidth: .5, borderColor: '#ffffff22', backgroundColor: menu.background, paddingVertical: 4, overflow: 'hidden', boxShadow: '0 8px 18px #0006' }, children: _jsxs(ScrollView, { keyboardShouldPersistTaps: "handled", children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Account"), onPress: () => { pending.current = 'account'; setOpen(false); }, style: ({ pressed }) => ({ minHeight: layout.rowHeight, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 10, backgroundColor: pressed ? menu.foreground + '12' : 'transparent' }), children: [layout.showIcons && _jsx(MessageIcon, { name: "person-circle-outline", color: menu.icons, size: 22 }), _jsx(Text, { style: { color: menu.foreground, fontSize: layout.textSize, fontWeight: '600' }, children: uiText("Account") })] }), onNewConversation && _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("New chat"), onPress: () => { pending.current = 'new-chat'; setOpen(false); }, style: ({ pressed }) => ({ minHeight: layout.rowHeight, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 10, backgroundColor: pressed ? menu.foreground + '12' : 'transparent' }), children: [layout.showIcons && _jsx(MessageIcon, { name: "edit", color: menu.icons, size: 22 }), _jsx(Text, { style: { color: menu.foreground, fontSize: layout.textSize, fontWeight: '600' }, children: uiText("New chat") })] }), onMaps && _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Maps"), onPress: () => { pending.current = 'maps'; setOpen(false); }, style: ({ pressed }) => ({ minHeight: layout.rowHeight, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 10, backgroundColor: pressed ? menu.foreground + '12' : 'transparent' }), children: [layout.showIcons && _jsx(MessageIcon, { name: "location", color: menu.icons, size: 22 }), _jsx(Text, { style: { color: menu.foreground, fontSize: layout.textSize, fontWeight: '600' }, children: uiText("Maps") })] }), onPublicRooms && _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Public groups"), onPress: () => { pending.current = 'rooms'; setOpen(false); }, style: ({ pressed }) => ({ minHeight: layout.rowHeight, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 10, backgroundColor: pressed ? menu.foreground + '12' : 'transparent' }), children: [layout.showIcons && _jsx(MessageIcon, { name: "people-outline", color: menu.icons, size: 22 }), _jsx(Text, { style: { color: menu.foreground, fontSize: layout.textSize, fontWeight: '600' }, children: uiText("Public groups") })] }), onNewGroup && _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("New group"), onPress: () => { pending.current = 'group'; setOpen(false); }, style: ({ pressed }) => ({ minHeight: layout.rowHeight, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 10, backgroundColor: pressed ? menu.foreground + '12' : 'transparent' }), children: [layout.showIcons && _jsx(MessageIcon, { name: "people-outline", color: menu.icons, size: 22 }), _jsx(Text, { style: { color: menu.foreground, fontSize: layout.textSize, fontWeight: '600' }, children: uiText("New group") })] }), savedAvailable && _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Saved messages"), onPress: () => { pending.current = 'saved'; setOpen(false); }, style: ({ pressed }) => ({ minHeight: layout.rowHeight, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 10, backgroundColor: pressed ? menu.foreground + '12' : 'transparent' }), children: [layout.showIcons && _jsx(MessageIcon, { name: "bookmark-outline", color: menu.icons, size: 22 }), _jsx(Text, { style: { color: menu.foreground, fontSize: layout.textSize, fontWeight: '600' }, children: uiText("Saved") })] })] }) })] });
|
|
1149
|
-
} }), accountOpen && _jsx(MessagingAccountScreen, { account: account, companyName: companyName ?? design.name, onClose: () => setAccountOpen(false) })] });
|
|
1249
|
+
return _jsxs(_Fragment, { children: [_jsx(Pressable, { ref: button, accessibilityRole: "button", accessibilityLabel: text('Messaging menu'), accessibilityState: { expanded: open }, onPress: show, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(View, { testID: "messaging-account-avatar", style: { width: 44, height: 44, borderRadius: 22, overflow: 'hidden', borderWidth: account?.avatarUrl ? 2 : 1, borderColor: account?.avatarUrl || open ? design.colors.accent : design.colors.foreground + '26', backgroundColor: open ? design.colors.accent : chatSurface(design.colors.background), alignItems: 'center', justifyContent: 'center' }, children: account?.avatarUrl ? _jsx(Image, { source: { uri: account.avatarUrl }, style: { width: '100%', height: '100%' } }) : _jsx(MessageIcon, { name: "person-circle-outline", color: design.screens?.friends?.headerText ?? design.colors.foreground, size: 31 }) }) }), _jsx(MessagingMenuSurface, { visible: open, onClose: () => setOpen(false), onDismiss: dismissed, children: rect => { const top = Math.max(8, Math.min(anchor.y - rect.top, rect.height - Math.min(menuHeight, rect.height - 16) - 8)); return _jsxs(View, { accessibilityViewIsModal: true, style: { flex: 1 }, children: [_jsx(Pressable, { accessibilityLabel: text('Close messaging menu'), onPress: () => setOpen(false), style: { position: 'absolute', inset: 0 } }), _jsx(View, { testID: "messaging-account-dropdown", style: { position: 'absolute', left: Math.max(8, Math.min(anchor.x - rect.left, rect.width - Math.min(width, rect.width - 16) - 8)), top, width: Math.min(width, rect.width - 16), maxHeight: Math.max(0, rect.height - top - 8), borderRadius: layout.radius, borderWidth: .5, borderColor: '#ffffff22', backgroundColor: menu.background, paddingVertical: 4, overflow: 'hidden', boxShadow: '0 8px 18px #0006' }, children: _jsx(ScrollView, { keyboardShouldPersistTaps: "handled", children: rows.map(row => _jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: text(row.key === 'saved' ? 'Saved messages' : row.label), onPress: () => { pending.current = row.key; setOpen(false); }, style: ({ pressed }) => ({ minHeight: layout.rowHeight, paddingHorizontal: 12, flexDirection: 'row', alignItems: 'center', gap: 10, backgroundColor: pressed ? menu.foreground + '12' : 'transparent' }), children: [layout.showIcons && _jsx(MessageIcon, { name: row.icon, color: menu.icons, size: 22 }), _jsx(Text, { style: { color: menu.foreground, fontSize: layout.textSize, fontWeight: '600' }, children: text(row.label) })] }, row.key)) }) })] }); } }), page && _jsx(MessagingAccountPageScreen, { page: page, account: account, inbox: inbox, companyName: companyName ?? design.name, onClose: () => setPage(null) }), accountOpen && _jsx(MessagingAccountScreen, { inbox: inbox, account: account && design.showChatBackup === false ? { ...account, backup: undefined } : account, companyName: companyName ?? design.name, onClose: () => setAccountOpen(false) })] });
|
|
1150
1250
|
}
|
|
1151
1251
|
function MessagingWaitingChanges() {
|
|
1152
1252
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
@@ -1161,12 +1261,29 @@ function MessagingWaitingChanges() {
|
|
|
1161
1261
|
}
|
|
1162
1262
|
export function MessagingConversation() {
|
|
1163
1263
|
const { text: uiText } = useRobonoLocale();
|
|
1164
|
-
const { state, client, components, design, style, keyboard } = useMessagingUI();
|
|
1264
|
+
const { state, client, components, design, style, keyboard, onBack, active } = useMessagingUI();
|
|
1265
|
+
const backNavigation = useRef({ onBack, active });
|
|
1266
|
+
backNavigation.current = { onBack, active };
|
|
1267
|
+
// Register before passive selection/attachment handlers so those close first.
|
|
1268
|
+
// Keep this subscription stable as host navigation callbacks change.
|
|
1269
|
+
useLayoutEffect(() => {
|
|
1270
|
+
if (Platform.OS !== 'android')
|
|
1271
|
+
return;
|
|
1272
|
+
const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
|
|
1273
|
+
const current = backNavigation.current;
|
|
1274
|
+
if (current.active === false || !current.onBack)
|
|
1275
|
+
return false;
|
|
1276
|
+
current.onBack();
|
|
1277
|
+
return true;
|
|
1278
|
+
});
|
|
1279
|
+
return () => subscription.remove();
|
|
1280
|
+
}, []);
|
|
1165
1281
|
const Header = components?.Header ?? MessagingHeader, List = components?.List ?? MessagingList, Composer = components?.Composer ?? MessagingComposer;
|
|
1166
|
-
return (_jsxs(MessagingKeyboardContainer, { options: keyboard, style: [{ backgroundColor: design.colors.background }, style], children: [_jsx(MessagingPopupHeaderBoundary, { children: _jsx(Header, {}) }), _jsx(List, {}), state.
|
|
1282
|
+
return (_jsxs(MessagingKeyboardContainer, { options: keyboard, style: [{ backgroundColor: design.colors.background }, style], children: [_jsx(MessagingPopupHeaderBoundary, { children: _jsx(Header, {}) }), _jsx(List, {}), state.error && (_jsx(Text, { accessibilityRole: "alert", style: { padding: 12, color: design.colors.foreground }, children: uiText(state.error) })), _jsx(MessagingWaitingChanges, {}), _jsx(View, { style: { paddingBottom: Math.max(0, keyboard?.bottomInset ?? 0) }, children: _jsx(Composer, {}, state.conversationId) })] }));
|
|
1167
1283
|
}
|
|
1168
1284
|
/** Embed inside your app's safe area and navigation. No engine, push or global audio side effects. */
|
|
1169
1285
|
export function MessagingScreen(props) {
|
|
1170
1286
|
return (_jsx(MessagingProvider, { ...props, children: props.renderLayout ? props.renderLayout(_jsx(MessagingConversation, {})) : _jsx(MessagingConversation, {}) }));
|
|
1171
1287
|
}
|
|
1172
1288
|
export { MessagingInbox } from './inbox.js';
|
|
1289
|
+
export { MessagingBackupScreen } from './backup.js';
|