@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/dist/index.cjs CHANGED
@@ -2238,6 +2238,18 @@ var styles11 = reactNative.StyleSheet.create({
2238
2238
  fontSize: 14
2239
2239
  }
2240
2240
  });
2241
+
2242
+ // src/internal/messageFocus.ts
2243
+ function latestMarkableId(messages) {
2244
+ const latest = messages[messages.length - 1];
2245
+ if (!latest?.id) return null;
2246
+ if (typeof latest.sequence !== "number" || latest.sequence <= 0) return null;
2247
+ if (latest.sequence === Number.MAX_SAFE_INTEGER) return null;
2248
+ return latest.id;
2249
+ }
2250
+ function indexOfMessage(items, messageId) {
2251
+ return items.findIndex((it) => it.kind === "msg" && it.msg?.id === messageId);
2252
+ }
2241
2253
  var AT_BOTTOM_THRESHOLD = 32;
2242
2254
  function MessageList({
2243
2255
  messages,
@@ -2249,7 +2261,9 @@ function MessageList({
2249
2261
  ListHeader = null,
2250
2262
  ListFooter = null,
2251
2263
  emptyState,
2252
- meId = null
2264
+ meId = null,
2265
+ scrollToMessageId = null,
2266
+ scrollRequest = 0
2253
2267
  }) {
2254
2268
  const theme = usePoolseTheme();
2255
2269
  const flatListRef = react.useRef(null);
@@ -2278,6 +2292,34 @@ function MessageList({
2278
2292
  setAtBottom((prev) => prev === next ? prev : next);
2279
2293
  if (next) setNewCount(0);
2280
2294
  }, []);
2295
+ const dataRef = react.useRef(data);
2296
+ dataRef.current = data;
2297
+ const scrollRetriesRef = react.useRef(0);
2298
+ react.useEffect(() => {
2299
+ if (!scrollToMessageId) return;
2300
+ const index = indexOfMessage(dataRef.current, scrollToMessageId);
2301
+ if (index === -1) return;
2302
+ scrollRetriesRef.current = 0;
2303
+ flatListRef.current?.scrollToIndex({ index, animated: true, viewPosition: 0.5 });
2304
+ }, [scrollToMessageId, scrollRequest]);
2305
+ const onScrollToIndexFailed = react.useCallback(
2306
+ (info) => {
2307
+ flatListRef.current?.scrollToOffset({
2308
+ offset: info.averageItemLength * info.index,
2309
+ animated: false
2310
+ });
2311
+ if (scrollRetriesRef.current >= 3) return;
2312
+ scrollRetriesRef.current += 1;
2313
+ setTimeout(() => {
2314
+ flatListRef.current?.scrollToIndex({
2315
+ index: info.index,
2316
+ animated: true,
2317
+ viewPosition: 0.5
2318
+ });
2319
+ }, 120);
2320
+ },
2321
+ []
2322
+ );
2281
2323
  const scrollToBottom = react.useCallback(() => {
2282
2324
  flatListRef.current?.scrollToOffset({ offset: 0, animated: true });
2283
2325
  setNewCount(0);
@@ -2307,6 +2349,7 @@ function MessageList({
2307
2349
  renderItem: handleRender,
2308
2350
  onEndReached: hasMore ? onLoadMore : void 0,
2309
2351
  onEndReachedThreshold: 0.3,
2352
+ onScrollToIndexFailed,
2310
2353
  onScroll: handleScroll,
2311
2354
  scrollEventThrottle: 32,
2312
2355
  ListHeaderComponent: ListHeader,
@@ -3063,6 +3106,7 @@ function MessageBubble({
3063
3106
  groupPosition = "standalone",
3064
3107
  maxBodyLength = 0,
3065
3108
  showSenderName = false,
3109
+ onSenderPress,
3066
3110
  actionsTrigger,
3067
3111
  showAttachments = true,
3068
3112
  markdown = true,
@@ -3144,141 +3188,158 @@ function MessageBubble({
3144
3188
  }
3145
3189
  );
3146
3190
  };
3147
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles17.wrap, { alignSelf: isSelf ? "flex-end" : "flex-start", maxWidth: bubbleMaxWidth }], children: [
3148
- /* @__PURE__ */ jsxRuntime.jsxs(
3149
- reactNative.View,
3150
- {
3151
- style: [
3152
- jumboCount === 0 && {
3153
- backgroundColor: isSelf ? theme.colors.selfBubble : theme.colors.otherBubble,
3154
- borderColor: isSelf ? "transparent" : theme.colors.border,
3155
- borderWidth: isSelf ? 0 : reactNative.StyleSheet.hairlineWidth,
3156
- borderTopLeftRadius: radii2.topLeft,
3157
- borderTopRightRadius: radii2.topRight,
3158
- borderBottomLeftRadius: radii2.bottomLeft,
3159
- borderBottomRightRadius: radii2.bottomRight
3160
- },
3161
- jumboCount === 0 && theme.shadows.sm
3162
- ],
3163
- children: [
3164
- showSenderName && !isSelf && jumboCount === 0 && (groupPosition === "first" || groupPosition === "standalone") ? /* @__PURE__ */ jsxRuntime.jsx(
3165
- reactNative.Text,
3166
- {
3167
- style: [styles17.senderName, { color: senderTint, fontFamily: theme.type.fontBody }],
3168
- children: senderLabel
3169
- }
3170
- ) : null,
3171
- message.quoted_message ? /* @__PURE__ */ jsxRuntime.jsx(
3172
- QuotedCard,
3173
- {
3174
- quoted: message.quoted_message,
3175
- isSelf,
3176
- ...labelFor ? { labelFor } : {},
3177
- ...onQuotedClick ? { onPress: () => onQuotedClick(message.quoted_message.id) } : {}
3178
- }
3179
- ) : null,
3180
- hasMedia ? (
3181
- // 3px of bubble color framing the picture; the mosaic clips
3182
- // itself 3px tighter than the bubble so the curves stay
3183
- // concentric.
3184
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles17.mediaFrame, children: [
3185
- /* @__PURE__ */ jsxRuntime.jsx(
3186
- ImageMosaic,
3191
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3192
+ reactNative.View,
3193
+ {
3194
+ style: [
3195
+ styles17.wrap,
3196
+ { alignSelf: isSelf ? "flex-end" : "flex-start", maxWidth: bubbleMaxWidth }
3197
+ ],
3198
+ children: [
3199
+ /* @__PURE__ */ jsxRuntime.jsxs(
3200
+ reactNative.View,
3201
+ {
3202
+ style: [
3203
+ jumboCount === 0 && {
3204
+ backgroundColor: isSelf ? theme.colors.selfBubble : theme.colors.otherBubble,
3205
+ borderColor: isSelf ? "transparent" : theme.colors.border,
3206
+ borderWidth: isSelf ? 0 : reactNative.StyleSheet.hairlineWidth,
3207
+ borderTopLeftRadius: radii2.topLeft,
3208
+ borderTopRightRadius: radii2.topRight,
3209
+ borderBottomLeftRadius: radii2.bottomLeft,
3210
+ borderBottomRightRadius: radii2.bottomRight
3211
+ },
3212
+ jumboCount === 0 && theme.shadows.sm
3213
+ ],
3214
+ children: [
3215
+ showSenderName && !isSelf && jumboCount === 0 && (groupPosition === "first" || groupPosition === "standalone") ? /* @__PURE__ */ jsxRuntime.jsx(
3216
+ reactNative.Text,
3187
3217
  {
3188
- images,
3189
- maxWidth: mediaWidth,
3190
- radius: Math.max(bubbleRadius - 3, 8),
3191
- squareBottom: !metaOverlay,
3192
- ...onLongPress ? { onLongPress } : {}
3218
+ style: [styles17.senderName, { color: senderTint, fontFamily: theme.type.fontBody }],
3219
+ ...onSenderPress ? {
3220
+ onPress: onSenderPress,
3221
+ accessibilityRole: "button",
3222
+ suppressHighlighting: true
3223
+ } : {},
3224
+ children: senderLabel
3193
3225
  }
3194
- ),
3195
- metaOverlay ? metaRow("overlay") : null
3196
- ] })
3197
- ) : null,
3198
- hasFiles ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles17.filesBlock, children: files.map((att) => /* @__PURE__ */ jsxRuntime.jsx(
3199
- AttachmentPreview,
3200
- {
3201
- attachment: att,
3202
- maxWidth: bubbleMaxWidth - 12,
3203
- tone: isSelf ? "onBrand" : "default"
3204
- },
3205
- att.id
3206
- )) }) : null,
3207
- isDeleted ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles17.textBlock, sectionAbove && styles17.textBlockAfter], children: /* @__PURE__ */ jsxRuntime.jsx(
3208
- reactNative.Text,
3209
- {
3210
- style: {
3211
- color: mutedOnBubble,
3212
- opacity: 0.7,
3213
- fontFamily: theme.type.fontBody,
3214
- fontSize: theme.type.bodySize,
3215
- lineHeight: theme.type.lineHeight,
3216
- fontStyle: "italic"
3217
- },
3218
- children: "Message deleted"
3219
- }
3220
- ) }) : null,
3221
- hasBody && jumboCount > 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles17.jumboBlock, children: /* @__PURE__ */ jsxRuntime.jsx(
3222
- reactNative.Text,
3223
- {
3224
- style: { fontSize: emojiFontSize(jumboCount), lineHeight: emojiFontSize(jumboCount) + 8 },
3225
- children: body
3226
- }
3227
- ) }) : null,
3228
- hasBody && jumboCount === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(
3229
- reactNative.View,
3230
- {
3231
- style: [styles17.textBlock, sectionAbove && styles17.textBlockAfter],
3232
- onLayout: inlineMeta ? (e) => setTextBoxWidth(e.nativeEvent.layout.width - 24) : void 0,
3233
- children: [
3234
- markdown && !inlineMeta ? renderMarkdown(truncated, {
3235
- textColor,
3236
- linkColor: isSelf ? theme.colors.onBrand : theme.colors.brand,
3237
- fontFamily: theme.type.fontBody,
3238
- fontSize: theme.type.bodySize,
3239
- lineHeight: theme.type.lineHeight,
3240
- onLinkPress: (url) => {
3241
- void reactNative.Linking.openURL(url).catch(() => void 0);
3242
- return false;
3243
- }
3244
- }) : /* @__PURE__ */ jsxRuntime.jsx(
3245
- reactNative.Text,
3246
- {
3247
- style: {
3248
- color: textColor,
3226
+ ) : null,
3227
+ message.quoted_message ? /* @__PURE__ */ jsxRuntime.jsx(
3228
+ QuotedCard,
3229
+ {
3230
+ quoted: message.quoted_message,
3231
+ isSelf,
3232
+ ...labelFor ? { labelFor } : {},
3233
+ ...onQuotedClick ? { onPress: () => onQuotedClick(message.quoted_message.id) } : {}
3234
+ }
3235
+ ) : null,
3236
+ hasMedia ? (
3237
+ // 3px of bubble color framing the picture; the mosaic clips
3238
+ // itself 3px tighter than the bubble so the curves stay
3239
+ // concentric.
3240
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles17.mediaFrame, children: [
3241
+ /* @__PURE__ */ jsxRuntime.jsx(
3242
+ ImageMosaic,
3243
+ {
3244
+ images,
3245
+ maxWidth: mediaWidth,
3246
+ radius: Math.max(bubbleRadius - 3, 8),
3247
+ squareBottom: !metaOverlay,
3248
+ ...onLongPress ? { onLongPress } : {}
3249
+ }
3250
+ ),
3251
+ metaOverlay ? metaRow("overlay") : null
3252
+ ] })
3253
+ ) : null,
3254
+ hasFiles ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles17.filesBlock, children: files.map((att) => /* @__PURE__ */ jsxRuntime.jsx(
3255
+ AttachmentPreview,
3256
+ {
3257
+ attachment: att,
3258
+ maxWidth: bubbleMaxWidth - 12,
3259
+ tone: isSelf ? "onBrand" : "default"
3260
+ },
3261
+ att.id
3262
+ )) }) : null,
3263
+ isDeleted ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles17.textBlock, sectionAbove && styles17.textBlockAfter], children: /* @__PURE__ */ jsxRuntime.jsx(
3264
+ reactNative.Text,
3265
+ {
3266
+ style: {
3267
+ color: mutedOnBubble,
3268
+ opacity: 0.7,
3269
+ fontFamily: theme.type.fontBody,
3270
+ fontSize: theme.type.bodySize,
3271
+ lineHeight: theme.type.lineHeight,
3272
+ fontStyle: "italic"
3273
+ },
3274
+ children: "Message deleted"
3275
+ }
3276
+ ) }) : null,
3277
+ hasBody && jumboCount > 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles17.jumboBlock, children: /* @__PURE__ */ jsxRuntime.jsx(
3278
+ reactNative.Text,
3279
+ {
3280
+ style: {
3281
+ fontSize: emojiFontSize(jumboCount),
3282
+ lineHeight: emojiFontSize(jumboCount) + 8
3283
+ },
3284
+ children: body
3285
+ }
3286
+ ) }) : null,
3287
+ hasBody && jumboCount === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(
3288
+ reactNative.View,
3289
+ {
3290
+ style: [styles17.textBlock, sectionAbove && styles17.textBlockAfter],
3291
+ onLayout: inlineMeta ? (e) => setTextBoxWidth(e.nativeEvent.layout.width - 24) : void 0,
3292
+ children: [
3293
+ markdown && !inlineMeta ? renderMarkdown(truncated, {
3294
+ textColor,
3295
+ linkColor: isSelf ? theme.colors.onBrand : theme.colors.brand,
3249
3296
  fontFamily: theme.type.fontBody,
3250
3297
  fontSize: theme.type.bodySize,
3251
- lineHeight: theme.type.lineHeight
3252
- },
3253
- onTextLayout: inlineMeta ? (e) => {
3254
- const lines = e.nativeEvent.lines;
3255
- const last = lines[lines.length - 1];
3256
- setLastLineWidth(last ? Math.ceil(last.width) : 0);
3257
- } : void 0,
3258
- children: truncated
3259
- }
3260
- ),
3261
- trimmable ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { onPress: () => setExpanded((e) => !e), children: /* @__PURE__ */ jsxRuntime.jsx(
3262
- reactNative.Text,
3263
- {
3264
- style: [
3265
- styles17.readMore,
3266
- { color: isSelf ? theme.colors.onBrand : theme.colors.brand }
3267
- ],
3268
- children: expanded ? "Show less" : "Read more"
3269
- }
3270
- ) }) : null,
3271
- inlineMeta ? metaRow(metaFits ? "inline" : "wrapped") : null
3272
- ]
3273
- }
3274
- ) : null,
3275
- !inlineMeta && !metaOverlay && jumboCount === 0 ? metaRow("block") : null,
3276
- actionsTrigger ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles17.actionsSlot, children: actionsTrigger }) : null
3277
- ]
3278
- }
3279
- ),
3280
- jumboCount > 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { alignSelf: isSelf ? "flex-end" : "flex-start" }, children: metaRow("jumbo") }) : null
3281
- ] });
3298
+ lineHeight: theme.type.lineHeight,
3299
+ onLinkPress: (url) => {
3300
+ void reactNative.Linking.openURL(url).catch(() => void 0);
3301
+ return false;
3302
+ }
3303
+ }) : /* @__PURE__ */ jsxRuntime.jsx(
3304
+ reactNative.Text,
3305
+ {
3306
+ style: {
3307
+ color: textColor,
3308
+ fontFamily: theme.type.fontBody,
3309
+ fontSize: theme.type.bodySize,
3310
+ lineHeight: theme.type.lineHeight
3311
+ },
3312
+ onTextLayout: inlineMeta ? (e) => {
3313
+ const lines = e.nativeEvent.lines;
3314
+ const last = lines[lines.length - 1];
3315
+ setLastLineWidth(last ? Math.ceil(last.width) : 0);
3316
+ } : void 0,
3317
+ children: truncated
3318
+ }
3319
+ ),
3320
+ trimmable ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { onPress: () => setExpanded((e) => !e), children: /* @__PURE__ */ jsxRuntime.jsx(
3321
+ reactNative.Text,
3322
+ {
3323
+ style: [
3324
+ styles17.readMore,
3325
+ { color: isSelf ? theme.colors.onBrand : theme.colors.brand }
3326
+ ],
3327
+ children: expanded ? "Show less" : "Read more"
3328
+ }
3329
+ ) }) : null,
3330
+ inlineMeta ? metaRow(metaFits ? "inline" : "wrapped") : null
3331
+ ]
3332
+ }
3333
+ ) : null,
3334
+ !inlineMeta && !metaOverlay && jumboCount === 0 ? metaRow("block") : null,
3335
+ actionsTrigger ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles17.actionsSlot, children: actionsTrigger }) : null
3336
+ ]
3337
+ }
3338
+ ),
3339
+ jumboCount > 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { alignSelf: isSelf ? "flex-end" : "flex-start" }, children: metaRow("jumbo") }) : null
3340
+ ]
3341
+ }
3342
+ );
3282
3343
  }
3283
3344
  function QuotedCard({
3284
3345
  quoted,
@@ -3645,7 +3706,9 @@ function BubbleMessageRow({
3645
3706
  maxBodyLength = 0,
3646
3707
  showSenderName = false,
3647
3708
  showAvatar = false,
3648
- avatarFor
3709
+ avatarFor,
3710
+ onSenderPress,
3711
+ onAvatarPress
3649
3712
  }) {
3650
3713
  const theme = usePoolseTheme();
3651
3714
  const isSelf = meId !== null && msg.sender_id === meId;
@@ -3728,9 +3791,25 @@ function BubbleMessageRow({
3728
3791
  });
3729
3792
  const showAvatarSlot = showAvatar && !isSelf;
3730
3793
  const showAvatarRender = showAvatarSlot && (groupPosition === "last" || groupPosition === "standalone");
3731
- const rowSender = react$1.useUser(showAvatarSlot ? msg.sender_external_id : null);
3794
+ const wantsSender = showAvatarSlot || !isSelf && onSenderPress !== void 0;
3795
+ const rowSender = react$1.useUser(wantsSender ? msg.sender_external_id : null);
3732
3796
  const avatarUrl = msg.sender_external_id ? avatarFor?.(msg.sender_external_id) ?? rowSender.profile?.avatarUrl ?? null : null;
3733
3797
  const senderLabel = msg.sender_external_id ? labelFor?.(msg.sender_external_id) ?? rowSender.profile?.displayName ?? msg.sender_external_id : null;
3798
+ const sender = {
3799
+ userId: msg.sender_id,
3800
+ externalId: msg.sender_external_id,
3801
+ displayName: senderLabel ?? "Unknown",
3802
+ avatarUrl
3803
+ };
3804
+ const avatar = /* @__PURE__ */ jsxRuntime.jsx(
3805
+ Avatar,
3806
+ {
3807
+ src: avatarUrl ?? null,
3808
+ name: senderLabel,
3809
+ seed: msg.sender_external_id ?? null,
3810
+ size: "sm"
3811
+ }
3812
+ );
3734
3813
  return /* @__PURE__ */ jsxRuntime.jsxs(
3735
3814
  reactNative.View,
3736
3815
  {
@@ -3743,15 +3822,16 @@ function BubbleMessageRow({
3743
3822
  isEditing ? styles19.rowEditing : null
3744
3823
  ],
3745
3824
  children: [
3746
- showAvatarSlot ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles19.avatarSlot, children: showAvatarRender ? /* @__PURE__ */ jsxRuntime.jsx(
3747
- Avatar,
3825
+ showAvatarSlot ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles19.avatarSlot, children: !showAvatarRender ? null : onAvatarPress ? /* @__PURE__ */ jsxRuntime.jsx(
3826
+ reactNative.Pressable,
3748
3827
  {
3749
- src: avatarUrl ?? null,
3750
- name: senderLabel,
3751
- seed: msg.sender_external_id ?? null,
3752
- size: "sm"
3828
+ onPress: () => onAvatarPress(sender),
3829
+ accessibilityRole: "button",
3830
+ accessibilityLabel: sender.displayName,
3831
+ hitSlop: 6,
3832
+ children: avatar
3753
3833
  }
3754
- ) : null }) : null,
3834
+ ) : avatar }) : null,
3755
3835
  /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles19.bubbleCol, children: [
3756
3836
  swipeEnabled ? /* @__PURE__ */ jsxRuntime.jsx(
3757
3837
  reactNative.Animated.View,
@@ -3794,6 +3874,7 @@ function BubbleMessageRow({
3794
3874
  groupPosition,
3795
3875
  maxBodyLength,
3796
3876
  showSenderName,
3877
+ ...onSenderPress ? { onSenderPress: () => onSenderPress(sender) } : {},
3797
3878
  showAttachments: attachments,
3798
3879
  markdown,
3799
3880
  onLongPress: () => {
@@ -4306,12 +4387,21 @@ function ConversationView({
4306
4387
  avatars = "auto",
4307
4388
  onMarkedRead,
4308
4389
  onSent,
4390
+ focusMessageId = null,
4391
+ onFocusMessageNotFound,
4392
+ onSenderPress,
4393
+ onAvatarPress,
4394
+ composer = true,
4395
+ readOnly = false,
4309
4396
  keyboardOffset = 0,
4310
4397
  onCallBack,
4311
4398
  onJoinCall,
4312
4399
  currentCallId = null
4313
4400
  }) {
4314
4401
  const theme = usePoolseTheme();
4402
+ const showComposer = composer && !readOnly;
4403
+ const canQuote = quotations && showComposer;
4404
+ const canAttach = attachments && showComposer;
4315
4405
  const { me } = react$1.useMe();
4316
4406
  const meId = me?.id ?? null;
4317
4407
  const receiptsVisible = react$1.receiptsOf(me).visible;
@@ -4321,6 +4411,7 @@ function ConversationView({
4321
4411
  loading,
4322
4412
  hasMore,
4323
4413
  loadMore,
4414
+ loadUntil,
4324
4415
  send,
4325
4416
  edit,
4326
4417
  delete: deleteMsg,
@@ -4370,22 +4461,73 @@ function ConversationView({
4370
4461
  }, [messages]);
4371
4462
  const lastMarkedRef = react.useRef(null);
4372
4463
  react.useEffect(() => {
4373
- if (!readReceipts) return;
4374
- if (messages.length === 0) return;
4375
- const latest = messages[messages.length - 1];
4376
- if (!latest || !latest.id) return;
4377
- if (latest.id === lastMarkedRef.current) return;
4378
- if (typeof latest.sequence !== "number" || latest.sequence <= 0) return;
4379
- lastMarkedRef.current = latest.id;
4380
- void markReadUpTo(latest.id).catch(() => {
4381
- lastMarkedRef.current = null;
4382
- });
4383
- onMarkedRead?.(conversationId, latest.id);
4384
- }, [messages, meId, readReceipts, markReadUpTo, onMarkedRead, conversationId]);
4464
+ const latestId = latestMarkableId(messages);
4465
+ if (!latestId || latestId === lastMarkedRef.current) return;
4466
+ lastMarkedRef.current = latestId;
4467
+ markReadUpTo(latestId).then(
4468
+ () => onMarkedRead?.(conversationId, latestId),
4469
+ () => {
4470
+ if (lastMarkedRef.current === latestId) lastMarkedRef.current = null;
4471
+ }
4472
+ );
4473
+ }, [messages, markReadUpTo, onMarkedRead, conversationId]);
4385
4474
  const visibleMessages = react.useMemo(
4386
4475
  () => messages.filter((m) => react$1.isMessageVisibleTo(m, meId)),
4387
4476
  [messages, meId]
4388
4477
  );
4478
+ const [jump, setJump] = react.useState(null);
4479
+ const [pendingFocusId, setPendingFocusId] = react.useState(null);
4480
+ const [highlightId, setHighlightId] = react.useState(null);
4481
+ const [focusMissing, setFocusMissing] = react.useState(false);
4482
+ const onFocusNotFoundRef = react.useRef(onFocusMessageNotFound);
4483
+ onFocusNotFoundRef.current = onFocusMessageNotFound;
4484
+ const focusMiss = react.useCallback((id, report) => {
4485
+ setFocusMissing(true);
4486
+ if (report) onFocusNotFoundRef.current?.(id);
4487
+ }, []);
4488
+ const jumpTo = react.useCallback(
4489
+ (id, report) => {
4490
+ let current = true;
4491
+ loadUntil(id).then((found) => {
4492
+ if (!current) return;
4493
+ if (found) setPendingFocusId(id);
4494
+ else focusMiss(id, report);
4495
+ }).catch(() => {
4496
+ if (current) focusMiss(id, report);
4497
+ });
4498
+ return () => {
4499
+ current = false;
4500
+ };
4501
+ },
4502
+ [loadUntil, focusMiss]
4503
+ );
4504
+ react.useEffect(() => {
4505
+ setPendingFocusId(null);
4506
+ setFocusMissing(false);
4507
+ if (!focusMessageId || loading) return;
4508
+ return jumpTo(focusMessageId, true);
4509
+ }, [focusMessageId, conversationId, loading, jumpTo]);
4510
+ react.useEffect(() => {
4511
+ if (!pendingFocusId) return;
4512
+ setPendingFocusId(null);
4513
+ if (!visibleMessages.some((m) => m.id === pendingFocusId)) {
4514
+ focusMiss(pendingFocusId, true);
4515
+ return;
4516
+ }
4517
+ setJump((prev) => ({ id: pendingFocusId, request: (prev?.request ?? 0) + 1 }));
4518
+ setHighlightId(pendingFocusId);
4519
+ }, [pendingFocusId, visibleMessages, focusMiss]);
4520
+ react.useEffect(() => {
4521
+ if (!highlightId) return;
4522
+ const t = setTimeout(() => setHighlightId(null), 1600);
4523
+ return () => clearTimeout(t);
4524
+ }, [highlightId]);
4525
+ react.useEffect(() => {
4526
+ if (!focusMissing) return;
4527
+ const t = setTimeout(() => setFocusMissing(false), 4e3);
4528
+ return () => clearTimeout(t);
4529
+ }, [focusMissing]);
4530
+ const onQuotedClick = react.useCallback((id) => void jumpTo(id, false), [jumpTo]);
4389
4531
  const groupPositionById = react.useMemo(() => {
4390
4532
  const map = /* @__PURE__ */ new Map();
4391
4533
  for (let i = 0; i < visibleMessages.length; i++) {
@@ -4413,7 +4555,7 @@ function ConversationView({
4413
4555
  insertedAt: msg.inserted_at
4414
4556
  });
4415
4557
  const groupPosition = groupPositionById.get(msg.id) ?? "standalone";
4416
- return /* @__PURE__ */ jsxRuntime.jsx(
4558
+ const row = /* @__PURE__ */ jsxRuntime.jsx(
4417
4559
  MessageRow,
4418
4560
  {
4419
4561
  msg,
@@ -4422,15 +4564,18 @@ function ConversationView({
4422
4564
  attachments,
4423
4565
  actions,
4424
4566
  threads,
4425
- quotations,
4567
+ quotations: canQuote,
4426
4568
  ...readState ? { readState } : {},
4427
4569
  isEditing: editingId === msg.id,
4428
4570
  ...canEdit ? { onStartEdit: () => setEditingId(msg.id) } : {},
4429
4571
  onDelete: () => deleteMsg(msg.id),
4430
4572
  ...threads ? { onOpenThread: () => setThreadRoot(msg) } : {},
4431
- ...quotations ? { onQuote: () => setReplyingTo(msg) } : {},
4573
+ ...canQuote ? { onQuote: () => setReplyingTo(msg) } : {},
4574
+ onQuotedClick,
4432
4575
  ...labelFor ? { labelFor } : {},
4433
4576
  ...avatarFor ? { avatarFor } : {},
4577
+ ...onSenderPress ? { onSenderPress } : {},
4578
+ ...onAvatarPress ? { onAvatarPress } : {},
4434
4579
  showSenderName: showSenderLabels,
4435
4580
  showAvatar: showAvatars,
4436
4581
  maxBodyLength,
@@ -4439,12 +4584,19 @@ function ConversationView({
4439
4584
  ...onCallBack ? { onCallBack } : {}
4440
4585
  }
4441
4586
  );
4587
+ if (msg.id !== highlightId) return row;
4588
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: { backgroundColor: theme.colors.brandSoft }, children: row });
4442
4589
  },
4443
4590
  [
4444
4591
  onCallBack,
4592
+ onQuotedClick,
4593
+ onSenderPress,
4594
+ onAvatarPress,
4595
+ highlightId,
4596
+ theme.colors.brandSoft,
4597
+ canQuote,
4445
4598
  renderMessage,
4446
4599
  meId,
4447
- readReceipts,
4448
4600
  showReadState,
4449
4601
  receiptsVisible,
4450
4602
  members,
@@ -4452,7 +4604,6 @@ function ConversationView({
4452
4604
  attachments,
4453
4605
  actions,
4454
4606
  threads,
4455
- quotations,
4456
4607
  editingId,
4457
4608
  deleteMsg,
4458
4609
  labelFor,
@@ -4540,6 +4691,17 @@ function ConversationView({
4540
4691
  keyboardVerticalOffset: keyboardOffset,
4541
4692
  children: [
4542
4693
  headerNode,
4694
+ focusMissing ? /* @__PURE__ */ jsxRuntime.jsx(
4695
+ reactNative.Text,
4696
+ {
4697
+ style: [
4698
+ styles22.notice,
4699
+ { color: theme.colors.ink2, backgroundColor: theme.colors.surface2 }
4700
+ ],
4701
+ accessibilityRole: "alert",
4702
+ children: "That message isn't available."
4703
+ }
4704
+ ) : null,
4543
4705
  onJoinCall ? /* @__PURE__ */ jsxRuntime.jsx(
4544
4706
  JoinBanner,
4545
4707
  {
@@ -4560,6 +4722,8 @@ function ConversationView({
4560
4722
  hasMore,
4561
4723
  onLoadMore: loadMore,
4562
4724
  renderItem,
4725
+ scrollToMessageId: jump?.id ?? null,
4726
+ scrollRequest: jump?.request ?? 0,
4563
4727
  ListHeader: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { children: [
4564
4728
  visibleStreams.map(
4565
4729
  (stream) => stream.status === "failed" ? /* @__PURE__ */ jsxRuntime.jsx(
@@ -4603,8 +4767,8 @@ function ConversationView({
4603
4767
  }
4604
4768
  ) : null
4605
4769
  ] }),
4606
- mentions ? /* @__PURE__ */ jsxRuntime.jsx(MentionInput, { conversationId, ...composerProps }) : /* @__PURE__ */ jsxRuntime.jsx(MessageComposer, { ...composerProps }),
4607
- attachments ? /* @__PURE__ */ jsxRuntime.jsx(AttachmentPicker, { visible: pickerOpen, onClose: () => setPickerOpen(false) }) : null,
4770
+ !showComposer ? null : mentions ? /* @__PURE__ */ jsxRuntime.jsx(MentionInput, { conversationId, ...composerProps }) : /* @__PURE__ */ jsxRuntime.jsx(MessageComposer, { ...composerProps }),
4771
+ canAttach ? /* @__PURE__ */ jsxRuntime.jsx(AttachmentPicker, { visible: pickerOpen, onClose: () => setPickerOpen(false) }) : null,
4608
4772
  threads && threadRoot ? /* @__PURE__ */ jsxRuntime.jsx(
4609
4773
  ThreadView,
4610
4774
  {
@@ -4647,6 +4811,12 @@ var styles22 = reactNative.StyleSheet.create({
4647
4811
  root: {
4648
4812
  flex: 1
4649
4813
  },
4814
+ notice: {
4815
+ fontSize: 12,
4816
+ fontWeight: "600",
4817
+ paddingHorizontal: 16,
4818
+ paddingVertical: 8
4819
+ },
4650
4820
  streamFailed: {
4651
4821
  fontSize: 12,
4652
4822
  marginHorizontal: 16,