@poolse/react-native 2.0.6 → 2.0.7

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 { useMe, useConversations, useUser, 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: [
@@ -2849,8 +2850,9 @@ function MessageRow({
2849
2850
  });
2850
2851
  const showAvatarSlot = showAvatar && !isSelf;
2851
2852
  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;
2853
+ const rowSender = useUser(showAvatarSlot ? msg.sender_external_id : null);
2854
+ const avatarUrl = msg.sender_external_id ? avatarFor?.(msg.sender_external_id) ?? rowSender.profile?.avatarUrl ?? null : null;
2855
+ const senderLabel = msg.sender_external_id ? labelFor?.(msg.sender_external_id) ?? rowSender.profile?.displayName ?? msg.sender_external_id : null;
2854
2856
  return /* @__PURE__ */ jsxs(View, { style: [styles17.row, { alignSelf: isSelf ? "flex-end" : "flex-start" }], children: [
2855
2857
  showAvatarSlot ? /* @__PURE__ */ jsx(View, { style: styles17.avatarSlot, children: showAvatarRender ? /* @__PURE__ */ jsx(
2856
2858
  Avatar,
@@ -4243,8 +4245,9 @@ function DefaultConversationRow({
4243
4245
  const theme = usePoolseTheme();
4244
4246
  const isDirect = conv.type === "direct";
4245
4247
  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;
4248
+ const resolvedOther = useUser(isDirect ? otherExtId ?? null : null);
4249
+ const title = isDirect ? otherExtId ? labelFor?.(otherExtId) ?? resolvedOther.profile?.displayName ?? otherExtId : "Direct chat" : conv.name ?? "Untitled group";
4250
+ const avatarUrl = isDirect && otherExtId ? avatarFor?.(otherExtId) ?? resolvedOther.profile?.avatarUrl ?? null : null;
4248
4251
  const avatarSeed = isDirect ? otherExtId ?? conv.id : conv.id;
4249
4252
  return /* @__PURE__ */ jsxs(
4250
4253
  Pressable,