@poolse/react-native 3.2.0-dev.5 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +10 -0
- package/dist/index.cjs +330 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +149 -103
- package/dist/index.d.ts +149 -103
- package/dist/index.js +330 -160
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2211,6 +2211,18 @@ var styles11 = StyleSheet.create({
|
|
|
2211
2211
|
fontSize: 14
|
|
2212
2212
|
}
|
|
2213
2213
|
});
|
|
2214
|
+
|
|
2215
|
+
// src/internal/messageFocus.ts
|
|
2216
|
+
function latestMarkableId(messages) {
|
|
2217
|
+
const latest = messages[messages.length - 1];
|
|
2218
|
+
if (!latest?.id) return null;
|
|
2219
|
+
if (typeof latest.sequence !== "number" || latest.sequence <= 0) return null;
|
|
2220
|
+
if (latest.sequence === Number.MAX_SAFE_INTEGER) return null;
|
|
2221
|
+
return latest.id;
|
|
2222
|
+
}
|
|
2223
|
+
function indexOfMessage(items, messageId) {
|
|
2224
|
+
return items.findIndex((it) => it.kind === "msg" && it.msg?.id === messageId);
|
|
2225
|
+
}
|
|
2214
2226
|
var AT_BOTTOM_THRESHOLD = 32;
|
|
2215
2227
|
function MessageList({
|
|
2216
2228
|
messages,
|
|
@@ -2222,7 +2234,9 @@ function MessageList({
|
|
|
2222
2234
|
ListHeader = null,
|
|
2223
2235
|
ListFooter = null,
|
|
2224
2236
|
emptyState,
|
|
2225
|
-
meId = null
|
|
2237
|
+
meId = null,
|
|
2238
|
+
scrollToMessageId = null,
|
|
2239
|
+
scrollRequest = 0
|
|
2226
2240
|
}) {
|
|
2227
2241
|
const theme = usePoolseTheme();
|
|
2228
2242
|
const flatListRef = useRef(null);
|
|
@@ -2251,6 +2265,34 @@ function MessageList({
|
|
|
2251
2265
|
setAtBottom((prev) => prev === next ? prev : next);
|
|
2252
2266
|
if (next) setNewCount(0);
|
|
2253
2267
|
}, []);
|
|
2268
|
+
const dataRef = useRef(data);
|
|
2269
|
+
dataRef.current = data;
|
|
2270
|
+
const scrollRetriesRef = useRef(0);
|
|
2271
|
+
useEffect(() => {
|
|
2272
|
+
if (!scrollToMessageId) return;
|
|
2273
|
+
const index = indexOfMessage(dataRef.current, scrollToMessageId);
|
|
2274
|
+
if (index === -1) return;
|
|
2275
|
+
scrollRetriesRef.current = 0;
|
|
2276
|
+
flatListRef.current?.scrollToIndex({ index, animated: true, viewPosition: 0.5 });
|
|
2277
|
+
}, [scrollToMessageId, scrollRequest]);
|
|
2278
|
+
const onScrollToIndexFailed = useCallback(
|
|
2279
|
+
(info) => {
|
|
2280
|
+
flatListRef.current?.scrollToOffset({
|
|
2281
|
+
offset: info.averageItemLength * info.index,
|
|
2282
|
+
animated: false
|
|
2283
|
+
});
|
|
2284
|
+
if (scrollRetriesRef.current >= 3) return;
|
|
2285
|
+
scrollRetriesRef.current += 1;
|
|
2286
|
+
setTimeout(() => {
|
|
2287
|
+
flatListRef.current?.scrollToIndex({
|
|
2288
|
+
index: info.index,
|
|
2289
|
+
animated: true,
|
|
2290
|
+
viewPosition: 0.5
|
|
2291
|
+
});
|
|
2292
|
+
}, 120);
|
|
2293
|
+
},
|
|
2294
|
+
[]
|
|
2295
|
+
);
|
|
2254
2296
|
const scrollToBottom = useCallback(() => {
|
|
2255
2297
|
flatListRef.current?.scrollToOffset({ offset: 0, animated: true });
|
|
2256
2298
|
setNewCount(0);
|
|
@@ -2280,6 +2322,7 @@ function MessageList({
|
|
|
2280
2322
|
renderItem: handleRender,
|
|
2281
2323
|
onEndReached: hasMore ? onLoadMore : void 0,
|
|
2282
2324
|
onEndReachedThreshold: 0.3,
|
|
2325
|
+
onScrollToIndexFailed,
|
|
2283
2326
|
onScroll: handleScroll,
|
|
2284
2327
|
scrollEventThrottle: 32,
|
|
2285
2328
|
ListHeaderComponent: ListHeader,
|
|
@@ -3036,6 +3079,7 @@ function MessageBubble({
|
|
|
3036
3079
|
groupPosition = "standalone",
|
|
3037
3080
|
maxBodyLength = 0,
|
|
3038
3081
|
showSenderName = false,
|
|
3082
|
+
onSenderPress,
|
|
3039
3083
|
actionsTrigger,
|
|
3040
3084
|
showAttachments = true,
|
|
3041
3085
|
markdown = true,
|
|
@@ -3117,141 +3161,158 @@ function MessageBubble({
|
|
|
3117
3161
|
}
|
|
3118
3162
|
);
|
|
3119
3163
|
};
|
|
3120
|
-
return /* @__PURE__ */ jsxs(
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
{
|
|
3147
|
-
quoted: message.quoted_message,
|
|
3148
|
-
isSelf,
|
|
3149
|
-
...labelFor ? { labelFor } : {},
|
|
3150
|
-
...onQuotedClick ? { onPress: () => onQuotedClick(message.quoted_message.id) } : {}
|
|
3151
|
-
}
|
|
3152
|
-
) : null,
|
|
3153
|
-
hasMedia ? (
|
|
3154
|
-
// 3px of bubble color framing the picture; the mosaic clips
|
|
3155
|
-
// itself 3px tighter than the bubble so the curves stay
|
|
3156
|
-
// concentric.
|
|
3157
|
-
/* @__PURE__ */ jsxs(View, { style: styles17.mediaFrame, children: [
|
|
3158
|
-
/* @__PURE__ */ jsx(
|
|
3159
|
-
ImageMosaic,
|
|
3164
|
+
return /* @__PURE__ */ jsxs(
|
|
3165
|
+
View,
|
|
3166
|
+
{
|
|
3167
|
+
style: [
|
|
3168
|
+
styles17.wrap,
|
|
3169
|
+
{ alignSelf: isSelf ? "flex-end" : "flex-start", maxWidth: bubbleMaxWidth }
|
|
3170
|
+
],
|
|
3171
|
+
children: [
|
|
3172
|
+
/* @__PURE__ */ jsxs(
|
|
3173
|
+
View,
|
|
3174
|
+
{
|
|
3175
|
+
style: [
|
|
3176
|
+
jumboCount === 0 && {
|
|
3177
|
+
backgroundColor: isSelf ? theme.colors.selfBubble : theme.colors.otherBubble,
|
|
3178
|
+
borderColor: isSelf ? "transparent" : theme.colors.border,
|
|
3179
|
+
borderWidth: isSelf ? 0 : StyleSheet.hairlineWidth,
|
|
3180
|
+
borderTopLeftRadius: radii2.topLeft,
|
|
3181
|
+
borderTopRightRadius: radii2.topRight,
|
|
3182
|
+
borderBottomLeftRadius: radii2.bottomLeft,
|
|
3183
|
+
borderBottomRightRadius: radii2.bottomRight
|
|
3184
|
+
},
|
|
3185
|
+
jumboCount === 0 && theme.shadows.sm
|
|
3186
|
+
],
|
|
3187
|
+
children: [
|
|
3188
|
+
showSenderName && !isSelf && jumboCount === 0 && (groupPosition === "first" || groupPosition === "standalone") ? /* @__PURE__ */ jsx(
|
|
3189
|
+
Text,
|
|
3160
3190
|
{
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3191
|
+
style: [styles17.senderName, { color: senderTint, fontFamily: theme.type.fontBody }],
|
|
3192
|
+
...onSenderPress ? {
|
|
3193
|
+
onPress: onSenderPress,
|
|
3194
|
+
accessibilityRole: "button",
|
|
3195
|
+
suppressHighlighting: true
|
|
3196
|
+
} : {},
|
|
3197
|
+
children: senderLabel
|
|
3166
3198
|
}
|
|
3167
|
-
),
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
style: [styles17.textBlock, sectionAbove && styles17.textBlockAfter],
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3199
|
+
) : null,
|
|
3200
|
+
message.quoted_message ? /* @__PURE__ */ jsx(
|
|
3201
|
+
QuotedCard,
|
|
3202
|
+
{
|
|
3203
|
+
quoted: message.quoted_message,
|
|
3204
|
+
isSelf,
|
|
3205
|
+
...labelFor ? { labelFor } : {},
|
|
3206
|
+
...onQuotedClick ? { onPress: () => onQuotedClick(message.quoted_message.id) } : {}
|
|
3207
|
+
}
|
|
3208
|
+
) : null,
|
|
3209
|
+
hasMedia ? (
|
|
3210
|
+
// 3px of bubble color framing the picture; the mosaic clips
|
|
3211
|
+
// itself 3px tighter than the bubble so the curves stay
|
|
3212
|
+
// concentric.
|
|
3213
|
+
/* @__PURE__ */ jsxs(View, { style: styles17.mediaFrame, children: [
|
|
3214
|
+
/* @__PURE__ */ jsx(
|
|
3215
|
+
ImageMosaic,
|
|
3216
|
+
{
|
|
3217
|
+
images,
|
|
3218
|
+
maxWidth: mediaWidth,
|
|
3219
|
+
radius: Math.max(bubbleRadius - 3, 8),
|
|
3220
|
+
squareBottom: !metaOverlay,
|
|
3221
|
+
...onLongPress ? { onLongPress } : {}
|
|
3222
|
+
}
|
|
3223
|
+
),
|
|
3224
|
+
metaOverlay ? metaRow("overlay") : null
|
|
3225
|
+
] })
|
|
3226
|
+
) : null,
|
|
3227
|
+
hasFiles ? /* @__PURE__ */ jsx(View, { style: styles17.filesBlock, children: files.map((att) => /* @__PURE__ */ jsx(
|
|
3228
|
+
AttachmentPreview,
|
|
3229
|
+
{
|
|
3230
|
+
attachment: att,
|
|
3231
|
+
maxWidth: bubbleMaxWidth - 12,
|
|
3232
|
+
tone: isSelf ? "onBrand" : "default"
|
|
3233
|
+
},
|
|
3234
|
+
att.id
|
|
3235
|
+
)) }) : null,
|
|
3236
|
+
isDeleted ? /* @__PURE__ */ jsx(View, { style: [styles17.textBlock, sectionAbove && styles17.textBlockAfter], children: /* @__PURE__ */ jsx(
|
|
3237
|
+
Text,
|
|
3238
|
+
{
|
|
3239
|
+
style: {
|
|
3240
|
+
color: mutedOnBubble,
|
|
3241
|
+
opacity: 0.7,
|
|
3242
|
+
fontFamily: theme.type.fontBody,
|
|
3243
|
+
fontSize: theme.type.bodySize,
|
|
3244
|
+
lineHeight: theme.type.lineHeight,
|
|
3245
|
+
fontStyle: "italic"
|
|
3246
|
+
},
|
|
3247
|
+
children: "Message deleted"
|
|
3248
|
+
}
|
|
3249
|
+
) }) : null,
|
|
3250
|
+
hasBody && jumboCount > 0 ? /* @__PURE__ */ jsx(View, { style: styles17.jumboBlock, children: /* @__PURE__ */ jsx(
|
|
3251
|
+
Text,
|
|
3252
|
+
{
|
|
3253
|
+
style: {
|
|
3254
|
+
fontSize: emojiFontSize(jumboCount),
|
|
3255
|
+
lineHeight: emojiFontSize(jumboCount) + 8
|
|
3256
|
+
},
|
|
3257
|
+
children: body
|
|
3258
|
+
}
|
|
3259
|
+
) }) : null,
|
|
3260
|
+
hasBody && jumboCount === 0 ? /* @__PURE__ */ jsxs(
|
|
3261
|
+
View,
|
|
3262
|
+
{
|
|
3263
|
+
style: [styles17.textBlock, sectionAbove && styles17.textBlockAfter],
|
|
3264
|
+
onLayout: inlineMeta ? (e) => setTextBoxWidth(e.nativeEvent.layout.width - 24) : void 0,
|
|
3265
|
+
children: [
|
|
3266
|
+
markdown && !inlineMeta ? renderMarkdown(truncated, {
|
|
3267
|
+
textColor,
|
|
3268
|
+
linkColor: isSelf ? theme.colors.onBrand : theme.colors.brand,
|
|
3222
3269
|
fontFamily: theme.type.fontBody,
|
|
3223
3270
|
fontSize: theme.type.bodySize,
|
|
3224
|
-
lineHeight: theme.type.lineHeight
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3271
|
+
lineHeight: theme.type.lineHeight,
|
|
3272
|
+
onLinkPress: (url) => {
|
|
3273
|
+
void Linking.openURL(url).catch(() => void 0);
|
|
3274
|
+
return false;
|
|
3275
|
+
}
|
|
3276
|
+
}) : /* @__PURE__ */ jsx(
|
|
3277
|
+
Text,
|
|
3278
|
+
{
|
|
3279
|
+
style: {
|
|
3280
|
+
color: textColor,
|
|
3281
|
+
fontFamily: theme.type.fontBody,
|
|
3282
|
+
fontSize: theme.type.bodySize,
|
|
3283
|
+
lineHeight: theme.type.lineHeight
|
|
3284
|
+
},
|
|
3285
|
+
onTextLayout: inlineMeta ? (e) => {
|
|
3286
|
+
const lines = e.nativeEvent.lines;
|
|
3287
|
+
const last = lines[lines.length - 1];
|
|
3288
|
+
setLastLineWidth(last ? Math.ceil(last.width) : 0);
|
|
3289
|
+
} : void 0,
|
|
3290
|
+
children: truncated
|
|
3291
|
+
}
|
|
3292
|
+
),
|
|
3293
|
+
trimmable ? /* @__PURE__ */ jsx(Pressable, { onPress: () => setExpanded((e) => !e), children: /* @__PURE__ */ jsx(
|
|
3294
|
+
Text,
|
|
3295
|
+
{
|
|
3296
|
+
style: [
|
|
3297
|
+
styles17.readMore,
|
|
3298
|
+
{ color: isSelf ? theme.colors.onBrand : theme.colors.brand }
|
|
3299
|
+
],
|
|
3300
|
+
children: expanded ? "Show less" : "Read more"
|
|
3301
|
+
}
|
|
3302
|
+
) }) : null,
|
|
3303
|
+
inlineMeta ? metaRow(metaFits ? "inline" : "wrapped") : null
|
|
3304
|
+
]
|
|
3305
|
+
}
|
|
3306
|
+
) : null,
|
|
3307
|
+
!inlineMeta && !metaOverlay && jumboCount === 0 ? metaRow("block") : null,
|
|
3308
|
+
actionsTrigger ? /* @__PURE__ */ jsx(View, { style: styles17.actionsSlot, children: actionsTrigger }) : null
|
|
3309
|
+
]
|
|
3310
|
+
}
|
|
3311
|
+
),
|
|
3312
|
+
jumboCount > 0 ? /* @__PURE__ */ jsx(View, { style: { alignSelf: isSelf ? "flex-end" : "flex-start" }, children: metaRow("jumbo") }) : null
|
|
3313
|
+
]
|
|
3314
|
+
}
|
|
3315
|
+
);
|
|
3255
3316
|
}
|
|
3256
3317
|
function QuotedCard({
|
|
3257
3318
|
quoted,
|
|
@@ -3618,7 +3679,9 @@ function BubbleMessageRow({
|
|
|
3618
3679
|
maxBodyLength = 0,
|
|
3619
3680
|
showSenderName = false,
|
|
3620
3681
|
showAvatar = false,
|
|
3621
|
-
avatarFor
|
|
3682
|
+
avatarFor,
|
|
3683
|
+
onSenderPress,
|
|
3684
|
+
onAvatarPress
|
|
3622
3685
|
}) {
|
|
3623
3686
|
const theme = usePoolseTheme();
|
|
3624
3687
|
const isSelf = meId !== null && msg.sender_id === meId;
|
|
@@ -3701,9 +3764,25 @@ function BubbleMessageRow({
|
|
|
3701
3764
|
});
|
|
3702
3765
|
const showAvatarSlot = showAvatar && !isSelf;
|
|
3703
3766
|
const showAvatarRender = showAvatarSlot && (groupPosition === "last" || groupPosition === "standalone");
|
|
3704
|
-
const
|
|
3767
|
+
const wantsSender = showAvatarSlot || !isSelf && onSenderPress !== void 0;
|
|
3768
|
+
const rowSender = useUser(wantsSender ? msg.sender_external_id : null);
|
|
3705
3769
|
const avatarUrl = msg.sender_external_id ? avatarFor?.(msg.sender_external_id) ?? rowSender.profile?.avatarUrl ?? null : null;
|
|
3706
3770
|
const senderLabel = msg.sender_external_id ? labelFor?.(msg.sender_external_id) ?? rowSender.profile?.displayName ?? msg.sender_external_id : null;
|
|
3771
|
+
const sender = {
|
|
3772
|
+
userId: msg.sender_id,
|
|
3773
|
+
externalId: msg.sender_external_id,
|
|
3774
|
+
displayName: senderLabel ?? "Unknown",
|
|
3775
|
+
avatarUrl
|
|
3776
|
+
};
|
|
3777
|
+
const avatar = /* @__PURE__ */ jsx(
|
|
3778
|
+
Avatar,
|
|
3779
|
+
{
|
|
3780
|
+
src: avatarUrl ?? null,
|
|
3781
|
+
name: senderLabel,
|
|
3782
|
+
seed: msg.sender_external_id ?? null,
|
|
3783
|
+
size: "sm"
|
|
3784
|
+
}
|
|
3785
|
+
);
|
|
3707
3786
|
return /* @__PURE__ */ jsxs(
|
|
3708
3787
|
View,
|
|
3709
3788
|
{
|
|
@@ -3716,15 +3795,16 @@ function BubbleMessageRow({
|
|
|
3716
3795
|
isEditing ? styles19.rowEditing : null
|
|
3717
3796
|
],
|
|
3718
3797
|
children: [
|
|
3719
|
-
showAvatarSlot ? /* @__PURE__ */ jsx(View, { style: styles19.avatarSlot, children: showAvatarRender ? /* @__PURE__ */ jsx(
|
|
3720
|
-
|
|
3798
|
+
showAvatarSlot ? /* @__PURE__ */ jsx(View, { style: styles19.avatarSlot, children: !showAvatarRender ? null : onAvatarPress ? /* @__PURE__ */ jsx(
|
|
3799
|
+
Pressable,
|
|
3721
3800
|
{
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3801
|
+
onPress: () => onAvatarPress(sender),
|
|
3802
|
+
accessibilityRole: "button",
|
|
3803
|
+
accessibilityLabel: sender.displayName,
|
|
3804
|
+
hitSlop: 6,
|
|
3805
|
+
children: avatar
|
|
3726
3806
|
}
|
|
3727
|
-
) :
|
|
3807
|
+
) : avatar }) : null,
|
|
3728
3808
|
/* @__PURE__ */ jsxs(View, { style: styles19.bubbleCol, children: [
|
|
3729
3809
|
swipeEnabled ? /* @__PURE__ */ jsx(
|
|
3730
3810
|
Animated.View,
|
|
@@ -3767,6 +3847,7 @@ function BubbleMessageRow({
|
|
|
3767
3847
|
groupPosition,
|
|
3768
3848
|
maxBodyLength,
|
|
3769
3849
|
showSenderName,
|
|
3850
|
+
...onSenderPress ? { onSenderPress: () => onSenderPress(sender) } : {},
|
|
3770
3851
|
showAttachments: attachments,
|
|
3771
3852
|
markdown,
|
|
3772
3853
|
onLongPress: () => {
|
|
@@ -4279,12 +4360,21 @@ function ConversationView({
|
|
|
4279
4360
|
avatars = "auto",
|
|
4280
4361
|
onMarkedRead,
|
|
4281
4362
|
onSent,
|
|
4363
|
+
focusMessageId = null,
|
|
4364
|
+
onFocusMessageNotFound,
|
|
4365
|
+
onSenderPress,
|
|
4366
|
+
onAvatarPress,
|
|
4367
|
+
composer = true,
|
|
4368
|
+
readOnly = false,
|
|
4282
4369
|
keyboardOffset = 0,
|
|
4283
4370
|
onCallBack,
|
|
4284
4371
|
onJoinCall,
|
|
4285
4372
|
currentCallId = null
|
|
4286
4373
|
}) {
|
|
4287
4374
|
const theme = usePoolseTheme();
|
|
4375
|
+
const showComposer = composer && !readOnly;
|
|
4376
|
+
const canQuote = quotations && showComposer;
|
|
4377
|
+
const canAttach = attachments && showComposer;
|
|
4288
4378
|
const { me } = useMe();
|
|
4289
4379
|
const meId = me?.id ?? null;
|
|
4290
4380
|
const receiptsVisible = receiptsOf(me).visible;
|
|
@@ -4294,6 +4384,7 @@ function ConversationView({
|
|
|
4294
4384
|
loading,
|
|
4295
4385
|
hasMore,
|
|
4296
4386
|
loadMore,
|
|
4387
|
+
loadUntil,
|
|
4297
4388
|
send,
|
|
4298
4389
|
edit,
|
|
4299
4390
|
delete: deleteMsg,
|
|
@@ -4343,22 +4434,73 @@ function ConversationView({
|
|
|
4343
4434
|
}, [messages]);
|
|
4344
4435
|
const lastMarkedRef = useRef(null);
|
|
4345
4436
|
useEffect(() => {
|
|
4346
|
-
|
|
4347
|
-
if (
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
onMarkedRead?.(conversationId, latest.id);
|
|
4357
|
-
}, [messages, meId, readReceipts, markReadUpTo, onMarkedRead, conversationId]);
|
|
4437
|
+
const latestId = latestMarkableId(messages);
|
|
4438
|
+
if (!latestId || latestId === lastMarkedRef.current) return;
|
|
4439
|
+
lastMarkedRef.current = latestId;
|
|
4440
|
+
markReadUpTo(latestId).then(
|
|
4441
|
+
() => onMarkedRead?.(conversationId, latestId),
|
|
4442
|
+
() => {
|
|
4443
|
+
if (lastMarkedRef.current === latestId) lastMarkedRef.current = null;
|
|
4444
|
+
}
|
|
4445
|
+
);
|
|
4446
|
+
}, [messages, markReadUpTo, onMarkedRead, conversationId]);
|
|
4358
4447
|
const visibleMessages = useMemo(
|
|
4359
4448
|
() => messages.filter((m) => isMessageVisibleTo(m, meId)),
|
|
4360
4449
|
[messages, meId]
|
|
4361
4450
|
);
|
|
4451
|
+
const [jump, setJump] = useState(null);
|
|
4452
|
+
const [pendingFocusId, setPendingFocusId] = useState(null);
|
|
4453
|
+
const [highlightId, setHighlightId] = useState(null);
|
|
4454
|
+
const [focusMissing, setFocusMissing] = useState(false);
|
|
4455
|
+
const onFocusNotFoundRef = useRef(onFocusMessageNotFound);
|
|
4456
|
+
onFocusNotFoundRef.current = onFocusMessageNotFound;
|
|
4457
|
+
const focusMiss = useCallback((id, report) => {
|
|
4458
|
+
setFocusMissing(true);
|
|
4459
|
+
if (report) onFocusNotFoundRef.current?.(id);
|
|
4460
|
+
}, []);
|
|
4461
|
+
const jumpTo = useCallback(
|
|
4462
|
+
(id, report) => {
|
|
4463
|
+
let current = true;
|
|
4464
|
+
loadUntil(id).then((found) => {
|
|
4465
|
+
if (!current) return;
|
|
4466
|
+
if (found) setPendingFocusId(id);
|
|
4467
|
+
else focusMiss(id, report);
|
|
4468
|
+
}).catch(() => {
|
|
4469
|
+
if (current) focusMiss(id, report);
|
|
4470
|
+
});
|
|
4471
|
+
return () => {
|
|
4472
|
+
current = false;
|
|
4473
|
+
};
|
|
4474
|
+
},
|
|
4475
|
+
[loadUntil, focusMiss]
|
|
4476
|
+
);
|
|
4477
|
+
useEffect(() => {
|
|
4478
|
+
setPendingFocusId(null);
|
|
4479
|
+
setFocusMissing(false);
|
|
4480
|
+
if (!focusMessageId || loading) return;
|
|
4481
|
+
return jumpTo(focusMessageId, true);
|
|
4482
|
+
}, [focusMessageId, conversationId, loading, jumpTo]);
|
|
4483
|
+
useEffect(() => {
|
|
4484
|
+
if (!pendingFocusId) return;
|
|
4485
|
+
setPendingFocusId(null);
|
|
4486
|
+
if (!visibleMessages.some((m) => m.id === pendingFocusId)) {
|
|
4487
|
+
focusMiss(pendingFocusId, true);
|
|
4488
|
+
return;
|
|
4489
|
+
}
|
|
4490
|
+
setJump((prev) => ({ id: pendingFocusId, request: (prev?.request ?? 0) + 1 }));
|
|
4491
|
+
setHighlightId(pendingFocusId);
|
|
4492
|
+
}, [pendingFocusId, visibleMessages, focusMiss]);
|
|
4493
|
+
useEffect(() => {
|
|
4494
|
+
if (!highlightId) return;
|
|
4495
|
+
const t = setTimeout(() => setHighlightId(null), 1600);
|
|
4496
|
+
return () => clearTimeout(t);
|
|
4497
|
+
}, [highlightId]);
|
|
4498
|
+
useEffect(() => {
|
|
4499
|
+
if (!focusMissing) return;
|
|
4500
|
+
const t = setTimeout(() => setFocusMissing(false), 4e3);
|
|
4501
|
+
return () => clearTimeout(t);
|
|
4502
|
+
}, [focusMissing]);
|
|
4503
|
+
const onQuotedClick = useCallback((id) => void jumpTo(id, false), [jumpTo]);
|
|
4362
4504
|
const groupPositionById = useMemo(() => {
|
|
4363
4505
|
const map = /* @__PURE__ */ new Map();
|
|
4364
4506
|
for (let i = 0; i < visibleMessages.length; i++) {
|
|
@@ -4386,7 +4528,7 @@ function ConversationView({
|
|
|
4386
4528
|
insertedAt: msg.inserted_at
|
|
4387
4529
|
});
|
|
4388
4530
|
const groupPosition = groupPositionById.get(msg.id) ?? "standalone";
|
|
4389
|
-
|
|
4531
|
+
const row = /* @__PURE__ */ jsx(
|
|
4390
4532
|
MessageRow,
|
|
4391
4533
|
{
|
|
4392
4534
|
msg,
|
|
@@ -4395,15 +4537,18 @@ function ConversationView({
|
|
|
4395
4537
|
attachments,
|
|
4396
4538
|
actions,
|
|
4397
4539
|
threads,
|
|
4398
|
-
quotations,
|
|
4540
|
+
quotations: canQuote,
|
|
4399
4541
|
...readState ? { readState } : {},
|
|
4400
4542
|
isEditing: editingId === msg.id,
|
|
4401
4543
|
...canEdit ? { onStartEdit: () => setEditingId(msg.id) } : {},
|
|
4402
4544
|
onDelete: () => deleteMsg(msg.id),
|
|
4403
4545
|
...threads ? { onOpenThread: () => setThreadRoot(msg) } : {},
|
|
4404
|
-
...
|
|
4546
|
+
...canQuote ? { onQuote: () => setReplyingTo(msg) } : {},
|
|
4547
|
+
onQuotedClick,
|
|
4405
4548
|
...labelFor ? { labelFor } : {},
|
|
4406
4549
|
...avatarFor ? { avatarFor } : {},
|
|
4550
|
+
...onSenderPress ? { onSenderPress } : {},
|
|
4551
|
+
...onAvatarPress ? { onAvatarPress } : {},
|
|
4407
4552
|
showSenderName: showSenderLabels,
|
|
4408
4553
|
showAvatar: showAvatars,
|
|
4409
4554
|
maxBodyLength,
|
|
@@ -4412,12 +4557,19 @@ function ConversationView({
|
|
|
4412
4557
|
...onCallBack ? { onCallBack } : {}
|
|
4413
4558
|
}
|
|
4414
4559
|
);
|
|
4560
|
+
if (msg.id !== highlightId) return row;
|
|
4561
|
+
return /* @__PURE__ */ jsx(View, { style: { backgroundColor: theme.colors.brandSoft }, children: row });
|
|
4415
4562
|
},
|
|
4416
4563
|
[
|
|
4417
4564
|
onCallBack,
|
|
4565
|
+
onQuotedClick,
|
|
4566
|
+
onSenderPress,
|
|
4567
|
+
onAvatarPress,
|
|
4568
|
+
highlightId,
|
|
4569
|
+
theme.colors.brandSoft,
|
|
4570
|
+
canQuote,
|
|
4418
4571
|
renderMessage,
|
|
4419
4572
|
meId,
|
|
4420
|
-
readReceipts,
|
|
4421
4573
|
showReadState,
|
|
4422
4574
|
receiptsVisible,
|
|
4423
4575
|
members,
|
|
@@ -4425,7 +4577,6 @@ function ConversationView({
|
|
|
4425
4577
|
attachments,
|
|
4426
4578
|
actions,
|
|
4427
4579
|
threads,
|
|
4428
|
-
quotations,
|
|
4429
4580
|
editingId,
|
|
4430
4581
|
deleteMsg,
|
|
4431
4582
|
labelFor,
|
|
@@ -4513,6 +4664,17 @@ function ConversationView({
|
|
|
4513
4664
|
keyboardVerticalOffset: keyboardOffset,
|
|
4514
4665
|
children: [
|
|
4515
4666
|
headerNode,
|
|
4667
|
+
focusMissing ? /* @__PURE__ */ jsx(
|
|
4668
|
+
Text,
|
|
4669
|
+
{
|
|
4670
|
+
style: [
|
|
4671
|
+
styles22.notice,
|
|
4672
|
+
{ color: theme.colors.ink2, backgroundColor: theme.colors.surface2 }
|
|
4673
|
+
],
|
|
4674
|
+
accessibilityRole: "alert",
|
|
4675
|
+
children: "That message isn't available."
|
|
4676
|
+
}
|
|
4677
|
+
) : null,
|
|
4516
4678
|
onJoinCall ? /* @__PURE__ */ jsx(
|
|
4517
4679
|
JoinBanner,
|
|
4518
4680
|
{
|
|
@@ -4533,6 +4695,8 @@ function ConversationView({
|
|
|
4533
4695
|
hasMore,
|
|
4534
4696
|
onLoadMore: loadMore,
|
|
4535
4697
|
renderItem,
|
|
4698
|
+
scrollToMessageId: jump?.id ?? null,
|
|
4699
|
+
scrollRequest: jump?.request ?? 0,
|
|
4536
4700
|
ListHeader: /* @__PURE__ */ jsxs(View, { children: [
|
|
4537
4701
|
visibleStreams.map(
|
|
4538
4702
|
(stream) => stream.status === "failed" ? /* @__PURE__ */ jsx(
|
|
@@ -4576,8 +4740,8 @@ function ConversationView({
|
|
|
4576
4740
|
}
|
|
4577
4741
|
) : null
|
|
4578
4742
|
] }),
|
|
4579
|
-
mentions ? /* @__PURE__ */ jsx(MentionInput, { conversationId, ...composerProps }) : /* @__PURE__ */ jsx(MessageComposer, { ...composerProps }),
|
|
4580
|
-
|
|
4743
|
+
!showComposer ? null : mentions ? /* @__PURE__ */ jsx(MentionInput, { conversationId, ...composerProps }) : /* @__PURE__ */ jsx(MessageComposer, { ...composerProps }),
|
|
4744
|
+
canAttach ? /* @__PURE__ */ jsx(AttachmentPicker, { visible: pickerOpen, onClose: () => setPickerOpen(false) }) : null,
|
|
4581
4745
|
threads && threadRoot ? /* @__PURE__ */ jsx(
|
|
4582
4746
|
ThreadView,
|
|
4583
4747
|
{
|
|
@@ -4620,6 +4784,12 @@ var styles22 = StyleSheet.create({
|
|
|
4620
4784
|
root: {
|
|
4621
4785
|
flex: 1
|
|
4622
4786
|
},
|
|
4787
|
+
notice: {
|
|
4788
|
+
fontSize: 12,
|
|
4789
|
+
fontWeight: "600",
|
|
4790
|
+
paddingHorizontal: 16,
|
|
4791
|
+
paddingVertical: 8
|
|
4792
|
+
},
|
|
4623
4793
|
streamFailed: {
|
|
4624
4794
|
fontSize: 12,
|
|
4625
4795
|
marginHorizontal: 16,
|