@robono/messaging-react-native 0.24.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 +7 -0
- package/README.md +75 -1
- package/RobonoMessagingRuntime.podspec +2 -0
- package/SBOM.spdx.json +1829 -557
- package/android/build.gradle +4 -1
- 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 +1 -1
- package/app.plugin.cjs +14 -1
- 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 +2 -1
- package/dist/account.js +6 -2
- 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.js +61 -16
- package/dist/bubble-design.d.ts +1 -1
- package/dist/cloudkit-backup.d.ts +14 -0
- package/dist/cloudkit-backup.js +193 -0
- package/dist/conversation-details.js +1 -1
- package/dist/customization.d.ts +1 -0
- package/dist/delivery-bar.d.ts +1 -1
- package/dist/delivery-bar.js +5 -2
- package/dist/delivery-notice.d.ts +9 -0
- package/dist/delivery-notice.js +15 -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-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 +7 -0
- package/dist/expo-backup-passkeys.js +31 -7
- package/dist/expo-backup-settings.js +26 -8
- 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-media.d.ts +2 -0
- package/dist/expo-media.js +15 -21
- package/dist/expo-messenger.d.ts +8 -0
- package/dist/expo-messenger.js +18 -7
- 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 +4 -1
- package/dist/expo-reviews.js +122 -17
- package/dist/expo-screen.js +5 -4
- package/dist/expo-thumbnails.d.ts +2 -2
- package/dist/expo-thumbnails.js +48 -5
- package/dist/expo.d.ts +10 -0
- package/dist/expo.js +8 -0
- package/dist/header-calls.js +1 -1
- package/dist/inbox-search.d.ts +1 -1
- package/dist/inbox-search.js +7 -3
- package/dist/inbox.d.ts +1 -0
- package/dist/inbox.js +5 -5
- package/dist/index.d.ts +8 -3
- package/dist/index.js +138 -63
- package/dist/linked-apps.d.ts +45 -0
- package/dist/linked-apps.js +40 -0
- package/dist/loading-messages.d.ts +1 -1
- package/dist/loading-messages.js +1 -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/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 +8 -4
- package/dist/reviews.js +53 -26
- package/dist/scheduled.js +2 -2
- package/dist/search.js +18 -8
- package/ios/RobonoBackupCloudKit.m +96 -0
- package/ios/RobonoHistoryStore.m +170 -0
- package/package.json +22 -4
- package/plugin/backup-expiration.cjs +23 -0
- package/plugin/prepare-native.cjs +12 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
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';
|
|
2
6
|
import { messagingHeaderColors } from './header-colors.js';
|
|
3
7
|
import { MessagingLoadingMessages } from './loading-messages.js';
|
|
4
8
|
export { messagingHeaderColors } from './header-colors.js';
|
|
@@ -16,6 +20,7 @@ import { MessagingKeyboardContainer } from './keyboard-container.js';
|
|
|
16
20
|
import { conversationMessages } from '@robono/messaging';
|
|
17
21
|
import { ConversationSelector } from './conversation-selector.js';
|
|
18
22
|
import { useAttachmentPreview } from './attachment-preview.js';
|
|
23
|
+
import { readPreviewSize, rememberPreviewSize } from './preview-layout.js';
|
|
19
24
|
import { MessagingRoomModeration, MessagingRoomRemoval } from './room-moderation.js';
|
|
20
25
|
export { MessagingConnectionState, MessagingSignIn, MessagingPhoneInput, MessagingChoicePicker } from './sign-in.js';
|
|
21
26
|
import { CustomMessage } from './custom-message.js';
|
|
@@ -35,7 +40,7 @@ import { MessageMenu, MessageMenuRow, messageMenuPosition } from './message-menu
|
|
|
35
40
|
import { TranslationSettings } from './translation-settings.js';
|
|
36
41
|
import { AttachmentMenu } from './attachment-menu.js';
|
|
37
42
|
import { QuickSendButton } from './quick-send.js';
|
|
38
|
-
import { MessageExtra, MessagingPrivacyLayer, privacyReadingStripHeight, openChatAddress
|
|
43
|
+
import { MessageExtra, MessagingPrivacyLayer, privacyReadingStripHeight, openChatAddress } from './extras.js';
|
|
39
44
|
export { MessagingPrivacyLayer } from './extras.js';
|
|
40
45
|
import { orderChatMessages } from './message-order.js';
|
|
41
46
|
import { MessagingPopup, MessagingPopupHost, MessagingPopupHeaderBoundary, useMessagingPopupColors } from './popup.js';
|
|
@@ -49,8 +54,8 @@ import { MessagingSafety } from './safety.js';
|
|
|
49
54
|
export { MessagingSafety } from './safety.js';
|
|
50
55
|
import { PollMessage, PollComposer } from "./polls.js";
|
|
51
56
|
export { PollMessage, PollComposer } from "./polls.js";
|
|
52
|
-
import React, { createContext, useContext, useMemo, useCallback, useEffect, useRef, useState, useSyncExternalStore, } from "react";
|
|
53
|
-
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";
|
|
54
59
|
import { useQuoteGesture, messageInfoRevealWidth, messageReplyRevealWidth } from "./use-quote-gesture.js";
|
|
55
60
|
import { MessageIcon, duration, fileSize, chatSurface, composerSurface } from "./icons.js";
|
|
56
61
|
import { VoiceMessageComposer } from "./voice-composer.js";
|
|
@@ -273,21 +278,26 @@ export function GroupDiscussion({ threadRoot, onClose }) {
|
|
|
273
278
|
context.setReply({ ...message, threadRoot: message.id }); }).catch(() => { }); }; setVisible(false); };
|
|
274
279
|
const rows = root ? [root, ...messages.filter(m => m.id !== root.id)] : messages;
|
|
275
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)
|
|
276
|
-
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") }) })] });
|
|
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") }) })] });
|
|
277
282
|
}
|
|
278
283
|
function MessagingActivity({ ink }) {
|
|
279
284
|
const { text: uiText, count: uiCount, locale: uiLocale } = useRobonoLocale();
|
|
280
|
-
const { state, design, participants } = useMessagingUI(), [now, setNow] = useState(Date.now());
|
|
285
|
+
const { state, design, participants, contact, companyName } = useMessagingUI(), [now, setNow] = useState(Date.now());
|
|
281
286
|
useEffect(() => { setNow(Date.now()); if (!state.presence?.peers.length)
|
|
282
287
|
return; const timer = setInterval(() => setNow(Date.now()), 1000); return () => clearInterval(timer); }, [state.presence]);
|
|
283
288
|
const typing = state.settings?.features.typing ? state.presence?.peers.filter(peer => peer.typingUntil > now) ?? [] : [];
|
|
284
289
|
const online = state.settings?.features.online && state.presence?.peers.some(peer => peer.onlineUntil > now);
|
|
285
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;
|
|
286
293
|
const lastSeen = state.settings?.features.lastSeen ? state.presence?.peers.find(peer => Number.isFinite(peer.lastSeenAt) && peer.lastSeenAt > 0)?.lastSeenAt : null;
|
|
287
294
|
const lastSeenLabel = lastSeen ? new Date(lastSeen).toLocaleString(uiLocale, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : '';
|
|
288
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 }] } })] });
|
|
289
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') : '';
|
|
290
|
-
return _jsx(Text, { testID: "messaging-chat-activity", numberOfLines: 1, style: { color: ink, opacity: .8, fontSize: 14, lineHeight: 18, minHeight: 18 }, children: text || " " });
|
|
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(' · ') || " " });
|
|
291
301
|
}
|
|
292
302
|
export function MessagingHeader({ children } = {}) {
|
|
293
303
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
@@ -305,9 +315,9 @@ export function MessagingHeader({ children } = {}) {
|
|
|
305
315
|
alignItems: "center",
|
|
306
316
|
paddingHorizontal: 12,
|
|
307
317
|
paddingVertical: 4,
|
|
308
|
-
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) +
|
|
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,
|
|
309
319
|
backgroundColor: header.background,
|
|
310
|
-
gap:
|
|
320
|
+
gap: 0,
|
|
311
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
|
|
312
322
|
? (_jsx(Image, { source: { uri: contact.avatarUrl }, style: { ...avatar, borderWidth: 1, borderColor: "#ffffff" } }))
|
|
313
323
|
: (_jsx(View, { style: {
|
|
@@ -317,16 +327,7 @@ export function MessagingHeader({ children } = {}) {
|
|
|
317
327
|
backgroundColor: c.incoming,
|
|
318
328
|
alignItems: "center",
|
|
319
329
|
justifyContent: "center",
|
|
320
|
-
}, 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 }),
|
|
321
|
-
}
|
|
322
|
-
function PrivacyControl({ color }) {
|
|
323
|
-
const messagingPopupColors = useMessagingPopupColors();
|
|
324
|
-
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
325
|
-
const { extras, extrasState, design } = useMessagingUI();
|
|
326
|
-
const [error, setError] = useState(''), [busy, setBusy] = useState(false);
|
|
327
|
-
if (!extras || !extrasState || !extrasState.available.privacyLens && !extrasState.privacyLens)
|
|
328
|
-
return null;
|
|
329
|
-
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)] }));
|
|
330
331
|
}
|
|
331
332
|
const mediaNames = {
|
|
332
333
|
voice: "Voice message",
|
|
@@ -335,8 +336,8 @@ const mediaNames = {
|
|
|
335
336
|
document: "File",
|
|
336
337
|
};
|
|
337
338
|
function quoteSummary(message, uiText) { return message?.poll?.question ?? message?.text ?? uiText(message && message.kind !== "text" && message.kind !== "poll" ? mediaNames[message.kind] : "Earlier message"); }
|
|
338
|
-
/**
|
|
339
|
-
function QuotedPreview({ message, ink }) {
|
|
339
|
+
/** Composer previews stay compact; delivered quotes display the complete text. */
|
|
340
|
+
function QuotedPreview({ message, ink, expanded = false }) {
|
|
340
341
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
341
342
|
const { attachmentPreview, userId, participants, contact, state, design } = useMessagingUI();
|
|
342
343
|
const [thumbnail, setThumbnail] = useState();
|
|
@@ -350,7 +351,7 @@ function QuotedPreview({ message, ink }) {
|
|
|
350
351
|
}, [message?.id, message?.conversationId, message?.media?.assetId, message?.deleted, attachmentPreview]);
|
|
351
352
|
const name = message && !message.deleted ? (message.senderId === userId ? 'You' : participants?.[message.senderId]?.name ?? (state.conversation?.kind === 'direct' ? contact.name : 'Chat member')) : null;
|
|
352
353
|
const media = message && !message.deleted && message.kind !== 'text' && message.kind !== 'poll';
|
|
353
|
-
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: 11, lineHeight: 14, fontWeight: '900' }, children: name === 'You' ? uiText('You') : name }), _jsxs(Text, { numberOfLines: 2, style: { color: ink, fontSize: 12, lineHeight: 16, opacity: .8, marginTop: name ? 1 : 0 }, children: [message?.deleted ? uiText("Message deleted") : quoteSummary(message, uiText), message?.kind === 'voice' && message.media?.durationMs ? ` · ${duration(message.media.durationMs)}` : ''] })] })] });
|
|
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)}` : ''] })] })] });
|
|
354
355
|
}
|
|
355
356
|
/** Thumbnails stay local to the view and are discarded on conversation/message changes. */
|
|
356
357
|
const heardVoiceMessages = new WeakMap();
|
|
@@ -366,7 +367,17 @@ function MediaContent({ message, ink, footer, onOpen, onLongPress, sendRetry })
|
|
|
366
367
|
return; rows.add(voiceKey); if (rows.size > 2048)
|
|
367
368
|
rows.delete(rows.values().next().value); updateHeard(n => n + 1); };
|
|
368
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;
|
|
369
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
|
+
};
|
|
370
381
|
useEffect(() => {
|
|
371
382
|
if (Platform.OS !== 'web' || !preview.uri)
|
|
372
383
|
return;
|
|
@@ -374,14 +385,16 @@ function MediaContent({ message, ink, footer, onOpen, onLongPress, sendRetry })
|
|
|
374
385
|
const uri = preview.uri;
|
|
375
386
|
// Web's image loader does not supply React Native's source dimensions.
|
|
376
387
|
// Decode the same local preview URL, never the full attachment.
|
|
377
|
-
Image.getSize(uri, (width, height) => { if (current
|
|
378
|
-
|
|
388
|
+
Image.getSize(uri, (width, height) => { if (current)
|
|
389
|
+
decodedSize(uri, width, height); }, () => { });
|
|
379
390
|
return () => { current = false; };
|
|
380
|
-
}, [preview.uri]);
|
|
391
|
+
}, [preview.uri, sizeKey, sizeScope]);
|
|
381
392
|
// Size the decoded preview, never the full attachment. A recycled row cannot
|
|
382
393
|
// reuse the previous image's shape.
|
|
383
|
-
const size = imageSize
|
|
384
|
-
|
|
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;
|
|
385
398
|
const previewWidth = size ? size.width * scale : 220, previewHeight = size ? size.height * scale : 155;
|
|
386
399
|
if (message.kind === 'voice') {
|
|
387
400
|
const Voice = components?.VoiceMessage;
|
|
@@ -393,8 +406,8 @@ function MediaContent({ message, ink, footer, onOpen, onLongPress, sendRetry })
|
|
|
393
406
|
// React Native Web supplies the decoded HTML image as the event target.
|
|
394
407
|
const target = event.nativeEvent.target;
|
|
395
408
|
const width = source?.width ?? target?.naturalWidth, height = source?.height ?? target?.naturalHeight;
|
|
396
|
-
if (width && height &&
|
|
397
|
-
|
|
409
|
+
if (width && height && preview.uri)
|
|
410
|
+
decodedSize(preview.uri, width, height);
|
|
398
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) })] })] }) });
|
|
399
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] })] });
|
|
400
413
|
}
|
|
@@ -438,6 +451,7 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
438
451
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
439
452
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
440
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 };
|
|
441
455
|
const deliveryStatus = pendingStatus ?? (message.senderId === userId && message.delivery?.state === 'pending' ? 'sending' : message.senderId === userId && message.delivery?.state === 'failed' ? 'failed' : undefined);
|
|
442
456
|
const candidateExtra = !message.custom && !pendingStatus && !message.deleted ? ui.candidateExtra : undefined;
|
|
443
457
|
const extra = candidateExtra?.address && (linkHandling?.addresses === false || linkHandling?.openAddress) ? undefined : candidateExtra;
|
|
@@ -450,7 +464,7 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
450
464
|
const status = bubbleDelivery(message, deliveryStatus, !!state.settings?.features.readReceipts, design);
|
|
451
465
|
const circleStatus = mine && status.style === 'circle';
|
|
452
466
|
const timePosition = design.messageTime?.position ?? 'slide', circlePosition = design.messageStatus?.position ?? 'inside';
|
|
453
|
-
const statusLabel = uiText(status.phase === 'failed' ? 'Message not sent' : status.phase === 'sent' ? 'Sending message' : status.phase === 'consumed' ? (message.kind === 'voice' ? 'Heard' : message.kind === 'video' ? 'Watched' : 'Seen') : 'Delivered');
|
|
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'));
|
|
454
468
|
const messageGap = design.presentation?.messageSpacing === 'compact' ? 4 : design.presentation?.messageSpacing === 'relaxed' ? 12 : 8;
|
|
455
469
|
const visual = message.kind === 'image' || message.kind === 'video', voice = message.kind === 'voice';
|
|
456
470
|
const grouped = ui.grouped;
|
|
@@ -539,8 +553,8 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
539
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);
|
|
540
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); };
|
|
541
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())
|
|
542
|
-
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;
|
|
543
|
-
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;
|
|
544
558
|
const canCopy = !!message.text && (!!copyText || Platform.OS === 'web');
|
|
545
559
|
const reactionDesign = design.menus?.message;
|
|
546
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)) }) });
|
|
@@ -559,23 +573,31 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
559
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 }) })] });
|
|
560
574
|
};
|
|
561
575
|
const insideMeta = messageMeta('inside'), belowMeta = messageMeta('below');
|
|
562
|
-
const sendRetry = deliveryStatus === 'failed' ? _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;
|
|
563
|
-
const fallbackContent = _jsx(View, { testID: "message-original-text", children: _jsx(Text, { selectable: true, style: { color: ink, fontSize: 16, lineHeight: 22 }, children: renderText(message.text ?? '') }) });
|
|
564
|
-
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:
|
|
565
|
-
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:
|
|
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;
|
|
566
580
|
const regionProps = { message, mine, appearance: design, pendingStatus };
|
|
567
581
|
const bodyContent = components?.MessageBody && !message.deleted ? _jsx(components.MessageBody, { ...regionProps, children: content }) : content;
|
|
568
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;
|
|
569
591
|
const statusTopRadius = voice && !showingTransform ? 24 : topTail ? 0 : bubbleRadius, statusBottomRadius = voice && !message.text && !showingTransform ? 24 : corners.borderBottomRightRadius;
|
|
570
592
|
// Cover the full inside edge; each curved end tapers to the bubble's corner.
|
|
571
|
-
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 }) }),
|
|
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())
|
|
572
594
|
return; if (extra?.address)
|
|
573
595
|
extraRef.current?.open();
|
|
574
596
|
else
|
|
575
|
-
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:
|
|
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) })] });
|
|
576
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)
|
|
577
599
|
quoteGesture.webRef.current = node; }, ...quoteGesture.handlers, accessibilityActions: quoting ? [{ name: "quote", label: uiText("Quote message") }] : undefined, onAccessibilityAction: event => { if (quoting && event.nativeEvent.actionName === "quote")
|
|
578
|
-
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 } : {}) }, 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: mine ? c.outgoing : c.incoming, ...(mine ? { borderRightWidth: 8, borderRightColor: 'transparent' } : { borderLeftWidth: 8, borderLeftColor: 'transparent' }) } }), extra?.address ? extraCard : socialReady ? socialCard : bubbleBody] }), 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 })] });
|
|
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 })] });
|
|
579
601
|
});
|
|
580
602
|
export function MessageDeletion({ messages, onClose }) {
|
|
581
603
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
@@ -630,6 +652,9 @@ export function MessagingList() {
|
|
|
630
652
|
createdAt: p.createdAt ?? new Date().toISOString(), readAt: null, pendingStatus: p.status,
|
|
631
653
|
}))]).reverse(), [state.messages, state.pending, state.conversationId, userId]);
|
|
632
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 };
|
|
633
658
|
const nearLatest = useRef(true), lastNewest = useRef(''), lastPending = useRef('');
|
|
634
659
|
const [away, setAway] = useState(false), [newMessages, setNewMessages] = useState(false);
|
|
635
660
|
const [historyHeight, setHistoryHeight] = useState(0);
|
|
@@ -789,15 +814,24 @@ export function MessagingList() {
|
|
|
789
814
|
target.retryTimer = setTimeout(() => { target.retryTimer = undefined; if (scrollTarget.current === target)
|
|
790
815
|
list.current?.scrollToIndex({ index: target.index, viewPosition: .5, animated: false }); }, 150);
|
|
791
816
|
list.current?.scrollToOffset({ offset: info.averageItemLength * info.index, animated: false });
|
|
792
|
-
}, 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)
|
|
793
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: {
|
|
794
825
|
itemVisiblePercentThreshold: 50,
|
|
795
826
|
minimumViewTime: 500,
|
|
796
827
|
}, renderItem: renderHistoryItem, onEndReached: () => {
|
|
797
|
-
|
|
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) {
|
|
798
832
|
void client.loadOlder().catch(() => { });
|
|
799
833
|
}
|
|
800
|
-
}, 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, 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, {})] }));
|
|
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, {})] }));
|
|
801
835
|
}
|
|
802
836
|
/** One horizontal media row on phones and in the browser preview. */
|
|
803
837
|
function AttachmentStrip({ children, label, height, recent = false }) {
|
|
@@ -1152,31 +1186,59 @@ export function MessagingComposer() {
|
|
|
1152
1186
|
attachmentActions.push({ key: 'poll', label: state.conversation?.kind === 'group' ? uiText("Poll") : uiText("Yes/No question"), icon: 'poll', run: () => setPollOpen(true) });
|
|
1153
1187
|
if (!editing && weatherAllowed)
|
|
1154
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 } });
|
|
1155
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') });
|
|
1156
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 }));
|
|
1157
1198
|
}
|
|
1158
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 }))] }));
|
|
1159
1200
|
}
|
|
1160
1201
|
/** Account navigation. Mount in the inbox/app toolbar, never in a contact menu. */
|
|
1161
|
-
export function MessagingAccountMenu({ inbox,
|
|
1162
|
-
const { text
|
|
1163
|
-
const
|
|
1164
|
-
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);
|
|
1165
1205
|
const menu = messagingMenuColors(design, 'friends'), items = design.menus?.friends?.items, layout = messagingMenuLayout(design.menus?.friends);
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
if (items?.
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
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' });
|
|
1175
1222
|
const button = useRef(null), viewport = useWindowDimensions(), [anchor, setAnchor] = useState({ x: 12, y: 12 });
|
|
1176
|
-
const width = Math.min(218, viewport.width - 24), menuHeight =
|
|
1177
|
-
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); });
|
|
1178
1225
|
const dismissed = () => { const next = pending.current; if (!next)
|
|
1179
|
-
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); }); };
|
|
1180
1242
|
useEffect(() => { if (!open && Platform.OS !== 'ios')
|
|
1181
1243
|
dismissed(); }, [open]);
|
|
1182
1244
|
useEffect(() => { if (!open || Platform.OS !== 'web')
|
|
@@ -1184,10 +1246,7 @@ export function MessagingAccountMenu({ inbox, onNewConversation, onNewGroup, onM
|
|
|
1184
1246
|
event.stopPropagation();
|
|
1185
1247
|
setOpen(false);
|
|
1186
1248
|
} }; document.addEventListener('keydown', key, true); return () => document.removeEventListener('keydown', key, true); }, [open]);
|
|
1187
|
-
return _jsxs(_Fragment, { children: [_jsx(Pressable, { ref: button, accessibilityRole: "button", accessibilityLabel:
|
|
1188
|
-
const top = Math.max(8, Math.min(anchor.y - rect.top, rect.height - menuHeight - 8));
|
|
1189
|
-
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") })] })] }) })] });
|
|
1190
|
-
} }), accountOpen && _jsx(MessagingAccountScreen, { inbox: inbox, 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) })] });
|
|
1191
1250
|
}
|
|
1192
1251
|
function MessagingWaitingChanges() {
|
|
1193
1252
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
@@ -1202,9 +1261,25 @@ function MessagingWaitingChanges() {
|
|
|
1202
1261
|
}
|
|
1203
1262
|
export function MessagingConversation() {
|
|
1204
1263
|
const { text: uiText } = useRobonoLocale();
|
|
1205
|
-
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
|
+
}, []);
|
|
1206
1281
|
const Header = components?.Header ?? MessagingHeader, List = components?.List ?? MessagingList, Composer = components?.Composer ?? MessagingComposer;
|
|
1207
|
-
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) })] }));
|
|
1208
1283
|
}
|
|
1209
1284
|
/** Embed inside your app's safe area and navigation. No engine, push or global audio side effects. */
|
|
1210
1285
|
export function MessagingScreen(props) {
|