@poolse/react-native 3.10.1 → 3.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -0
- package/README.md +11 -0
- package/dist/index.cjs +293 -150
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1857 -1773
- package/dist/index.d.ts +1857 -1773
- package/dist/index.js +295 -152
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { applySlashCommand, useUser, useRecordingPlayback, silencesOf, silencesFromSegments, activeSegmentIndex, chapterIndexAt, meetingsErrorMessage, skipSilenceTarget, formatClock, PLAYBACK_RATES, speakerName,
|
|
1
|
+
import { applySlashCommand, useUser, usePoolse, useMe, useMembers, rankMentionGroups, mentionGroupMeta, useRecordingPlayback, silencesOf, silencesFromSegments, activeSegmentIndex, chapterIndexAt, meetingsErrorMessage, skipSilenceTarget, formatClock, PLAYBACK_RATES, speakerName, useConversations, useUserPresence, formatCallLogPreview, formatRecordingNoticePreview, formatCallSummaryPreview, useAttachmentUpload, slashQuery, filterSlashCommands, FORMAT_ACTIONS, applyFormat, readDlpError, filterConversations, useConversation, usePresence, receiptsOf, useMessages, useTyping, useMessageStreams, useRealtimeStatus, isMessageVisibleTo, computeGroupPosition, canEditOwnMessage, isTombstone, formatDayLabel, useCustomEmoji, customEmojiToken, searchCustomEmoji, useOptionalPoolse, recordingNoticeDisplayFor, callLogDisplayFor, parseCallSummary, useLiveCall, sameDay, useReactions, messageAgent, clipOf, citationsOf, approvalIdOf, useThreadFollow, useThread, findCustomEmoji, useCallSummary, summaryStyleLabel, summaryStatusText, formatDue, momentOf, useAttachmentUrl, useClip, useRecordingUrl, formatTimeRange, citationLabel, useApproval, useAgent, approvalStatusLabel, APPROVAL_REASON_MAX, approvalErrorMessage, useAskMeetings, ASK_QUESTION_MAX, captureLabel, useApprovals, useLiveTranscript, groupTranscript, formatCallDuration, useTranscript, findInText, ApiError, captureErrorMessage, callAgentStateOf, callAgentStateLabel, callAgentModeLabel, whisperHintKindLabel, whisperErrorMessage, escalationStatusLabel, ESCALATION_ANSWER_MAX, escalationErrorMessage, useEscalations, useBreakouts, waveformBars, playbackRateLabel, nextPlaybackRate } from '@poolse/react';
|
|
2
2
|
import { createContext, forwardRef, useRef, useState, useImperativeHandle, useEffect, useMemo, useCallback, useContext, createElement } from 'react';
|
|
3
|
-
import { StyleSheet, View, Pressable, TextInput, Text,
|
|
3
|
+
import { StyleSheet, View, Pressable, TextInput, Text, ScrollView, Switch, useWindowDimensions, Animated, Easing, PanResponder, Keyboard, Platform, Modal, Image, AppState, ActivityIndicator, SectionList, FlatList, KeyboardAvoidingView, Alert, AccessibilityInfo, Linking, useColorScheme } from 'react-native';
|
|
4
4
|
import { toNativeTheme, isBuiltInThemeId } from '@poolse/theme';
|
|
5
5
|
export { BUILT_IN_THEME_IDS, DEFAULT_THEME_ID, createTheme, decodeTheme, encodeTheme, tokensFromFlat } from '@poolse/theme';
|
|
6
6
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -825,6 +825,7 @@ function Avatar({
|
|
|
825
825
|
const theme = useTheme();
|
|
826
826
|
const dim = SIZES[size];
|
|
827
827
|
const initials = computeInitials(name);
|
|
828
|
+
const [failedSrc, setFailedSrc] = useState(null);
|
|
828
829
|
const tint = seed ? userColor(seed) : theme.colors.accent;
|
|
829
830
|
const fontSize = size === "xs" ? 9 : size === "sm" ? 11 : size === "lg" ? 22 : 15;
|
|
830
831
|
const badgeSize = Math.max(8, Math.round(dim * 0.32));
|
|
@@ -846,10 +847,11 @@ function Avatar({
|
|
|
846
847
|
accessibilityRole: "image",
|
|
847
848
|
accessibilityLabel: agent ? `${name ?? "Agent"} (agent)` : name ?? "avatar",
|
|
848
849
|
children: [
|
|
849
|
-
src ? /* @__PURE__ */ jsx(
|
|
850
|
+
src && failedSrc !== src ? /* @__PURE__ */ jsx(
|
|
850
851
|
Image,
|
|
851
852
|
{
|
|
852
853
|
source: { uri: src },
|
|
854
|
+
onError: () => setFailedSrc(src),
|
|
853
855
|
style: { width: dim, height: dim, borderRadius: radius },
|
|
854
856
|
accessible: false
|
|
855
857
|
}
|
|
@@ -879,7 +881,7 @@ function Avatar({
|
|
|
879
881
|
]
|
|
880
882
|
}
|
|
881
883
|
) : null,
|
|
882
|
-
lookupId ? /* @__PURE__ */ jsx(
|
|
884
|
+
lookupId ? /* @__PURE__ */ jsx(OptionalLivePresenceBadge, { id: lookupId, size: badgeSize, style: badgeStyle }) : presence && presence !== true ? /* @__PURE__ */ jsx(
|
|
883
885
|
PresenceBadge,
|
|
884
886
|
{
|
|
885
887
|
state: presence,
|
|
@@ -906,6 +908,9 @@ function Avatar({
|
|
|
906
908
|
}
|
|
907
909
|
);
|
|
908
910
|
}
|
|
911
|
+
function OptionalLivePresenceBadge(props) {
|
|
912
|
+
return useOptionalPoolse() ? /* @__PURE__ */ jsx(LivePresenceBadge, { ...props }) : null;
|
|
913
|
+
}
|
|
909
914
|
function LivePresenceBadge({
|
|
910
915
|
id,
|
|
911
916
|
size,
|
|
@@ -3227,7 +3232,9 @@ var MessageComposer = forwardRef(
|
|
|
3227
3232
|
emojiPicker = true,
|
|
3228
3233
|
accessory,
|
|
3229
3234
|
formattingToolbar = false,
|
|
3230
|
-
commands
|
|
3235
|
+
commands,
|
|
3236
|
+
onMic,
|
|
3237
|
+
recordingBar
|
|
3231
3238
|
}, ref) {
|
|
3232
3239
|
const theme = useTheme();
|
|
3233
3240
|
const inputRef = useRef(null);
|
|
@@ -3269,6 +3276,17 @@ var MessageComposer = forwardRef(
|
|
|
3269
3276
|
if (!controlled) setInnerValue("");
|
|
3270
3277
|
onChangeTextRef.current?.("");
|
|
3271
3278
|
},
|
|
3279
|
+
getText: () => valueRef.current,
|
|
3280
|
+
setText: (text) => setValueRef.current(text),
|
|
3281
|
+
insertText: (text) => {
|
|
3282
|
+
const now = valueRef.current;
|
|
3283
|
+
const sel = selectionRef.current ?? { start: now.length, end: now.length };
|
|
3284
|
+
const caret = sel.start + text.length;
|
|
3285
|
+
applyTextRef.current(now.slice(0, sel.start) + text + now.slice(sel.end), {
|
|
3286
|
+
start: caret,
|
|
3287
|
+
end: caret
|
|
3288
|
+
});
|
|
3289
|
+
},
|
|
3272
3290
|
setSelection: (start, end) => {
|
|
3273
3291
|
selectionRef.current = { start, end };
|
|
3274
3292
|
inputRef.current?.setSelection?.(start, end);
|
|
@@ -3303,14 +3321,19 @@ var MessageComposer = forwardRef(
|
|
|
3303
3321
|
const replyId = replyingTo?.id;
|
|
3304
3322
|
const attachmentIds = readyAttachmentIds;
|
|
3305
3323
|
setDraft("");
|
|
3306
|
-
upload.reset();
|
|
3307
3324
|
const opts = {
|
|
3308
3325
|
...replyId ? { quoted_message_id: replyId } : {},
|
|
3309
3326
|
...attachmentIds.length > 0 ? { attachment_ids: attachmentIds } : {}
|
|
3310
3327
|
};
|
|
3311
3328
|
try {
|
|
3312
|
-
await onSend(body, opts)
|
|
3329
|
+
if (await onSend(body, opts) === false) {
|
|
3330
|
+
if (!controlled) setInnerValue((now) => now ? now : body);
|
|
3331
|
+
else onChangeTextRef.current?.(body);
|
|
3332
|
+
return;
|
|
3333
|
+
}
|
|
3334
|
+
upload.reset();
|
|
3313
3335
|
} catch (err) {
|
|
3336
|
+
upload.reset();
|
|
3314
3337
|
const outcome = readDlpError(err);
|
|
3315
3338
|
if (outcome) setDlp({ outcome, body, opts });
|
|
3316
3339
|
if (!controlled) setInnerValue((now) => now ? now : body);
|
|
@@ -3331,6 +3354,12 @@ var MessageComposer = forwardRef(
|
|
|
3331
3354
|
setCursor(sel.end);
|
|
3332
3355
|
setTimeout(() => inputRef.current?.setSelection?.(sel.start, sel.end), 0);
|
|
3333
3356
|
};
|
|
3357
|
+
const valueRef = useRef(value);
|
|
3358
|
+
valueRef.current = value;
|
|
3359
|
+
const setValueRef = useRef(setValue);
|
|
3360
|
+
setValueRef.current = setValue;
|
|
3361
|
+
const applyTextRef = useRef(applyText);
|
|
3362
|
+
applyTextRef.current = applyText;
|
|
3334
3363
|
const format2 = (kind) => {
|
|
3335
3364
|
const sel = selectionRef.current ?? { start: value.length, end: value.length };
|
|
3336
3365
|
const r = applyFormat(value, sel, kind);
|
|
@@ -3400,7 +3429,7 @@ var MessageComposer = forwardRef(
|
|
|
3400
3429
|
...Array.isArray(formattingToolbar) ? { actions: formattingToolbar } : {}
|
|
3401
3430
|
}
|
|
3402
3431
|
) : null,
|
|
3403
|
-
/* @__PURE__ */ jsxs(View, { style: styles15.row, children: [
|
|
3432
|
+
recordingBar ? recordingBar : /* @__PURE__ */ jsxs(View, { style: styles15.row, children: [
|
|
3404
3433
|
attachments && onAttachPress ? /* @__PURE__ */ jsx(
|
|
3405
3434
|
Pressable,
|
|
3406
3435
|
{
|
|
@@ -3454,7 +3483,18 @@ var MessageComposer = forwardRef(
|
|
|
3454
3483
|
]
|
|
3455
3484
|
}
|
|
3456
3485
|
),
|
|
3457
|
-
/* @__PURE__ */ jsx(
|
|
3486
|
+
onMic && !isEditing && value.trim().length === 0 && readyAttachmentIds.length === 0 && !isUploading ? /* @__PURE__ */ jsx(
|
|
3487
|
+
Pressable,
|
|
3488
|
+
{
|
|
3489
|
+
onPress: onMic,
|
|
3490
|
+
disabled,
|
|
3491
|
+
hitSlop: 8,
|
|
3492
|
+
style: [styles15.sendBtn, { backgroundColor: theme.colors.accent }],
|
|
3493
|
+
accessibilityRole: "button",
|
|
3494
|
+
accessibilityLabel: "Record a voice message",
|
|
3495
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "mic", size: 18, color: theme.colors.accentText, label: null })
|
|
3496
|
+
}
|
|
3497
|
+
) : /* @__PURE__ */ jsx(
|
|
3458
3498
|
Pressable,
|
|
3459
3499
|
{
|
|
3460
3500
|
onPress: handleSend,
|
|
@@ -3619,129 +3659,146 @@ var styles15 = StyleSheet.create({
|
|
|
3619
3659
|
padding: 6
|
|
3620
3660
|
}
|
|
3621
3661
|
});
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
const
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
onPress: () => pick(c)
|
|
3706
|
-
},
|
|
3707
|
-
c.member.user_id
|
|
3708
|
-
)),
|
|
3709
|
-
groupMatches.map((g) => /* @__PURE__ */ jsx(GroupRow, { group: g, onPress: () => pickGroup(g) }, `group:${g.handle}`))
|
|
3710
|
-
] }),
|
|
3711
|
-
/* @__PURE__ */ jsx(
|
|
3712
|
-
Pressable,
|
|
3662
|
+
var MentionInput = forwardRef(
|
|
3663
|
+
function MentionInput2({
|
|
3664
|
+
conversationId,
|
|
3665
|
+
onSend,
|
|
3666
|
+
maxSuggestions = 6,
|
|
3667
|
+
labelFor,
|
|
3668
|
+
value: valueProp,
|
|
3669
|
+
onChangeText,
|
|
3670
|
+
onSelectionChange,
|
|
3671
|
+
groups,
|
|
3672
|
+
...composerProps
|
|
3673
|
+
}, ref) {
|
|
3674
|
+
const theme = useTheme();
|
|
3675
|
+
const chat = usePoolse();
|
|
3676
|
+
const { me } = useMe();
|
|
3677
|
+
const { members } = useMembers(conversationId);
|
|
3678
|
+
const composerRef = useRef(null);
|
|
3679
|
+
useImperativeHandle(
|
|
3680
|
+
ref,
|
|
3681
|
+
() => ({
|
|
3682
|
+
addFiles: (inputs) => composerRef.current?.addFiles(inputs),
|
|
3683
|
+
focus: () => composerRef.current?.focus(),
|
|
3684
|
+
clear: () => composerRef.current?.clear(),
|
|
3685
|
+
getText: () => composerRef.current?.getText() ?? "",
|
|
3686
|
+
setText: (t) => composerRef.current?.setText(t),
|
|
3687
|
+
insertText: (t) => composerRef.current?.insertText(t),
|
|
3688
|
+
setSelection: (start, end) => composerRef.current?.setSelection(start, end)
|
|
3689
|
+
}),
|
|
3690
|
+
[]
|
|
3691
|
+
);
|
|
3692
|
+
const [innerText, setInnerText] = useState("");
|
|
3693
|
+
const text = valueProp ?? innerText;
|
|
3694
|
+
const [cursor, setCursor] = useState(0);
|
|
3695
|
+
const [dismissedAt, setDismissedAt] = useState(null);
|
|
3696
|
+
const pickedRef = useRef([]);
|
|
3697
|
+
const setText = (next) => {
|
|
3698
|
+
if (valueProp === void 0) setInnerText(next);
|
|
3699
|
+
onChangeText?.(next);
|
|
3700
|
+
};
|
|
3701
|
+
const query = useMemo(() => {
|
|
3702
|
+
const q = activeMentionQuery(text, cursor);
|
|
3703
|
+
return q && q.start !== dismissedAt ? q : null;
|
|
3704
|
+
}, [text, cursor, dismissedAt]);
|
|
3705
|
+
const candidates = useMemo(() => {
|
|
3706
|
+
if (!query) return [];
|
|
3707
|
+
const all = members.filter((m) => m.user_id !== me?.id).map((m) => ({
|
|
3708
|
+
member: m,
|
|
3709
|
+
externalId: m.external_id,
|
|
3710
|
+
label: labelFor?.(m.external_id) ?? chat.users.peek(m.external_id)?.displayName ?? m.external_id
|
|
3711
|
+
}));
|
|
3712
|
+
return filterMentionCandidates(all, query.query, maxSuggestions);
|
|
3713
|
+
}, [query, members, me?.id, labelFor, chat, maxSuggestions]);
|
|
3714
|
+
const groupMatches = useMemo(
|
|
3715
|
+
() => query && groups ? rankMentionGroups(groups, query.query, Math.max(0, maxSuggestions - candidates.length)) : [],
|
|
3716
|
+
[query, groups, maxSuggestions, candidates.length]
|
|
3717
|
+
);
|
|
3718
|
+
const pickGroup = (g) => {
|
|
3719
|
+
if (!query) return;
|
|
3720
|
+
const next = insertMention(text, query.start, cursor, g.handle);
|
|
3721
|
+
setText(next.text);
|
|
3722
|
+
setCursor(next.cursor);
|
|
3723
|
+
setTimeout(() => composerRef.current?.setSelection(next.cursor, next.cursor), 0);
|
|
3724
|
+
};
|
|
3725
|
+
const pick = (c) => {
|
|
3726
|
+
if (!query) return;
|
|
3727
|
+
const next = insertMention(text, query.start, cursor, c.label);
|
|
3728
|
+
pickedRef.current = [...pickedRef.current, { userId: c.member.user_id, label: c.label }];
|
|
3729
|
+
setText(next.text);
|
|
3730
|
+
setCursor(next.cursor);
|
|
3731
|
+
setTimeout(() => composerRef.current?.setSelection(next.cursor, next.cursor), 0);
|
|
3732
|
+
};
|
|
3733
|
+
const handleSend = async (body, opts) => {
|
|
3734
|
+
const mentions = mentionedUserIds(body, pickedRef.current);
|
|
3735
|
+
const result = await onSend(body, { ...opts, ...mentions.length > 0 ? { mentions } : {} });
|
|
3736
|
+
if (result === false) return false;
|
|
3737
|
+
pickedRef.current = [];
|
|
3738
|
+
return void 0;
|
|
3739
|
+
};
|
|
3740
|
+
const suggestions = query && candidates.length + groupMatches.length > 0 ? /* @__PURE__ */ jsxs(
|
|
3741
|
+
View,
|
|
3742
|
+
{
|
|
3743
|
+
style: [
|
|
3744
|
+
styles16.suggestions,
|
|
3713
3745
|
{
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
}
|
|
3746
|
+
backgroundColor: theme.colors.surface,
|
|
3747
|
+
borderColor: theme.colors.border,
|
|
3748
|
+
borderRadius: theme.radii.md
|
|
3749
|
+
},
|
|
3750
|
+
theme.shadows.md
|
|
3751
|
+
],
|
|
3752
|
+
accessibilityRole: "menu",
|
|
3753
|
+
accessibilityLabel: "Mention suggestions",
|
|
3754
|
+
children: [
|
|
3755
|
+
/* @__PURE__ */ jsxs(ScrollView, { keyboardShouldPersistTaps: "always", style: styles16.suggestionScroll, children: [
|
|
3756
|
+
candidates.map((c) => /* @__PURE__ */ jsx(
|
|
3757
|
+
MentionRow,
|
|
3758
|
+
{
|
|
3759
|
+
externalId: c.externalId,
|
|
3760
|
+
label: c.label,
|
|
3761
|
+
onPress: () => pick(c)
|
|
3762
|
+
},
|
|
3763
|
+
c.member.user_id
|
|
3764
|
+
)),
|
|
3765
|
+
groupMatches.map((g) => /* @__PURE__ */ jsx(GroupRow, { group: g, onPress: () => pickGroup(g) }, `group:${g.handle}`))
|
|
3766
|
+
] }),
|
|
3767
|
+
/* @__PURE__ */ jsx(
|
|
3768
|
+
Pressable,
|
|
3769
|
+
{
|
|
3770
|
+
onPress: () => setDismissedAt(query.start),
|
|
3771
|
+
style: styles16.dismiss,
|
|
3772
|
+
accessibilityRole: "button",
|
|
3773
|
+
accessibilityLabel: "Dismiss suggestions",
|
|
3774
|
+
hitSlop: 6,
|
|
3775
|
+
children: /* @__PURE__ */ jsx(PoolseIcon, { name: "close", size: 14, color: theme.colors.textSubtle, label: null })
|
|
3776
|
+
}
|
|
3777
|
+
)
|
|
3778
|
+
]
|
|
3779
|
+
}
|
|
3780
|
+
) : null;
|
|
3781
|
+
return /* @__PURE__ */ jsx(
|
|
3782
|
+
MessageComposer,
|
|
3783
|
+
{
|
|
3784
|
+
ref: composerRef,
|
|
3785
|
+
...composerProps,
|
|
3786
|
+
...labelFor ? { labelFor } : {},
|
|
3787
|
+
value: text,
|
|
3788
|
+
onChangeText: (next) => {
|
|
3789
|
+
setText(next);
|
|
3790
|
+
if (dismissedAt !== null && !next.includes("@", dismissedAt)) setDismissedAt(null);
|
|
3791
|
+
},
|
|
3792
|
+
onSelectionChange: (sel) => {
|
|
3793
|
+
setCursor(sel.end);
|
|
3794
|
+
onSelectionChange?.(sel);
|
|
3795
|
+
},
|
|
3796
|
+
onSend: handleSend,
|
|
3797
|
+
accessory: suggestions
|
|
3798
|
+
}
|
|
3799
|
+
);
|
|
3800
|
+
}
|
|
3801
|
+
);
|
|
3745
3802
|
function MentionRow({
|
|
3746
3803
|
externalId,
|
|
3747
3804
|
label,
|
|
@@ -3858,6 +3915,23 @@ var styles16 = StyleSheet.create({
|
|
|
3858
3915
|
right: 8
|
|
3859
3916
|
}
|
|
3860
3917
|
});
|
|
3918
|
+
var alertConfirmDelete = () => new Promise((resolve) => {
|
|
3919
|
+
Alert.alert(
|
|
3920
|
+
"Delete message?",
|
|
3921
|
+
"It will be deleted for everyone.",
|
|
3922
|
+
[
|
|
3923
|
+
{ text: "Cancel", style: "cancel", onPress: () => resolve(false) },
|
|
3924
|
+
{ text: "Delete", style: "destructive", onPress: () => resolve(true) }
|
|
3925
|
+
],
|
|
3926
|
+
{ cancelable: true, onDismiss: () => resolve(false) }
|
|
3927
|
+
);
|
|
3928
|
+
});
|
|
3929
|
+
|
|
3930
|
+
// src/internal/confirmDelete.ts
|
|
3931
|
+
async function confirmThenDelete(msg, confirm, remove) {
|
|
3932
|
+
if (!await confirm(msg)) return;
|
|
3933
|
+
await remove(msg.id).catch(() => void 0);
|
|
3934
|
+
}
|
|
3861
3935
|
|
|
3862
3936
|
// src/internal/messageFocus.ts
|
|
3863
3937
|
function latestMarkableId(messages) {
|
|
@@ -7286,6 +7360,7 @@ function FlatMessageRow({
|
|
|
7286
7360
|
isEditing = false,
|
|
7287
7361
|
onStartEdit,
|
|
7288
7362
|
onDelete,
|
|
7363
|
+
extraActions,
|
|
7289
7364
|
onOpenThread,
|
|
7290
7365
|
onQuote,
|
|
7291
7366
|
labelFor,
|
|
@@ -7547,7 +7622,8 @@ function FlatMessageRow({
|
|
|
7547
7622
|
onQuote,
|
|
7548
7623
|
onMarkUnread,
|
|
7549
7624
|
onRemoveLinkPreview,
|
|
7550
|
-
linkPreviews
|
|
7625
|
+
linkPreviews,
|
|
7626
|
+
extraActions
|
|
7551
7627
|
}
|
|
7552
7628
|
) : null;
|
|
7553
7629
|
return /* @__PURE__ */ jsxs(
|
|
@@ -7724,7 +7800,8 @@ function MessageActions({
|
|
|
7724
7800
|
pinned = false,
|
|
7725
7801
|
onForward,
|
|
7726
7802
|
onTranslate,
|
|
7727
|
-
translated = false
|
|
7803
|
+
translated = false,
|
|
7804
|
+
extraActions = []
|
|
7728
7805
|
}) {
|
|
7729
7806
|
const theme = useTheme();
|
|
7730
7807
|
const insets = useSafeInsets();
|
|
@@ -7754,6 +7831,14 @@ function MessageActions({
|
|
|
7754
7831
|
});
|
|
7755
7832
|
}
|
|
7756
7833
|
}
|
|
7834
|
+
for (const a of extraActions) {
|
|
7835
|
+
items.push({
|
|
7836
|
+
label: a.label,
|
|
7837
|
+
icon: a.icon ?? "more-h",
|
|
7838
|
+
onPress: a.onPress,
|
|
7839
|
+
...a.danger ? { danger: true } : {}
|
|
7840
|
+
});
|
|
7841
|
+
}
|
|
7757
7842
|
if (isSelf && onEdit) items.push({ label: "Edit", icon: "edit", onPress: onEdit });
|
|
7758
7843
|
if (isSelf && onDelete)
|
|
7759
7844
|
items.push({ label: "Delete", icon: "trash", onPress: onDelete, danger: true });
|
|
@@ -7913,7 +7998,8 @@ function RowActionsSheet({
|
|
|
7913
7998
|
onQuote,
|
|
7914
7999
|
onMarkUnread,
|
|
7915
8000
|
onRemoveLinkPreview,
|
|
7916
|
-
linkPreviews
|
|
8001
|
+
linkPreviews,
|
|
8002
|
+
extraActions
|
|
7917
8003
|
}) {
|
|
7918
8004
|
const then = (fn) => () => {
|
|
7919
8005
|
close();
|
|
@@ -7933,6 +8019,7 @@ function RowActionsSheet({
|
|
|
7933
8019
|
...threads && onOpenThread ? { onReplyInThread: then(onOpenThread) } : {},
|
|
7934
8020
|
...quotations && onQuote ? { onQuote: then(onQuote) } : {},
|
|
7935
8021
|
...onMarkUnread ? { onMarkUnread: then(onMarkUnread) } : {},
|
|
8022
|
+
...extraActions && extraActions.length > 0 ? { extraActions: extraActions.map((a) => ({ ...a, onPress: then(a.onPress) })) } : {},
|
|
7936
8023
|
...onRemoveLinkPreview && previewUrls.length > 0 ? {
|
|
7937
8024
|
previewUrls,
|
|
7938
8025
|
onRemovePreview: (url) => {
|
|
@@ -8034,7 +8121,8 @@ function BubbleMessageRow({
|
|
|
8034
8121
|
onMarkUnread,
|
|
8035
8122
|
editHistory = true,
|
|
8036
8123
|
onRetrySend,
|
|
8037
|
-
onDiscardSend
|
|
8124
|
+
onDiscardSend,
|
|
8125
|
+
extraActions
|
|
8038
8126
|
}) {
|
|
8039
8127
|
const theme = useTheme();
|
|
8040
8128
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
@@ -8291,7 +8379,8 @@ function BubbleMessageRow({
|
|
|
8291
8379
|
onQuote,
|
|
8292
8380
|
onMarkUnread,
|
|
8293
8381
|
onRemoveLinkPreview,
|
|
8294
|
-
linkPreviews
|
|
8382
|
+
linkPreviews,
|
|
8383
|
+
extraActions
|
|
8295
8384
|
}
|
|
8296
8385
|
) : null
|
|
8297
8386
|
),
|
|
@@ -8417,7 +8506,8 @@ function ThreadView({
|
|
|
8417
8506
|
showPresence = false,
|
|
8418
8507
|
linkPreviews = true,
|
|
8419
8508
|
follow = true,
|
|
8420
|
-
alsoSendToChannel = true
|
|
8509
|
+
alsoSendToChannel = true,
|
|
8510
|
+
...hooks
|
|
8421
8511
|
}) {
|
|
8422
8512
|
return /* @__PURE__ */ jsx(
|
|
8423
8513
|
Modal,
|
|
@@ -8441,7 +8531,8 @@ function ThreadView({
|
|
|
8441
8531
|
showPresence,
|
|
8442
8532
|
linkPreviews,
|
|
8443
8533
|
follow,
|
|
8444
|
-
alsoSendToChannel
|
|
8534
|
+
alsoSendToChannel,
|
|
8535
|
+
hooks
|
|
8445
8536
|
}
|
|
8446
8537
|
) })
|
|
8447
8538
|
}
|
|
@@ -8459,7 +8550,8 @@ function ThreadSheet({
|
|
|
8459
8550
|
showPresence,
|
|
8460
8551
|
linkPreviews,
|
|
8461
8552
|
follow,
|
|
8462
|
-
alsoSendToChannel
|
|
8553
|
+
alsoSendToChannel,
|
|
8554
|
+
hooks
|
|
8463
8555
|
}) {
|
|
8464
8556
|
const theme = useTheme();
|
|
8465
8557
|
const followState = useThreadFollow(follow ? rootMessage.id : null);
|
|
@@ -8503,9 +8595,8 @@ function ThreadSheet({
|
|
|
8503
8595
|
quotations: false,
|
|
8504
8596
|
isEditing: editingId === msg.id,
|
|
8505
8597
|
...canEdit ? { onStartEdit: () => setEditingId(msg.id) } : {},
|
|
8506
|
-
onDelete: () =>
|
|
8507
|
-
|
|
8508
|
-
},
|
|
8598
|
+
onDelete: () => void confirmThenDelete(msg, hooks.confirmDelete ?? alertConfirmDelete, deleteReply),
|
|
8599
|
+
...hooks.extraActions ? { extraActions: hooks.extraActions(msg) } : {},
|
|
8509
8600
|
...labelFor ? { labelFor } : {},
|
|
8510
8601
|
...avatarFor ? { avatarFor } : {},
|
|
8511
8602
|
...layout ? { layout } : {},
|
|
@@ -8523,6 +8614,7 @@ function ThreadSheet({
|
|
|
8523
8614
|
meId,
|
|
8524
8615
|
editingId,
|
|
8525
8616
|
deleteReply,
|
|
8617
|
+
hooks,
|
|
8526
8618
|
labelFor,
|
|
8527
8619
|
avatarFor,
|
|
8528
8620
|
layout,
|
|
@@ -8668,20 +8760,30 @@ function ThreadSheet({
|
|
|
8668
8760
|
}
|
|
8669
8761
|
)
|
|
8670
8762
|
] }) : null,
|
|
8763
|
+
hooks.composerAccessory,
|
|
8671
8764
|
/* @__PURE__ */ jsx(
|
|
8672
8765
|
MessageComposer,
|
|
8673
8766
|
{
|
|
8767
|
+
ref: hooks.composerHandle ?? null,
|
|
8674
8768
|
onSend: async (body, opts) => {
|
|
8675
|
-
|
|
8769
|
+
let draft = {
|
|
8676
8770
|
body,
|
|
8677
8771
|
...opts,
|
|
8678
8772
|
...alsoSendToChannel && alsoToChannel ? { also_send_to_channel: true } : {}
|
|
8679
|
-
}
|
|
8773
|
+
};
|
|
8774
|
+
if (hooks.beforeSend) {
|
|
8775
|
+
const changed = await hooks.beforeSend(draft);
|
|
8776
|
+
if (changed === false) return false;
|
|
8777
|
+
draft = changed;
|
|
8778
|
+
}
|
|
8779
|
+
await sendReply(draft);
|
|
8680
8780
|
setAlsoToChannel(false);
|
|
8781
|
+
return void 0;
|
|
8681
8782
|
},
|
|
8682
8783
|
placeholder: "Reply to thread\u2026",
|
|
8683
8784
|
attachments: true,
|
|
8684
8785
|
onAttachPress: () => setPickerOpen(true),
|
|
8786
|
+
...hooks.composerProps,
|
|
8685
8787
|
editingMessage,
|
|
8686
8788
|
onCancelEdit: () => setEditingId(null),
|
|
8687
8789
|
onSaveEdit: async (body) => {
|
|
@@ -9102,7 +9204,13 @@ function ConversationView({
|
|
|
9102
9204
|
maxFileSize,
|
|
9103
9205
|
acceptedFileTypes,
|
|
9104
9206
|
markUnread = true,
|
|
9105
|
-
onMarkedUnread
|
|
9207
|
+
onMarkedUnread,
|
|
9208
|
+
composerProps: appComposerProps,
|
|
9209
|
+
composerAccessory,
|
|
9210
|
+
composerHandle,
|
|
9211
|
+
beforeSend,
|
|
9212
|
+
extraActions,
|
|
9213
|
+
confirmDelete = alertConfirmDelete
|
|
9106
9214
|
}) {
|
|
9107
9215
|
const theme = useTheme();
|
|
9108
9216
|
const chat = usePoolse();
|
|
@@ -9178,6 +9286,20 @@ function ConversationView({
|
|
|
9178
9286
|
);
|
|
9179
9287
|
const [draftFor, setDraftFor] = useState(conversationId);
|
|
9180
9288
|
const [draftText, setDraftText] = useState(() => drafts.peek(conversationId)?.text ?? "");
|
|
9289
|
+
const composerRef = useRef(null);
|
|
9290
|
+
useImperativeHandle(
|
|
9291
|
+
composerHandle,
|
|
9292
|
+
() => ({
|
|
9293
|
+
addFiles: (inputs) => composerRef.current?.addFiles(inputs),
|
|
9294
|
+
focus: () => composerRef.current?.focus(),
|
|
9295
|
+
clear: () => composerRef.current?.clear(),
|
|
9296
|
+
getText: () => composerRef.current?.getText() ?? "",
|
|
9297
|
+
setText: (t) => composerRef.current?.setText(t),
|
|
9298
|
+
insertText: (t) => composerRef.current?.insertText(t),
|
|
9299
|
+
setSelection: (start, end) => composerRef.current?.setSelection(start, end)
|
|
9300
|
+
}),
|
|
9301
|
+
[]
|
|
9302
|
+
);
|
|
9181
9303
|
const [replyingTo, setReplyingTo] = useState(
|
|
9182
9304
|
() => drafts.peek(conversationId)?.quote ?? null
|
|
9183
9305
|
);
|
|
@@ -9440,7 +9562,8 @@ function ConversationView({
|
|
|
9440
9562
|
...readState ? { readState } : {},
|
|
9441
9563
|
isEditing: editingId === msg.id,
|
|
9442
9564
|
...canEdit ? { onStartEdit: () => setEditingId(msg.id) } : {},
|
|
9443
|
-
onDelete: () =>
|
|
9565
|
+
onDelete: () => void confirmThenDelete(msg, confirmDelete, deleteMsg),
|
|
9566
|
+
...extraActions ? { extraActions: extraActions(msg) } : {},
|
|
9444
9567
|
...threads ? { onOpenThread: () => setThreadRoot(msg) } : {},
|
|
9445
9568
|
...canQuote && !tombstone ? { onQuote: () => setReplyingTo(msg) } : {},
|
|
9446
9569
|
onQuotedClick,
|
|
@@ -9482,6 +9605,8 @@ function ConversationView({
|
|
|
9482
9605
|
threads,
|
|
9483
9606
|
editingId,
|
|
9484
9607
|
deleteMsg,
|
|
9608
|
+
confirmDelete,
|
|
9609
|
+
extraActions,
|
|
9485
9610
|
labelFor,
|
|
9486
9611
|
avatarFor,
|
|
9487
9612
|
showSenderLabels,
|
|
@@ -9541,9 +9666,15 @@ function ConversationView({
|
|
|
9541
9666
|
const composerProps = useMemo(
|
|
9542
9667
|
() => ({
|
|
9543
9668
|
onSend: async (body, opts) => {
|
|
9544
|
-
|
|
9669
|
+
let draft = { body, ...opts };
|
|
9670
|
+
if (beforeSend) {
|
|
9671
|
+
const changed = await beforeSend(draft);
|
|
9672
|
+
if (changed === false) return false;
|
|
9673
|
+
draft = changed;
|
|
9674
|
+
}
|
|
9675
|
+
const id = draft.id ?? safeUuid();
|
|
9545
9676
|
try {
|
|
9546
|
-
await send({
|
|
9677
|
+
await send({ ...draft, id });
|
|
9547
9678
|
} catch (err) {
|
|
9548
9679
|
const kept = err instanceof MessageQueuedError || chat.outboxEnabled && !isQuoteGone(err);
|
|
9549
9680
|
if (kept) {
|
|
@@ -9560,6 +9691,7 @@ function ConversationView({
|
|
|
9560
9691
|
setReplyingTo(null);
|
|
9561
9692
|
setAutoReadPaused(false);
|
|
9562
9693
|
onSent?.(conversationId);
|
|
9694
|
+
return void 0;
|
|
9563
9695
|
},
|
|
9564
9696
|
value: draftText,
|
|
9565
9697
|
onChangeText: (text) => {
|
|
@@ -9567,7 +9699,11 @@ function ConversationView({
|
|
|
9567
9699
|
setDraftText(text);
|
|
9568
9700
|
},
|
|
9569
9701
|
emojiPicker,
|
|
9570
|
-
|
|
9702
|
+
...appComposerProps,
|
|
9703
|
+
onTyping: () => {
|
|
9704
|
+
signalTyping();
|
|
9705
|
+
appComposerProps?.onTyping?.();
|
|
9706
|
+
},
|
|
9571
9707
|
...attachments ? { onAttachPress: () => setPickerOpen(true) } : {},
|
|
9572
9708
|
...replyingTo ? { replyingTo } : {},
|
|
9573
9709
|
onCancelReply: () => setReplyingTo(null),
|
|
@@ -9597,7 +9733,9 @@ function ConversationView({
|
|
|
9597
9733
|
editingId,
|
|
9598
9734
|
edit,
|
|
9599
9735
|
draftText,
|
|
9600
|
-
emojiPicker
|
|
9736
|
+
emojiPicker,
|
|
9737
|
+
beforeSend,
|
|
9738
|
+
appComposerProps
|
|
9601
9739
|
]
|
|
9602
9740
|
);
|
|
9603
9741
|
const headerNode = header === false ? null : header === true ? /* @__PURE__ */ jsx(
|
|
@@ -9737,7 +9875,8 @@ function ConversationView({
|
|
|
9737
9875
|
}
|
|
9738
9876
|
) : null
|
|
9739
9877
|
] }),
|
|
9740
|
-
|
|
9878
|
+
showComposer ? composerAccessory : null,
|
|
9879
|
+
!showComposer ? null : mentions ? /* @__PURE__ */ jsx(MentionInput, { ref: composerRef, conversationId, ...composerProps }) : /* @__PURE__ */ jsx(MessageComposer, { ref: composerRef, ...composerProps }),
|
|
9741
9880
|
canAttach ? /* @__PURE__ */ jsx(
|
|
9742
9881
|
AttachmentPicker,
|
|
9743
9882
|
{
|
|
@@ -9761,7 +9900,11 @@ function ConversationView({
|
|
|
9761
9900
|
...timeFormat ? { timeFormat } : {},
|
|
9762
9901
|
density,
|
|
9763
9902
|
showPresence,
|
|
9764
|
-
linkPreviews
|
|
9903
|
+
linkPreviews,
|
|
9904
|
+
confirmDelete,
|
|
9905
|
+
...appComposerProps ? { composerProps: appComposerProps } : {},
|
|
9906
|
+
...beforeSend ? { beforeSend } : {},
|
|
9907
|
+
...extraActions ? { extraActions } : {}
|
|
9765
9908
|
}
|
|
9766
9909
|
) : null
|
|
9767
9910
|
]
|