@poolse/react-native 2.0.6 → 2.0.8

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useMe, useConversations, useAttachmentUpload, useConversation, useMembers, usePresence, useUser, useMessages, useTyping, useReactions, useThread, useAttachmentUrl, usePoolse } from '@poolse/react';
1
+ import { useUser, useMe, useConversations, useAttachmentUpload, useConversation, useMembers, usePresence, useMessages, useTyping, useReactions, useThread, useAttachmentUrl, usePoolse } from '@poolse/react';
2
2
  import { createContext, forwardRef, useRef, useState, useImperativeHandle, useEffect, useMemo, useCallback, useContext } from 'react';
3
3
  import { StyleSheet, View, Pressable, TextInput, Text, useWindowDimensions, Animated, Easing, PanResponder, Image, ScrollView, ActivityIndicator, FlatList, KeyboardAvoidingView, Platform, Modal, Dimensions, AppState } from 'react-native';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
@@ -488,18 +488,16 @@ function MemberList({
488
488
  style: { backgroundColor: theme.colors.paper },
489
489
  renderItem: ({ item }) => {
490
490
  if (renderItem) return /* @__PURE__ */ jsx(Fragment, { children: renderItem(item) });
491
- const name = labelFor?.(item.external_id) ?? item.external_id;
492
- const avatarUrl = avatarFor?.(item.external_id) ?? null;
493
491
  const isOnline = effectiveOnline.has(item.external_id);
494
492
  const showRemove = canRemove?.(item) ?? false;
495
493
  return /* @__PURE__ */ jsx(
496
494
  MemberRow,
497
495
  {
498
- name,
499
496
  externalId: item.external_id,
500
- avatarUrl,
501
497
  role: item.role,
502
498
  online: isOnline,
499
+ ...labelFor ? { labelFor } : {},
500
+ ...avatarFor ? { avatarFor } : {},
503
501
  ...showRemove ? { onRemove: () => removeMember(item.external_id) } : {}
504
502
  }
505
503
  );
@@ -508,14 +506,17 @@ function MemberList({
508
506
  );
509
507
  }
510
508
  function MemberRow({
511
- name,
512
509
  externalId,
513
- avatarUrl,
514
510
  role,
515
511
  online,
512
+ labelFor,
513
+ avatarFor,
516
514
  onRemove
517
515
  }) {
518
516
  const theme = usePoolseTheme();
517
+ const resolved = useUser(externalId);
518
+ const name = labelFor?.(externalId) ?? resolved.profile?.displayName ?? externalId;
519
+ const avatarUrl = avatarFor?.(externalId) ?? resolved.profile?.avatarUrl ?? null;
519
520
  return /* @__PURE__ */ jsxs(View, { style: styles2.row, children: [
520
521
  /* @__PURE__ */ jsx(Avatar, { src: avatarUrl, name, seed: externalId, online, size: "md" }),
521
522
  /* @__PURE__ */ jsxs(View, { style: styles2.body, children: [
@@ -1534,7 +1535,8 @@ function ReplyChip({
1534
1535
  onCancel
1535
1536
  }) {
1536
1537
  const theme = usePoolseTheme();
1537
- const senderName = message.sender_external_id ? labelFor?.(message.sender_external_id) ?? message.sender_external_id : "Unknown";
1538
+ const resolved = useUser(message.sender_external_id);
1539
+ const senderName = message.sender_external_id ? labelFor?.(message.sender_external_id) ?? resolved.profile?.displayName ?? message.sender_external_id : "Unknown";
1538
1540
  return /* @__PURE__ */ jsxs(
1539
1541
  View,
1540
1542
  {
@@ -2499,7 +2501,8 @@ function QuotedCard({
2499
2501
  onPress
2500
2502
  }) {
2501
2503
  const theme = usePoolseTheme();
2502
- const senderName = quoted.sender_external_id ? labelFor?.(quoted.sender_external_id) ?? quoted.sender_external_id : "Unknown";
2504
+ const resolved = useUser(quoted.sender_external_id);
2505
+ const senderName = quoted.sender_external_id ? labelFor?.(quoted.sender_external_id) ?? resolved.profile?.displayName ?? quoted.sender_external_id : "Unknown";
2503
2506
  const bg = isSelf ? "rgba(255,255,255,0.18)" : theme.colors.surface2;
2504
2507
  const accent = isSelf ? theme.colors.onBrand : theme.colors.brand;
2505
2508
  const txt = isSelf ? theme.colors.onBrand : theme.colors.ink;
@@ -2849,8 +2852,9 @@ function MessageRow({
2849
2852
  });
2850
2853
  const showAvatarSlot = showAvatar && !isSelf;
2851
2854
  const showAvatarRender = showAvatarSlot && (groupPosition === "last" || groupPosition === "standalone");
2852
- const avatarUrl = avatarFor && msg.sender_external_id ? avatarFor(msg.sender_external_id) : null;
2853
- const senderLabel = msg.sender_external_id && labelFor ? labelFor(msg.sender_external_id) : msg.sender_external_id ?? null;
2855
+ const rowSender = useUser(showAvatarSlot ? msg.sender_external_id : null);
2856
+ const avatarUrl = msg.sender_external_id ? avatarFor?.(msg.sender_external_id) ?? rowSender.profile?.avatarUrl ?? null : null;
2857
+ const senderLabel = msg.sender_external_id ? labelFor?.(msg.sender_external_id) ?? rowSender.profile?.displayName ?? msg.sender_external_id : null;
2854
2858
  return /* @__PURE__ */ jsxs(View, { style: [styles17.row, { alignSelf: isSelf ? "flex-end" : "flex-start" }], children: [
2855
2859
  showAvatarSlot ? /* @__PURE__ */ jsx(View, { style: styles17.avatarSlot, children: showAvatarRender ? /* @__PURE__ */ jsx(
2856
2860
  Avatar,
@@ -4243,8 +4247,9 @@ function DefaultConversationRow({
4243
4247
  const theme = usePoolseTheme();
4244
4248
  const isDirect = conv.type === "direct";
4245
4249
  const otherExtId = isDirect && meExternalId ? (conv.member_external_ids ?? []).find((x) => x !== meExternalId) : null;
4246
- const title = isDirect ? otherExtId ? labelFor?.(otherExtId) ?? otherExtId : "Direct chat" : conv.name ?? "Untitled group";
4247
- const avatarUrl = isDirect && otherExtId ? avatarFor?.(otherExtId) ?? null : null;
4250
+ const resolvedOther = useUser(isDirect ? otherExtId ?? null : null);
4251
+ const title = isDirect ? otherExtId ? labelFor?.(otherExtId) ?? resolvedOther.profile?.displayName ?? otherExtId : "Direct chat" : conv.name ?? "Untitled group";
4252
+ const avatarUrl = isDirect && otherExtId ? avatarFor?.(otherExtId) ?? resolvedOther.profile?.avatarUrl ?? null : null;
4248
4253
  const avatarSeed = isDirect ? otherExtId ?? conv.id : conv.id;
4249
4254
  return /* @__PURE__ */ jsxs(
4250
4255
  Pressable,