@robono/messaging-react-native 0.22.0 → 0.24.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/BRIDGE-MESSENGER.md +72 -10
- package/CHANGELOG.md +26 -0
- package/README.md +83 -4
- package/RobonoMessagingRuntime.podspec +14 -0
- package/SBOM.spdx.json +967 -295
- package/android/build.gradle +7 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/robono/messaging/RobonoBackupCrypto.java +27 -0
- package/android/src/main/java/com/robono/messaging/RobonoMessagingPackage.java +11 -0
- package/app.plugin.cjs +8 -2
- package/dist/account.d.ts +4 -1
- package/dist/account.js +33 -11
- package/dist/attachment-preview.d.ts +11 -10
- package/dist/attachment-preview.js +15 -12
- package/dist/backup.d.ts +24 -0
- package/dist/backup.js +157 -0
- package/dist/brand.js +4 -4
- package/dist/bubble-design.js +5 -3
- package/dist/chat-options.d.ts +5 -1
- package/dist/chat-options.js +2 -2
- package/dist/contact-directory.d.ts +5 -1
- package/dist/contact-directory.js +11 -3
- package/dist/conversation-details.js +1 -1
- package/dist/delivery-bar.d.ts +2 -1
- package/dist/delivery-bar.js +2 -2
- package/dist/directory-navigation.d.ts +25 -0
- package/dist/directory-navigation.js +69 -0
- package/dist/expo-backup-crypto.d.ts +3 -0
- package/dist/expo-backup-crypto.js +17 -0
- package/dist/expo-backup-passkeys.d.ts +7 -0
- package/dist/expo-backup-passkeys.js +22 -0
- package/dist/expo-backup-settings.d.ts +4 -0
- package/dist/expo-backup-settings.js +41 -0
- package/dist/expo-bridge.d.ts +6 -0
- package/dist/expo-bridge.js +13 -2
- package/dist/expo-inbox-preferences.d.ts +3 -0
- package/dist/expo-inbox-preferences.js +9 -0
- package/dist/expo-media.js +3 -3
- package/dist/expo-messenger.js +10 -5
- package/dist/expo-notification-cleanup.js +3 -3
- package/dist/expo-notifications.js +7 -3
- package/dist/expo-reviews.d.ts +3 -0
- package/dist/expo-reviews.js +40 -0
- package/dist/expo-screen.d.ts +3 -0
- package/dist/expo-screen.js +87 -45
- package/dist/expo-thumbnails.d.ts +4 -0
- package/dist/expo-thumbnails.js +25 -3
- package/dist/expo.d.ts +4 -0
- package/dist/expo.js +4 -0
- package/dist/forward.js +2 -2
- package/dist/header-colors.d.ts +5 -0
- package/dist/header-colors.js +7 -0
- package/dist/inbox.d.ts +5 -2
- package/dist/inbox.js +25 -53
- package/dist/index.d.ts +8 -5
- package/dist/index.js +78 -36
- package/dist/loading-messages.d.ts +5 -0
- package/dist/loading-messages.js +10 -0
- package/dist/media-access.d.ts +8 -0
- package/dist/media-access.js +6 -1
- package/dist/media-readiness.d.ts +2 -0
- package/dist/media-readiness.js +1 -0
- package/dist/playback-reporting.d.ts +8 -0
- package/dist/playback-reporting.js +32 -0
- package/dist/popup.d.ts +6 -3
- package/dist/popup.js +6 -6
- package/dist/reviews.d.ts +15 -0
- package/dist/reviews.js +204 -0
- package/dist/scheduled.js +5 -5
- package/ios/RobonoBackupCrypto.m +30 -0
- package/package.json +21 -8
package/dist/index.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { messagingHeaderColors } from './header-colors.js';
|
|
3
|
+
import { MessagingLoadingMessages } from './loading-messages.js';
|
|
4
|
+
export { messagingHeaderColors } from './header-colors.js';
|
|
5
|
+
export { MessagingReviewInbox } from './reviews.js';
|
|
6
|
+
import { messageParts, selectMessagePart, composeMessageItems } from '@robono/messaging';
|
|
2
7
|
import { DeliveryBar } from './delivery-bar.js';
|
|
3
8
|
import { bubbleCorners, bubbleDelivery } from './bubble-design.js';
|
|
4
9
|
import { compareMessageOrder, isMessageIdentity } from '@robono/messaging';
|
|
@@ -165,7 +170,7 @@ function MessagingProviderContent({ children, ...props }) {
|
|
|
165
170
|
setForwarding([m]);
|
|
166
171
|
else
|
|
167
172
|
setDeleting([m]); }, [props.requestedMessageAction]);
|
|
168
|
-
const effectiveAppearance = props.appearance ?? state.settings?.appearance ?? defaultMessagingSettings().appearance;
|
|
173
|
+
const effectiveAppearance = props.appearance ?? state.settings?.appearance ?? props.initialAppearance ?? defaultMessagingSettings().appearance;
|
|
169
174
|
const styleScreen = state.conversation?.kind === 'group' ? (state.conversation.supergroup ? 'supergroupChat' : 'groupChat') : 'chat';
|
|
170
175
|
const design = useMemo(() => localizeMessagingAppearance(messagingScreenAppearance(effectiveAppearance, styleScreen), uiText), [effectiveAppearance, styleScreen, uiText]);
|
|
171
176
|
const messagingPopupColors = useMessagingPopupColors(design);
|
|
@@ -270,13 +275,6 @@ export function GroupDiscussion({ threadRoot, onClose }) {
|
|
|
270
275
|
return _jsxs(MessagingPopup, { screen: threadRoot ? 'replies' : 'pins', visible: visible, onDismiss: dismiss, title: threadRoot ? uiText("Replies") : uiText("Pinned messages"), onClose: () => setVisible(false), background: messagingPopupColors.background, children: [_jsx(Context.Provider, { value: { ...context, discussionPreview: true, discussionRoot: threadRoot, state: { ...state, messages: rows }, setReply: message => { if (message)
|
|
271
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") }) })] });
|
|
272
277
|
}
|
|
273
|
-
export function messagingHeaderColors(design, group) {
|
|
274
|
-
const screen = design.screens?.chat;
|
|
275
|
-
const background = group ? (screen?.groupHeaderBackground ?? '#1F5F7A') : (screen?.headerBackground ?? design.colors.accent);
|
|
276
|
-
const rgb = background.slice(1).match(/.{2}/g)?.map(v => parseInt(v, 16)) ?? [0, 0, 0];
|
|
277
|
-
const foreground = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000 > 150 ? '#050505' : '#F7F7F7';
|
|
278
|
-
return { background, foreground: (group ? screen?.groupHeaderText : screen?.headerText) ?? foreground };
|
|
279
|
-
}
|
|
280
278
|
function MessagingActivity({ ink }) {
|
|
281
279
|
const { text: uiText, count: uiCount, locale: uiLocale } = useRobonoLocale();
|
|
282
280
|
const { state, design, participants } = useMessagingUI(), [now, setNow] = useState(Date.now());
|
|
@@ -289,7 +287,7 @@ function MessagingActivity({ ink }) {
|
|
|
289
287
|
const lastSeenLabel = lastSeen ? new Date(lastSeen).toLocaleString(uiLocale, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' }) : '';
|
|
290
288
|
const names = typing.map(peer => participants?.[peer.userId]?.name ?? uiText('Someone'));
|
|
291
289
|
const text = typing.length ? (group ? (typing.length > 2 ? uiText('Several people are typing…') : typing.length === 2 ? uiText('{first} and {second} are typing…', { first: names[0], second: names[1] }) : uiText('{name} is typing…', { name: names[0] })) : uiText('Typing…')) : !group && online ? uiText('Online now') : !group && lastSeenLabel ? uiText('Last seen {time}', { time: lastSeenLabel }) : group ? uiCount(state.conversation?.memberCount ?? state.conversation?.memberIds?.length ?? 0, '{count} member', '{count} members') : '';
|
|
292
|
-
return
|
|
290
|
+
return _jsx(Text, { testID: "messaging-chat-activity", numberOfLines: 1, style: { color: ink, opacity: .8, fontSize: 14, lineHeight: 18, minHeight: 18 }, children: text || " " });
|
|
293
291
|
}
|
|
294
292
|
export function MessagingHeader({ children } = {}) {
|
|
295
293
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
@@ -307,7 +305,7 @@ export function MessagingHeader({ children } = {}) {
|
|
|
307
305
|
alignItems: "center",
|
|
308
306
|
paddingHorizontal: 12,
|
|
309
307
|
paddingVertical: 4,
|
|
310
|
-
minHeight: chatDesign?.headerSize === 'roomy' ? 72 : chatDesign?.headerSize === 'compact' ? 44 :
|
|
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) + (chatDesign?.showActivity !== false ? 18 : 0)) + (headerOptions?.paddingTop ?? 4) + (headerOptions?.paddingBottom ?? 4)), paddingTop: headerOptions?.paddingTop ?? 4, paddingBottom: headerOptions?.paddingBottom ?? 4, paddingStart: headerOptions?.paddingStart ?? 12, paddingEnd: headerOptions?.paddingEnd ?? 12,
|
|
311
309
|
backgroundColor: header.background,
|
|
312
310
|
gap: 4,
|
|
313
311
|
}, 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
|
|
@@ -319,7 +317,7 @@ export function MessagingHeader({ children } = {}) {
|
|
|
319
317
|
backgroundColor: c.incoming,
|
|
320
318
|
alignItems: "center",
|
|
321
319
|
justifyContent: "center",
|
|
322
|
-
}, children: _jsx(Text, { style: { color: c.incomingText }, children: state.conversation?.kind === 'group' ? (state.conversation.name ?? 'Group').slice(0, 1) : contact.name.slice(0, 1) }) }))), _jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [_jsx(Text, { numberOfLines: 1, style: { color: header.foreground, fontSize: chatDesign?.titleSize ?? 18, textAlign: chatDesign?.titleAlign ?? 'left', fontWeight: "800" }, children: state.conversation?.kind === 'group' ? state.conversation.name : contact.name }), chatDesign?.showActivity !== false && _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' ? _jsx(PrivacyControl, { color: header.foreground }) : (onContactOptions || 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: 42, height: 42, 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: 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, { 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: 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)] }));
|
|
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 }), chatDesign?.showActivity !== false && _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' ? extras && _jsx(View, { style: { width: 44, height: 44 }, children: _jsx(PrivacyControl, { color: header.foreground }) }) : _jsx(View, { style: { width: 42, height: 44 }, children: (onContactOptions || 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: 42, height: 42, 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)] }));
|
|
323
321
|
}
|
|
324
322
|
function PrivacyControl({ color }) {
|
|
325
323
|
const messagingPopupColors = useMessagingPopupColors();
|
|
@@ -352,11 +350,11 @@ function QuotedPreview({ message, ink }) {
|
|
|
352
350
|
}, [message?.id, message?.conversationId, message?.media?.assetId, message?.deleted, attachmentPreview]);
|
|
353
351
|
const name = message && !message.deleted ? (message.senderId === userId ? 'You' : participants?.[message.senderId]?.name ?? (state.conversation?.kind === 'direct' ? contact.name : 'Chat member')) : null;
|
|
354
352
|
const media = message && !message.deleted && message.kind !== 'text' && message.kind !== 'poll';
|
|
355
|
-
return _jsxs(View, { testID: "quoted-message-preview", style: { flexDirection: 'row', alignItems: 'flex-start', gap: 8, minWidth: 0 }, children: [media && (thumbnail ? _jsx(Image, { accessibilityLabel: uiText("Quoted attachment thumbnail"), source: { uri: thumbnail }, onError: () => setThumbnail(undefined), resizeMode: "
|
|
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)}` : ''] })] })] });
|
|
356
354
|
}
|
|
357
355
|
/** Thumbnails stay local to the view and are discarded on conversation/message changes. */
|
|
358
356
|
const heardVoiceMessages = new WeakMap();
|
|
359
|
-
function MediaContent({ message, ink, footer, onOpen, onLongPress }) {
|
|
357
|
+
function MediaContent({ message, ink, footer, onOpen, onLongPress, sendRetry }) {
|
|
360
358
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
361
359
|
const { attachmentPreview, components, design, userId, client } = useMessagingUI();
|
|
362
360
|
const [, updateHeard] = useState(0), voiceKey = message.conversationId + ':' + message.id + ':' + message.media?.assetId;
|
|
@@ -368,13 +366,37 @@ function MediaContent({ message, ink, footer, onOpen, onLongPress }) {
|
|
|
368
366
|
return; rows.add(voiceKey); if (rows.size > 2048)
|
|
369
367
|
rows.delete(rows.values().next().value); updateHeard(n => n + 1); };
|
|
370
368
|
const { preview, failed, retry, onImageError } = useAttachmentPreview(message, attachmentPreview, useMessagingUI().active !== false);
|
|
369
|
+
const [imageSize, setImageSize] = useState();
|
|
370
|
+
useEffect(() => {
|
|
371
|
+
if (Platform.OS !== 'web' || !preview.uri)
|
|
372
|
+
return;
|
|
373
|
+
let current = true;
|
|
374
|
+
const uri = preview.uri;
|
|
375
|
+
// Web's image loader does not supply React Native's source dimensions.
|
|
376
|
+
// Decode the same local preview URL, never the full attachment.
|
|
377
|
+
Image.getSize(uri, (width, height) => { if (current && width > 0 && height > 0)
|
|
378
|
+
setImageSize({ uri, width, height }); }, () => { });
|
|
379
|
+
return () => { current = false; };
|
|
380
|
+
}, [preview.uri]);
|
|
381
|
+
// Size the decoded preview, never the full attachment. A recycled row cannot
|
|
382
|
+
// reuse the previous image's shape.
|
|
383
|
+
const size = imageSize?.uri === preview.uri ? imageSize : undefined;
|
|
384
|
+
const scale = size ? Math.min(1, 220 / size.width, 280 / size.height) : 1;
|
|
385
|
+
const previewWidth = size ? size.width * scale : 220, previewHeight = size ? size.height * scale : 155;
|
|
371
386
|
if (message.kind === 'voice') {
|
|
372
387
|
const Voice = components?.VoiceMessage;
|
|
373
|
-
return Voice ? _jsx(Voice, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, message: message, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, footer: footer, onOpen: onOpen, onLongPress: onLongPress }) : _jsx(VoicePlayback, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, durationMs: message.media?.durationMs, footer: footer, onToggle: onOpen, onLongPress: onLongPress });
|
|
388
|
+
return Voice ? _jsx(Voice, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, message: message, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, footer: _jsxs(_Fragment, { children: [footer, sendRetry] }), onOpen: onOpen, onLongPress: onLongPress }) : _jsx(VoicePlayback, { mine: message.senderId === userId, heard: heard, onPlayed: onPlayed, background: message.senderId === userId ? design.colors.outgoing : design.colors.incoming, ink: ink, accent: design.colors.accent, waveform: preview.waveform ?? message.media?.waveform, showWaveform: design.showWaveform !== false, durationMs: message.media?.durationMs, footer: _jsxs(_Fragment, { children: [footer, sendRetry] }), onToggle: onOpen, onLongPress: onLongPress });
|
|
374
389
|
}
|
|
375
390
|
if (message.kind === 'image' || message.kind === 'video')
|
|
376
|
-
return _jsx(View, { style: { width:
|
|
377
|
-
|
|
391
|
+
return _jsx(View, { style: { width: previewWidth, maxWidth: '100%', gap: 0 }, children: _jsxs(View, { testID: "media-bubble-surface", style: { width: '100%', aspectRatio: previewWidth / previewHeight, ...bubbleCorners(design, message.senderId === userId, !!message.text), overflow: 'hidden', alignItems: 'center', justifyContent: 'center', backgroundColor: '#00000012' }, children: [preview.uri ? _jsx(Image, { source: { uri: preview.uri }, accessibilityLabel: message.media?.fileName ?? uiText(mediaNames[message.kind]), resizeMode: "contain", onLoad: event => {
|
|
392
|
+
const source = event.nativeEvent.source;
|
|
393
|
+
// React Native Web supplies the decoded HTML image as the event target.
|
|
394
|
+
const target = event.nativeEvent.target;
|
|
395
|
+
const width = source?.width ?? target?.naturalWidth, height = source?.height ?? target?.naturalHeight;
|
|
396
|
+
if (width && height && Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0)
|
|
397
|
+
setImageSize({ uri: preview.uri, width, height });
|
|
398
|
+
}, 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
|
+
return _jsxs(View, { testID: "file-message-content", style: { flexDirection: 'row', alignItems: 'center', gap: 10, width: 220, maxWidth: '100%', minHeight: 56, paddingHorizontal: 12, paddingVertical: 6, ...bubbleCorners(design, message.senderId === userId), ...(message.senderId === userId && design.messageStatus?.style === 'circle' ? { paddingRight: 28 } : {}) }, children: [_jsx(MessageIcon, { name: "document", color: design.colors.accent, size: 24 }), _jsxs(View, { style: { flex: 1, gap: 2 }, children: [_jsx(Text, { numberOfLines: 2, style: { color: ink, fontSize: 14, fontWeight: '600' }, children: message.media?.fileName ?? uiText("File") }), _jsxs(Text, { style: { color: ink, fontSize: 12, opacity: 0.75 }, children: [message.media?.fileName?.split('.').pop()?.toUpperCase(), " \u00B7 ", fileSize(message.media?.byteSize)] }), sendRetry] })] });
|
|
378
400
|
}
|
|
379
401
|
function messageTimeLabel(message, format, text) { return (message.editedAt && !message.deleted ? text('edited') + ' · ' : '') + format(message.createdAt); }
|
|
380
402
|
function MessageMetadata(_props) { return null; }
|
|
@@ -407,7 +429,10 @@ export function MessagingBubble(props) {
|
|
|
407
429
|
const context = useMessagingUI(), last = useRef(null);
|
|
408
430
|
const selected = selectBubbleUI(context, props, last.current);
|
|
409
431
|
last.current = selected;
|
|
410
|
-
return _jsx(
|
|
432
|
+
return _jsx(MessagingBubbleItems, { message: props.message, pendingStatus: props.pendingStatus, ui: selected });
|
|
433
|
+
}
|
|
434
|
+
function MessagingBubbleItems({ message, pendingStatus, ui }) {
|
|
435
|
+
return _jsx(_Fragment, { children: messageParts(message).map((item, index) => _jsx(MessagingBubbleView, { message: item, pendingStatus: pendingStatus, ui: index ? { ...ui, grouped: true } : ui }, item.part ?? 'whole')) });
|
|
411
436
|
}
|
|
412
437
|
const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, pendingStatus, ui }) {
|
|
413
438
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
@@ -424,6 +449,8 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
424
449
|
const corners = bubbleCorners(design, mine), bubbleRadius = corners.borderTopRightRadius;
|
|
425
450
|
const status = bubbleDelivery(message, deliveryStatus, !!state.settings?.features.readReceipts, design);
|
|
426
451
|
const circleStatus = mine && status.style === 'circle';
|
|
452
|
+
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');
|
|
427
454
|
const messageGap = design.presentation?.messageSpacing === 'compact' ? 4 : design.presentation?.messageSpacing === 'relaxed' ? 12 : 8;
|
|
428
455
|
const visual = message.kind === 'image' || message.kind === 'video', voice = message.kind === 'voice';
|
|
429
456
|
const grouped = ui.grouped;
|
|
@@ -433,7 +460,8 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
433
460
|
const leaveMenu = (next) => { afterMenu.current = next; setActions(false); if (Platform.OS !== 'ios')
|
|
434
461
|
menuDismissed(); };
|
|
435
462
|
useEffect(() => () => { afterMenu.current = null; }, [client, message.id]);
|
|
436
|
-
const
|
|
463
|
+
const wholeMessage = message.part ? client.getSnapshot().messages.find(m => m.id === message.id) ?? message : message;
|
|
464
|
+
const canChange = (!message.part || wholeMessage !== message) && !extra?.weather && !extra?.call && mine && !pendingStatus && !message.deleted && !!state.messageActionsAvailable && !!state.settings?.enabled && state.conversation?.canSend !== false && !wholeMessage.readAt && !wholeMessage.textReadAt;
|
|
437
465
|
const anchor = useRef(null), viewport = useWindowDimensions();
|
|
438
466
|
const [menuPosition, setMenuPosition] = useState({ x: 12, y: 12, above: false, available: 400 }), [hovered, setHovered] = useState(false);
|
|
439
467
|
const [addressBubbleHeight, setAddressBubbleHeight] = useState(44);
|
|
@@ -447,7 +475,7 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
447
475
|
const translation = state.translationPreference;
|
|
448
476
|
const translationLanguage = translation?.language ?? languageTools?.preferredLanguage ?? language;
|
|
449
477
|
const sourceLanguage = participants?.[message.senderId]?.language ?? (state.conversation?.kind === 'direct' ? contact.language : undefined) ?? translation?.sourceLanguage;
|
|
450
|
-
const canTranslate = languageTools?.translation !== false && !mine && !extra?.weather && !extra?.call && !pendingStatus && ['text', 'voice', 'video'].includes(message.kind) && !!state.settings?.enabled && !!state.settings.features.translation && client.hasLanguageTools() && !message.deleted && translation?.mode !== undefined && translation.mode !== 'off' && needsMessageTranslation(sourceLanguage, translationLanguage) && (translation.mode !== 'voice' || languageTools?.voiceOutput === false || !!TranslationVoice);
|
|
478
|
+
const canTranslate = message.part !== 'text' && languageTools?.translation !== false && !mine && !extra?.weather && !extra?.call && !pendingStatus && ['text', 'voice', 'video'].includes(message.kind) && !!state.settings?.enabled && !!state.settings.features.translation && client.hasLanguageTools() && !message.deleted && translation?.mode !== undefined && translation.mode !== 'off' && needsMessageTranslation(sourceLanguage, translationLanguage) && (translation.mode !== 'voice' || languageTools?.voiceOutput === false || !!TranslationVoice);
|
|
451
479
|
const transformGeneration = useRef(0), transformAbort = useRef(null);
|
|
452
480
|
useEffect(() => { transformAbort.current?.abort(); transformGeneration.current++; setTransformed(null); setTransforming(false); setShowOriginal(false); setTranslationAutoPlay(false); return () => { transformAbort.current?.abort(); transformGeneration.current++; }; }, [message.id, message.deleted, message.text, message.media?.assetId, translationLanguage, translation?.mode, sourceLanguage, state.settings?.enabled, state.settings?.features.transcription, state.settings?.features.translation, languageTools?.translation, languageTools?.transcription, languageTools?.voiceOutput, languageTools?.revision]);
|
|
453
481
|
useEffect(() => { if (!transformed?.audio)
|
|
@@ -520,21 +548,34 @@ const MessagingBubbleView = React.memo(function MessagingBubbleView({ message, p
|
|
|
520
548
|
const bigEmoji = message.kind === 'text' && !message.replyTo && !extra && !canTranslate && !transformed && isBigEmojiText(message.text);
|
|
521
549
|
const showingTransform = !!transformed && !showOriginal && (transformed.kind === 'transcript' || canTranslate);
|
|
522
550
|
const languageActions = (canTranscript || canTranslate || transformed) && _jsxs(View, { testID: "message-language-actions", style: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: voice && !showingTransform ? 'flex-end' : 'flex-start', columnGap: 8, rowGap: 0 }, children: [transforming && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel"), onPress: () => { transformAbort.current?.abort(); transformGeneration.current++; setTransforming(false); }, hitSlop: 8, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: uiText("Cancel") }) }), transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original"), onPress: () => { setTranslationAutoPlay(false); setShowOriginal(v => !v); }, hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: showOriginal ? (transformed.kind === 'transcript' ? 'Show transcript' : 'Show translation') : uiText("Show original") }) }), canTranscript && !transformed && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Read transcript"), disabled: transforming, onPress: () => void transform('transcript'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: transforming ? uiText("Transcribing…") : uiText("Transcript") }) }), canTranslate && transformed?.kind !== 'translation' && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play translation") : uiText("Translate message"), disabled: transforming, onPress: () => void transform('translation', translation.mode === 'voice' && languageTools?.voiceOutput !== false ? 'voice' : 'text'), hitSlop: 8, style: { minHeight: 17, paddingVertical: 1, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent, fontSize: 11, lineHeight: 15 }, children: translation.mode === 'voice' && languageTools?.voiceOutput !== false ? uiText("Play Translation") : uiText("Translate") }) })] });
|
|
551
|
+
const messageMeta = (placement) => {
|
|
552
|
+
const time = timePosition === placement, circle = circleStatus && circlePosition === placement;
|
|
553
|
+
if (!time && !circle)
|
|
554
|
+
return null;
|
|
555
|
+
const textColor = placement === 'below' ? c.secondary : visual ? '#ffffff' : ink;
|
|
556
|
+
const circleColor = status.phase === 'delivered' ? textColor : status.phase === 'sent' ? c.secondary : status.phase === 'consumed' ? c.accent : status.color;
|
|
557
|
+
const rgb = circleColor.slice(1).match(/../g)?.map(v => parseInt(v, 16)) ?? [0, 0, 0];
|
|
558
|
+
const checkColor = rgb[0] * .299 + rgb[1] * .587 + rgb[2] * .114 > 150 ? '#111111' : '#ffffff';
|
|
559
|
+
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
|
+
};
|
|
561
|
+
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;
|
|
523
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 ?? '') }) });
|
|
524
|
-
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: mine ? 'right' : 'left' }, children: renderText(message.text ?? '') }), pendingStatus && footer] }) : _jsx(MediaContent, { message: message, ink: ink, accent: c.accent, footer: voice ? languageActions : undefined, onOpen: () => void open(), onLongPress: menu });
|
|
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: mine ? 'right' : '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 });
|
|
525
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: mine ? 'right' : 'left' }, children: transformed.text }), !voice && footer] }) : originalContent;
|
|
526
566
|
const regionProps = { message, mine, appearance: design, pendingStatus };
|
|
527
567
|
const bodyContent = components?.MessageBody && !message.deleted ? _jsx(components.MessageBody, { ...regionProps, children: content }) : content;
|
|
528
|
-
const
|
|
568
|
+
const topTail = design.presentation?.bubbleStyle === 'top-tail' && !visual && !voice && !extra && !socialReady && !bigEmoji;
|
|
569
|
+
const statusTopRadius = voice && !showingTransform ? 24 : topTail ? 0 : bubbleRadius, statusBottomRadius = voice && !message.text && !showingTransform ? 24 : corners.borderBottomRightRadius;
|
|
529
570
|
// Cover the full inside edge; each curved end tapers to the bubble's corner.
|
|
530
|
-
const bubbleBody = _jsxs(_Fragment, { children: [mine && _jsx(View, { testID: 'message-status-' + status.phase, pointerEvents: "none", accessibilityLabel:
|
|
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 }) }), message.replyTo && message.replyTo !== discussionRoot && _jsx(Pressable, { 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: 'flex-start', maxWidth: 220, minHeight: 44, borderRadius: 10, backgroundColor: chatSurface(c.background) === '#ffffff' ? '#f3f3f3' : '#242424', borderWidth: StyleSheet.hairlineWidth, borderColor: c.secondary + '55', paddingHorizontal: 8, paddingTop: 6, paddingBottom: 7, marginBottom: 4, overflow: 'hidden' }, children: _jsx(QuotedPreview, { message: ui.quoted ? selectMessagePart(ui.quoted, message.replyPart) : undefined, ink: c.foreground }) }), !mine && !grouped && state.conversation?.kind === 'group' && _jsx(Text, { style: { color: ink, fontSize: 12, fontWeight: '600', marginBottom: 5 }, children: message.deleted ? uiText("Former member") : participants?.[message.senderId]?.name ?? uiText("Member") }), message.custom || extra?.address || extra?.weather || extra?.call || voice || message.kind === 'poll' ? bodyContent : _jsx(Pressable, { accessibilityRole: message.kind === 'text' ? undefined : 'button', accessibilityLabel: message.kind === 'text' ? undefined : uiText('{kind}: {name}', { kind: uiText(mediaNames[message.kind]), name: message.media?.fileName ?? uiText('Open attachment') }), disabled: busy, onLongPress: menu, onPress: message.kind === 'text' ? () => { if (quoteGesture.suppressPress())
|
|
531
572
|
return; if (extra?.address)
|
|
532
573
|
extraRef.current?.open();
|
|
533
574
|
else
|
|
534
|
-
socialRef.current?.open(); } : () => void open(), children: bodyContent }), !discussionPreview && state.discussionAvailable && !!message.replyCount && _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: message.replyCount + ' ' + (message.replyCount === 1 ? 'reply' : 'replies'), onPress: () => openDiscussion(message.id), style: { minHeight: 32, justifyContent: 'center' }, children: _jsxs(Text, { style: { color: c.accent, fontSize: 12, fontWeight: '600' }, children: [message.replyCount, " ", message.replyCount === 1 ? uiText("reply") : uiText("replies")] }) }), message.kind !== 'text' && !!message.text && _jsx(View, { testID: voice ? 'voice-message-caption' : undefined, style: voice && !showingTransform ? { maxWidth: 220, alignSelf: mine ? 'flex-end' : 'flex-start', marginTop: 1, paddingTop: 4, paddingBottom: 1, borderRadius: 14, ...(mine ? { borderBottomEndRadius: 3 } : { borderBottomStartRadius: 3 }), backgroundColor: mine ? c.outgoing : c.incoming } : visual ? { backgroundColor: mine ? c.outgoing : c.incoming, ...corners, borderTopLeftRadius: 0, borderTopRightRadius: 0, paddingHorizontal: 6, paddingVertical: 3, ...(circleStatus ? { paddingEnd: 24 } : {}) } : undefined, children: _jsx(Text, { testID: "attachment-caption", selectable: true, onLongPress: menu, style: { color: ink, fontSize: 16, lineHeight: 22, marginTop: voice ? 0 : 2, textAlign: mine ? 'right' : 'left', alignSelf: 'stretch', paddingHorizontal: voice || message.kind === 'document' ? 8 : 2, 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, 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") }) })] }),
|
|
535
|
-
return _jsxs(View, { ...(Platform.OS === 'web' ? { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onContextMenu: (event) => { event.preventDefault(); menu(); } } : {}), style: { width: '100%', position: 'relative', marginTop: messageGap + (message.reactions?.length ? 16 : 0), marginBottom: 0 }, children: [quoteGesture.infoLoaded && _jsxs(Animated.View, { pointerEvents: "none", testID: "message-info-reveal", accessible: false, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, minHeight: 52, width: messageInfoRevealWidth, justifyContent: 'center', ...(mine ? { start: 0, alignItems: 'flex-start' } : { end: 0, alignItems: 'flex-end' }), opacity: quoteGesture.infoOpacity }, children: [_jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("SENT:") }), _jsx(Text, { style: { color: c.foreground, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: messageTimeLabel(message, ui.formatMessageTime, uiText) })] }), mine && state.settings?.features.readReceipts && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("READ:") }), _jsx(Text, { style: { color: message.readAt ? c.foreground : c.secondary, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: message.readAt ? ui.formatMessageTime(message.readAt) : uiText("Not yet") })] })] }), quoting && _jsxs(Animated.View, { pointerEvents: "none", ...(Platform.OS === 'web' ? { 'aria-hidden': true } : { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' }), testID: `quote-reveal-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, ...(mine ? { end: 0 } : { start: 0 }), width: messageReplyRevealWidth, minHeight: 52, gap: 3, alignItems: 'center', justifyContent: 'center', opacity: quoteGesture.revealOpacity }, children: [_jsx(View, { style: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center', backgroundColor: chatSurface(c.background), borderWidth: 1.5, borderColor: c.secondary + '40' }, children: _jsx(MessageIcon, { name: "quote", color: c.accent, size: 30 }) }), _jsx(Text, { style: { color: c.secondary, fontSize: 10, fontWeight: '900' }, children: uiText("QUOTE MESSAGE") })] }), _jsxs(Animated.View, { ref: node => { anchor.current = node; if (quoteGesture.webRef)
|
|
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: mine ? 'right' : 'left', alignSelf: 'stretch', paddingHorizontal: voice || message.kind === 'document' ? 8 : 2, 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
|
+
return _jsxs(View, { ...(Platform.OS === 'web' ? { onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onContextMenu: (event) => { event.preventDefault(); menu(); } } : {}), style: { width: '100%', position: 'relative', marginTop: messageGap + (message.reactions?.length ? 16 : 0), marginBottom: 0 }, children: [quoteGesture.infoLoaded && _jsxs(Animated.View, { pointerEvents: "none", testID: "message-info-reveal", accessible: false, accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, minHeight: 52, width: messageInfoRevealWidth, justifyContent: 'center', ...(mine ? { start: 0, alignItems: 'flex-start' } : { end: 0, alignItems: 'flex-end' }), opacity: quoteGesture.infoOpacity }, children: [_jsx(_Fragment, { children: timePosition === 'slide' && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("SENT:") }), _jsx(Text, { testID: "message-slide-time", style: { color: c.foreground, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: messageTimeLabel(message, ui.formatMessageTime, uiText) })] }) }), mine && state.settings?.features.readReceipts && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'baseline', gap: 4 }, children: [_jsx(Text, { style: { color: c.secondary, fontSize: 8, lineHeight: 11, fontWeight: '900' }, children: uiText("READ:") }), _jsx(Text, { style: { color: message.readAt ? c.foreground : c.secondary, fontSize: 10, lineHeight: 12, fontWeight: '800' }, children: message.readAt ? ui.formatMessageTime(message.readAt) : uiText("Not yet") })] })] }), quoting && _jsxs(Animated.View, { pointerEvents: "none", ...(Platform.OS === 'web' ? { 'aria-hidden': true } : { accessible: false, accessibilityElementsHidden: true, importantForAccessibility: 'no-hide-descendants' }), testID: `quote-reveal-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.revealWebStyle, position: 'absolute', top: '50%', marginTop: -26, ...(mine ? { end: 0 } : { start: 0 }), width: messageReplyRevealWidth, minHeight: 52, gap: 3, alignItems: 'center', justifyContent: 'center', opacity: quoteGesture.revealOpacity }, children: [_jsx(View, { style: { width: 40, height: 40, borderRadius: 20, alignItems: 'center', justifyContent: 'center', backgroundColor: chatSurface(c.background), borderWidth: 1.5, borderColor: c.secondary + '40' }, children: _jsx(MessageIcon, { name: "quote", color: c.accent, size: 30 }) }), _jsx(Text, { style: { color: c.secondary, fontSize: 10, fontWeight: '900' }, children: uiText("QUOTE MESSAGE") })] }), _jsxs(Animated.View, { ref: node => { anchor.current = node; if (quoteGesture.webRef)
|
|
536
577
|
quoteGesture.webRef.current = node; }, ...quoteGesture.handlers, accessibilityActions: quoting ? [{ name: "quote", label: uiText("Quote message") }] : undefined, onAccessibilityAction: event => { if (quoting && event.nativeEvent.actionName === "quote")
|
|
537
|
-
setReply(message); }, testID: `message-${message.kind}-${mine ? 'outgoing' : 'incoming'}`, style: { ...quoteGesture.webStyle, transform: [{ translateX: quoteGesture.offset }], ...(Platform.OS === "web" && !pendingStatus ? { touchAction: "pan-y", userSelect: "none" } : {}), alignSelf: mine ? 'flex-end' : 'flex-start', maxWidth: `${design.screens?.chat?.messageWidth ?? 88}%`, backgroundColor: visual ? 'transparent' : mine ? c.outgoing : c.incoming, ...corners, ...(
|
|
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 })] });
|
|
538
579
|
});
|
|
539
580
|
export function MessageDeletion({ messages, onClose }) {
|
|
540
581
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
@@ -576,7 +617,7 @@ const MessagingHistoryRow = React.memo(function MessagingHistoryRow({ item, prev
|
|
|
576
617
|
const date = new Date(item.createdAt), start = !previous || date.toDateString() !== new Date(previous.createdAt).toDateString();
|
|
577
618
|
const checked = selection.some(m => m.id === item.id), selectable = selection.length > 0 && !item.pendingStatus && !item.deleted;
|
|
578
619
|
const toggle = () => setSelection(checked ? selection.filter(m => m.id !== item.id) : [...selection, item]);
|
|
579
|
-
return _jsxs(View, { testID: highlighted ? 'focused-message' : undefined, style: highlighted || checked ? { backgroundColor: design.colors.accent + '20', borderRadius: 8 } : undefined, children: [start && design.screens?.chat?.showDates !== false && _jsx(Text, { testID: "messaging-date-separator", style: { alignSelf: 'center', fontSize: design.screens?.chat?.dateSize ?? 12, color: design.screens?.chat?.dateText ?? design.colors.secondary, backgroundColor: design.screens?.chat?.dateBackground ?? chatSurface(design.colors.background), borderRadius: 7, paddingHorizontal: 12, paddingVertical: 5, marginTop: 4, marginBottom: 10 }, children: date.toDateString() === new Date().toDateString() ? uiText("Today") : date.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric' }) }), _jsx(View, { style: { paddingLeft: selection.length ? 32 : 0 }, pointerEvents: selection.length ? 'none' : 'auto', accessibilityElementsHidden: selection.length > 0, importantForAccessibility: selection.length ? 'no-hide-descendants' : 'auto', ...(Platform.OS === 'web' && selection.length ? { 'aria-hidden': true } : {}), children: Message ? _jsx(Message, { message: item }) : _jsx(
|
|
620
|
+
return _jsxs(View, { testID: highlighted ? 'focused-message' : undefined, style: highlighted || checked ? { backgroundColor: design.colors.accent + '20', borderRadius: 8 } : undefined, children: [start && design.screens?.chat?.showDates !== false && _jsx(Text, { testID: "messaging-date-separator", style: { alignSelf: 'center', fontSize: design.screens?.chat?.dateSize ?? 12, color: design.screens?.chat?.dateText ?? design.colors.secondary, backgroundColor: design.screens?.chat?.dateBackground ?? chatSurface(design.colors.background), borderRadius: 7, paddingHorizontal: 12, paddingVertical: 5, marginTop: 4, marginBottom: 10 }, children: date.toDateString() === new Date().toDateString() ? uiText("Today") : date.toLocaleDateString(uiLocale, { month: 'short', day: 'numeric' }) }), _jsx(View, { style: { paddingLeft: selection.length ? 32 : 0 }, pointerEvents: selection.length ? 'none' : 'auto', accessibilityElementsHidden: selection.length > 0, importantForAccessibility: selection.length ? 'no-hide-descendants' : 'auto', ...(Platform.OS === 'web' && selection.length ? { 'aria-hidden': true } : {}), children: Message ? _jsx(Message, { message: item }) : _jsx(MessagingBubbleItems, { message: item, pendingStatus: item.pendingStatus, ui: bubbleUI }) }), selectable && _jsx(Pressable, { accessibilityRole: "checkbox", accessibilityLabel: uiText('Select message: {message}', { message: item.text || item.media?.fileName || uiText(mediaNames[item.kind] || 'Message') }), accessibilityState: { checked }, onPress: toggle, style: { position: 'absolute', inset: 0, justifyContent: 'center' }, children: _jsx(View, { style: { width: 24, height: 24, borderRadius: 12, borderWidth: 1, borderColor: design.colors.accent, backgroundColor: checked ? design.colors.accent : design.colors.background, alignItems: 'center', justifyContent: 'center' }, children: checked && _jsx(MessageIcon, { name: "check", size: 16, color: "#ffffff" }) }) })] });
|
|
580
621
|
});
|
|
581
622
|
const conversationReadingPositions = new WeakMap();
|
|
582
623
|
export function MessagingList() {
|
|
@@ -693,7 +734,7 @@ export function MessagingList() {
|
|
|
693
734
|
// Existing Bridge receipts belong to individual messages. A visible
|
|
694
735
|
// thumbnail is not a read/heard event; its viewer reports consumption.
|
|
695
736
|
if (ui.state.chronologicalHistory && ui.state.attachmentReceiptsAvailable) {
|
|
696
|
-
for (const item of visible.filter(m => m.kind === 'text'
|
|
737
|
+
for (const item of visible.filter(m => !m.deleted && (m.kind === 'text' ? !m.readAt : !!m.text && !m.textReadAt))) {
|
|
697
738
|
const key = item.conversationId + ':' + item.id;
|
|
698
739
|
if (bridgeReads.current.has(key))
|
|
699
740
|
continue;
|
|
@@ -756,7 +797,7 @@ export function MessagingList() {
|
|
|
756
797
|
if (state.hasMore && !state.loading && !state.historyError) {
|
|
757
798
|
void client.loadOlder().catch(() => { });
|
|
758
799
|
}
|
|
759
|
-
}, onEndReachedThreshold: 0.2, ListHeaderComponent: state.historyWindow && state.hasNewer ? _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Load newer messages"), disabled: state.loading, onPress: () => void client.loadNewer().catch(() => { }), style: { padding: 10, minHeight: 44, alignItems: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: uiText("Load newer messages") }) }) : null, ListFooterComponent: _jsxs(_Fragment, { children: [state.messages.length > 0 && (state.loading || state.historyError || state.hasMore) ? _jsx(View, { style: { padding: 10, alignItems: 'center' }, children: state.loading ? _jsx(ActivityIndicator, { accessibilityLabel: uiText("Loading earlier messages"), color: design.colors.accent }) : _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: state.historyError ? uiText("Retry earlier messages") : uiText("Load earlier messages"), onPress: () => void client.loadOlder().catch(() => { }), style: { minHeight: 44, justifyContent: 'center' }, children: _jsx(Text, { style: { color: design.colors.accent }, children: state.historyError ? uiText("Earlier messages could not load. Retry") : uiText("Load earlier messages") }) }) }) : null, context.extrasState?.privacyLens && _jsx(View, { testID: "privacy-history-spacer", style: { height: Math.max(0, historyHeight - privacyReadingStripHeight) } })] }), ListEmptyComponent: _jsx(
|
|
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, {})] }));
|
|
760
801
|
}
|
|
761
802
|
/** One horizontal media row on phones and in the browser preview. */
|
|
762
803
|
function AttachmentStrip({ children, label, height, recent = false }) {
|
|
@@ -884,7 +925,7 @@ export function MessagingComposer() {
|
|
|
884
925
|
const outgoing = {
|
|
885
926
|
...content,
|
|
886
927
|
...(content.text && mentionsFor(content.text).length ? { mentions: mentionsFor(content.text) } : {}),
|
|
887
|
-
...(reply && features?.replies ? { replyTo: reply.id, ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {}),
|
|
928
|
+
...(reply && features?.replies ? { replyTo: reply.id, ...(reply.part ? { replyPart: reply.part } : {}), ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {}),
|
|
888
929
|
};
|
|
889
930
|
const prepare = content.media && prepareAttachment && content.kind !== 'text' && content.kind !== 'poll'
|
|
890
931
|
? async () => ({ ...outgoing, media: await prepareAttachment(content.kind, content.media) })
|
|
@@ -925,10 +966,10 @@ export function MessagingComposer() {
|
|
|
925
966
|
return;
|
|
926
967
|
inFlight.current = true;
|
|
927
968
|
const conversationId = state.conversationId;
|
|
928
|
-
const quote = reply && features?.replies ? { replyTo: reply.id, ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {};
|
|
969
|
+
const quote = reply && features?.replies ? { replyTo: reply.id, ...(reply.part ? { replyPart: reply.part } : {}), ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {};
|
|
929
970
|
const attachments = [...selectedRef.current];
|
|
930
971
|
const batchId = attachments.length > 1 ? 'batch-' + Date.now().toString(36) + '-' + Math.random().toString(36).slice(2) : null;
|
|
931
|
-
const outgoing = attachments
|
|
972
|
+
const outgoing = composeMessageItems(attachments, draft, quote, mentionsFor(draft), batchId ?? '');
|
|
932
973
|
setSelected([]);
|
|
933
974
|
setDraft('');
|
|
934
975
|
setMentionIds([]);
|
|
@@ -957,7 +998,7 @@ export function MessagingComposer() {
|
|
|
957
998
|
let requested = false;
|
|
958
999
|
try {
|
|
959
1000
|
const attachments = [...selectedRef.current];
|
|
960
|
-
const quote = reply && features?.replies ? { replyTo: reply.id, ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {};
|
|
1001
|
+
const quote = reply && features?.replies ? { replyTo: reply.id, ...(reply.part ? { replyPart: reply.part } : {}), ...(reply.threadRoot ? { threadRoot: reply.threadRoot } : {}) } : {};
|
|
961
1002
|
const signature = JSON.stringify({ draft, attachments, quote });
|
|
962
1003
|
let attempt = scheduleAttempt.current;
|
|
963
1004
|
if (!attempt || attempt.signature !== signature) {
|
|
@@ -1081,7 +1122,7 @@ export function MessagingComposer() {
|
|
|
1081
1122
|
function removeSelected(id) { const item = selectedRef.current.find(item => item.id === id); setSelected(items => items.filter(item => item.id !== id)); if (item && (!editing || item.media.assetId !== editing.media?.assetId))
|
|
1082
1123
|
void releaseAttachment?.(item.media); }
|
|
1083
1124
|
function renderAttachments(voiceReview, blocked = busy) {
|
|
1084
|
-
return selected.length > 0 || voiceReview ? _jsxs(AttachmentStrip, { label: uiText("Pending attachments"), height: selected.some(item => item.kind === 'document') ? 104 : 86, children: [selected.map(item => item.kind === 'voice' && item.media.assetId !== editing?.media?.assetId && components?.VoiceAttachment ? _jsx(components.VoiceAttachment, { media: item.media, appearance: design, disabled: blocked, onRemove: () => removeSelected(item.id) }, item.id) : _jsxs(View, { style: { width: 88, paddingTop: 8, paddingRight: 10 }, children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Preview {name}', { name: item.media.fileName ?? uiText(mediaNames[item.kind]) }), disabled: blocked || !openAttachment, onPress: () => void openAttachment?.({ ...item, id: item.id, clientMessageId: item.id, conversationId: state.conversationId, senderId: userId, createdAt: new Date().toISOString(), readAt: null }).catch(() => setError(uiText("This attachment could not be opened."))), style: { width: 76, height: 76, borderRadius: 9, overflow: 'hidden', backgroundColor: c.incoming, borderWidth: 1, borderColor: c.secondary + '40', alignItems: 'center', justifyContent: 'center' }, children: [item.thumbnail ? _jsx(Image, { source: { uri: item.thumbnail }, accessibilityLabel: item.media.fileName ?? uiText(mediaNames[item.kind]), resizeMode: "
|
|
1125
|
+
return selected.length > 0 || voiceReview ? _jsxs(AttachmentStrip, { label: uiText("Pending attachments"), height: selected.some(item => item.kind === 'document') ? 104 : 86, children: [selected.map(item => item.kind === 'voice' && item.media.assetId !== editing?.media?.assetId && components?.VoiceAttachment ? _jsx(components.VoiceAttachment, { media: item.media, appearance: design, disabled: blocked, onRemove: () => removeSelected(item.id) }, item.id) : _jsxs(View, { style: { width: 88, paddingTop: 8, paddingRight: 10 }, children: [_jsxs(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Preview {name}', { name: item.media.fileName ?? uiText(mediaNames[item.kind]) }), disabled: blocked || !openAttachment, onPress: () => void openAttachment?.({ ...item, id: item.id, clientMessageId: item.id, conversationId: state.conversationId, senderId: userId, createdAt: new Date().toISOString(), readAt: null }).catch(() => setError(uiText("This attachment could not be opened."))), style: { width: 76, height: 76, borderRadius: 9, overflow: 'hidden', backgroundColor: c.incoming, borderWidth: 1, borderColor: c.secondary + '40', alignItems: 'center', justifyContent: 'center' }, children: [item.thumbnail ? _jsx(Image, { source: { uri: item.thumbnail }, accessibilityLabel: item.media.fileName ?? uiText(mediaNames[item.kind]), resizeMode: "contain", style: { width: '100%', height: '100%' } }) : _jsx(MessageIcon, { name: item.kind === 'voice' ? 'mic' : item.kind, color: c.accent, size: 28 }), item.kind === 'video' && _jsx(View, { style: { position: 'absolute', bottom: 0, left: 0, right: 0, padding: 4, backgroundColor: '#0009' }, children: _jsx(Text, { style: { color: '#fff', fontSize: 10 }, children: duration(item.media.durationMs) }) })] }), item.kind === 'document' && _jsx(Text, { numberOfLines: 1, style: { fontSize: 10, color: c.foreground, marginTop: 3 }, children: item.media.fileName ?? uiText(mediaNames[item.kind]) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Remove {name}', { name: item.media.fileName ?? uiText(mediaNames[item.kind]) }), disabled: blocked, onPress: () => removeSelected(item.id), style: { position: 'absolute', right: 0, top: 0, width: 30, height: 30, alignItems: 'center', justifyContent: 'center' }, children: _jsx(View, { style: { backgroundColor: c.foreground, borderRadius: 11, padding: 3 }, children: _jsx(MessageIcon, { name: "close", size: 16, color: c.background }) }) })] }, item.id)), voiceReview] }) : null;
|
|
1085
1126
|
}
|
|
1086
1127
|
function renderTextComposer(voice = { hasVoice: false, blocked: false }) {
|
|
1087
1128
|
const blocked = voice.blocked || busy;
|
|
@@ -1117,7 +1158,7 @@ export function MessagingComposer() {
|
|
|
1117
1158
|
return (_jsxs(View, { testID: "messaging-composer", style: { paddingStart: 8, paddingEnd: 0, paddingVertical: 4, gap: 8, backgroundColor: design.composer?.background ?? c.background }, children: [mentionSuggestions.length > 0 && _jsx(ScrollView, { keyboardShouldPersistTaps: "handled", style: { maxHeight: 144 }, children: mentionSuggestions.map(id => _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText('Mention {name}', { name: participants[id].name }), onPress: () => chooseMention(id), style: { minHeight: 44, paddingHorizontal: 12, justifyContent: 'center', borderBottomWidth: .5, borderBottomColor: c.secondary + '30' }, children: _jsxs(Text, { style: { color: c.accent, fontSize: 16 }, children: ["@", participants[id].name] }) }, id)) }), mentionQuery !== undefined && !!mentionError && _jsx(Text, { style: { color: c.secondary, fontSize: 13 }, children: mentionError }), editing && _jsxs(View, { style: { flexDirection: 'row', alignItems: 'center', gap: 8 }, children: [_jsxs(Text, { numberOfLines: 1, style: { flex: 1, color: c.secondary }, children: [uiText("Editing:"), editing.text || editing.media?.fileName] }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel editing"), disabled: busy, onPress: () => setEditing(null), style: { minHeight: 36, justifyContent: 'center' }, children: _jsx(Text, { style: { color: c.accent }, children: uiText("Cancel") }) })] }), !editing && reply && (_jsxs(View, { testID: "composer-quote", style: { flexDirection: "row", gap: 8 }, children: [_jsx(View, { style: { flex: 1 }, children: _jsx(QuotedPreview, { message: reply, ink: c.secondary }) }), _jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: uiText("Cancel quote"), onPress: () => setReply(null), children: _jsx(Text, { style: { color: c.foreground }, children: uiText("Cancel") }) })] })), state.settings?.history?.mode === 'last_two' && _jsx(Text, { style: { color: c.secondary, fontSize: 11, textAlign: 'center' }, children: uiText("Only the latest two messages are kept.") }), editing ? _jsxs(_Fragment, { children: [renderAttachments(), renderTextComposer()] }) : features?.voice ? _jsx(VoiceComposer, { appearance: design, maxSeconds: state.settings?.voice?.maxDurationSeconds ?? 60, busy: busy, onRecord: () => { Keyboard.dismiss(); void pick('voice'); }, renderAttachments: renderAttachments, renderTextComposer: features?.text || selected.length ? renderTextComposer : undefined, actions: _jsx(_Fragment, { children: (camera || library.image || library.video || library.document || !editing && (features?.poll || weatherAllowed)) && _jsx(Pressable, { ref: attachmentButton, accessibilityRole: "button", accessibilityLabel: uiText("Attach"), accessibilityState: { expanded: attachmentsOpen }, disabled: busy, onPress: () => setAttachmentsOpen(!attachmentsOpen), style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: attachmentsOpen ? 'close' : 'plus', color: c.foreground, size: 25 }) }) }) }) : _jsxs(_Fragment, { children: [renderAttachments(), renderTextComposer()] }), attachmentsOpen && _jsx(AttachmentMenu, { anchor: attachmentButton, accent: c.accent, onClose: () => setAttachmentsOpen(false), actions: attachmentActions }), scheduleOpen && _jsx(ScheduleTimePicker, { initial: scheduleAttempt.current?.time, retryAt: scheduleError ? scheduleAttempt.current?.time : undefined, accent: c.accent, busy: busy, error: scheduleError, onSave: time => void schedule(time), onClose: () => setScheduleOpen(false) }), pollOpen && features?.poll && _jsx(PollComposer, { yesNo: state.conversation?.kind !== 'group', appearance: design, onSend: poll => submit({ kind: 'poll', poll }), onCancel: () => setPollOpen(false) }), error && (_jsx(Text, { accessibilityRole: "alert", style: { color: c.foreground }, children: error }))] }));
|
|
1118
1159
|
}
|
|
1119
1160
|
/** Account navigation. Mount in the inbox/app toolbar, never in a contact menu. */
|
|
1120
|
-
export function MessagingAccountMenu({ onNewConversation, onNewGroup, onMaps, onPublicRooms } = {}) {
|
|
1161
|
+
export function MessagingAccountMenu({ inbox, onNewConversation, onNewGroup, onMaps, onPublicRooms } = {}) {
|
|
1121
1162
|
const { text: uiText, locale: uiLocale, number: uiNumber, count: uiCount } = useRobonoLocale();
|
|
1122
1163
|
const { client, design, setSavedOpen, account, companyName } = useMessagingUI();
|
|
1123
1164
|
const [open, setOpen] = useState(false), [accountOpen, setAccountOpen] = useState(false), pending = useRef(null);
|
|
@@ -1143,10 +1184,10 @@ export function MessagingAccountMenu({ onNewConversation, onNewGroup, onMaps, on
|
|
|
1143
1184
|
event.stopPropagation();
|
|
1144
1185
|
setOpen(false);
|
|
1145
1186
|
} }; document.addEventListener('keydown', key, true); return () => document.removeEventListener('keydown', key, true); }, [open]);
|
|
1146
|
-
return _jsxs(_Fragment, { children: [_jsx(Pressable, { ref: button, accessibilityRole: "button", accessibilityLabel: uiText("Messaging menu"), accessibilityState: { expanded: open }, onPress: show, style: { width: 44, height: 44, alignItems: 'center', justifyContent: 'center' }, children: _jsx(MessageIcon, { name: "
|
|
1187
|
+
return _jsxs(_Fragment, { children: [_jsx(Pressable, { ref: button, accessibilityRole: "button", accessibilityLabel: uiText("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 => {
|
|
1147
1188
|
const top = Math.max(8, Math.min(anchor.y - rect.top, rect.height - menuHeight - 8));
|
|
1148
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") })] })] }) })] });
|
|
1149
|
-
} }), accountOpen && _jsx(MessagingAccountScreen, { account: account, companyName: companyName ?? design.name, onClose: () => setAccountOpen(false) })] });
|
|
1190
|
+
} }), accountOpen && _jsx(MessagingAccountScreen, { inbox: inbox, account: account, companyName: companyName ?? design.name, onClose: () => setAccountOpen(false) })] });
|
|
1150
1191
|
}
|
|
1151
1192
|
function MessagingWaitingChanges() {
|
|
1152
1193
|
const messagingPopupColors = useMessagingPopupColors(undefined, 'alerts');
|
|
@@ -1170,3 +1211,4 @@ export function MessagingScreen(props) {
|
|
|
1170
1211
|
return (_jsx(MessagingProvider, { ...props, children: props.renderLayout ? props.renderLayout(_jsx(MessagingConversation, {})) : _jsx(MessagingConversation, {}) }));
|
|
1171
1212
|
}
|
|
1172
1213
|
export { MessagingInbox } from './inbox.js';
|
|
1214
|
+
export { MessagingBackupScreen } from './backup.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
import { ActivityIndicator, View } from 'react-native';
|
|
4
|
+
import { useRobonoLocale } from './localization.js';
|
|
5
|
+
/** Keep brief authorized reads visually quiet; indicate a slow read in place. */
|
|
6
|
+
export function MessagingLoadingMessages({ color }) {
|
|
7
|
+
const { text } = useRobonoLocale(), [visible, setVisible] = useState(false);
|
|
8
|
+
useEffect(() => { const timer = setTimeout(() => setVisible(true), 500); return () => clearTimeout(timer); }, []);
|
|
9
|
+
return visible ? _jsx(View, { testID: "messaging-loading-messages", style: { padding: 16, alignItems: 'center' }, children: _jsx(ActivityIndicator, { accessibilityLabel: text('Loading messages…'), color: color }) }) : null;
|
|
10
|
+
}
|
package/dist/media-access.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { MessagingMessage } from '@robono/messaging';
|
|
2
2
|
export declare const isRemoteMessagingAsset: (id: string) => boolean;
|
|
3
|
+
/** A bounded JPEG can be displayed directly without a second image encode. */
|
|
4
|
+
export declare const isSmallMessagingJpeg: (media: {
|
|
5
|
+
mimeType?: string;
|
|
6
|
+
byteSize?: number;
|
|
7
|
+
} | undefined) => boolean;
|
|
8
|
+
/** Prefer an existing page preview grant; otherwise a small original is already
|
|
9
|
+
* preview-sized and uses the same authenticated download path as opening it. */
|
|
10
|
+
export declare const useSmallOriginalPreview: (message: MessagingMessage) => boolean;
|
|
3
11
|
/** Access belongs to this authorized message object, never a global URL cache.
|
|
4
12
|
* Explicit exports still request fresh authorization. */
|
|
5
13
|
export declare class MessagingMediaAccess {
|
package/dist/media-access.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
export const isRemoteMessagingAsset = (id) => id.startsWith('bridge:') || id.startsWith('robono-r2:');
|
|
1
|
+
export const isRemoteMessagingAsset = (id) => id.startsWith('bridge:') || id.startsWith('robono-r2:') || id.startsWith('robono-source:');
|
|
2
|
+
/** A bounded JPEG can be displayed directly without a second image encode. */
|
|
3
|
+
export const isSmallMessagingJpeg = (media) => media?.mimeType === 'image/jpeg' && Number.isSafeInteger(media.byteSize) && media.byteSize > 0 && media.byteSize <= 131072;
|
|
4
|
+
/** Prefer an existing page preview grant; otherwise a small original is already
|
|
5
|
+
* preview-sized and uses the same authenticated download path as opening it. */
|
|
6
|
+
export const useSmallOriginalPreview = (message) => message.kind === 'image' && !message.deleted && !message.attachmentPreview && isSmallMessagingJpeg(message.media);
|
|
2
7
|
/** Access belongs to this authorized message object, never a global URL cache.
|
|
3
8
|
* Explicit exports still request fresh authorization. */
|
|
4
9
|
export class MessagingMediaAccess {
|
|
@@ -2,3 +2,5 @@ export type MediaReadyStage = 'image-loaded' | 'video-frame' | 'audio-playing' |
|
|
|
2
2
|
export declare const MediaReadiness: import("react").Context<(stage: MediaReadyStage, uri: string) => void>;
|
|
3
3
|
/** Internal recovery channel; URLs are matched in memory, never logged. */
|
|
4
4
|
export declare const StreamRecovery: import("react").Context<(uri: string, positionMs: number, autoPlay: boolean) => void>;
|
|
5
|
+
import type { PlaybackSample } from '@robono/messaging';
|
|
6
|
+
export declare const MediaPlayback: import("react").Context<(uri: string, sample: PlaybackSample | null) => void>;
|
package/dist/media-readiness.js
CHANGED
|
@@ -2,3 +2,4 @@ import { createContext } from 'react';
|
|
|
2
2
|
export const MediaReadiness = createContext(() => { });
|
|
3
3
|
/** Internal recovery channel; URLs are matched in memory, never logged. */
|
|
4
4
|
export const StreamRecovery = createContext(() => { });
|
|
5
|
+
export const MediaPlayback = createContext(() => { });
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MessagingMessage, type MessagingPlaybackEvent, type PlaybackSample } from '@robono/messaging';
|
|
2
|
+
/** Connect the shared players to the owning screen, never draft/translation players. */
|
|
3
|
+
export declare function usePlaybackReporting(options: {
|
|
4
|
+
actorId: string;
|
|
5
|
+
resolve: (uri: string) => MessagingMessage | null;
|
|
6
|
+
emit?: (event: MessagingPlaybackEvent) => void;
|
|
7
|
+
createId: () => string;
|
|
8
|
+
}): (uri: string, sample: PlaybackSample | null) => void;
|