@poolse/react-native 2.0.9 → 2.0.11
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 +65 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +65 -28
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -433,8 +433,15 @@ interface ConversationListProps {
|
|
|
433
433
|
error?: Error | null;
|
|
434
434
|
/** Per-conversation unread counts rendered as a Pulse Coral pill. */
|
|
435
435
|
unreadCounts?: Record<Uuid, number>;
|
|
436
|
+
/**
|
|
437
|
+
* Explicit overrides for direct-chat names + avatars, keyed by the
|
|
438
|
+
* OTHER member's external_id. When omitted, the row falls back to
|
|
439
|
+
* `PoolseConfig.userResolver` and finally to the external_id.
|
|
440
|
+
*/
|
|
441
|
+
labelFor?: (externalId: string) => string;
|
|
442
|
+
avatarFor?: (externalId: string) => string | null;
|
|
436
443
|
}
|
|
437
|
-
declare function ConversationList({ selectedId, onSelect, renderItem, emptyState, conversations: controlled, loading: controlledLoading, error: controlledError, unreadCounts, }: ConversationListProps): react_jsx_runtime.JSX.Element;
|
|
444
|
+
declare function ConversationList({ selectedId, onSelect, renderItem, emptyState, conversations: controlled, loading: controlledLoading, error: controlledError, unreadCounts, labelFor, avatarFor, }: ConversationListProps): react_jsx_runtime.JSX.Element;
|
|
438
445
|
|
|
439
446
|
interface MemberListProps {
|
|
440
447
|
conversationId: Uuid;
|
package/dist/index.d.ts
CHANGED
|
@@ -433,8 +433,15 @@ interface ConversationListProps {
|
|
|
433
433
|
error?: Error | null;
|
|
434
434
|
/** Per-conversation unread counts rendered as a Pulse Coral pill. */
|
|
435
435
|
unreadCounts?: Record<Uuid, number>;
|
|
436
|
+
/**
|
|
437
|
+
* Explicit overrides for direct-chat names + avatars, keyed by the
|
|
438
|
+
* OTHER member's external_id. When omitted, the row falls back to
|
|
439
|
+
* `PoolseConfig.userResolver` and finally to the external_id.
|
|
440
|
+
*/
|
|
441
|
+
labelFor?: (externalId: string) => string;
|
|
442
|
+
avatarFor?: (externalId: string) => string | null;
|
|
436
443
|
}
|
|
437
|
-
declare function ConversationList({ selectedId, onSelect, renderItem, emptyState, conversations: controlled, loading: controlledLoading, error: controlledError, unreadCounts, }: ConversationListProps): react_jsx_runtime.JSX.Element;
|
|
444
|
+
declare function ConversationList({ selectedId, onSelect, renderItem, emptyState, conversations: controlled, loading: controlledLoading, error: controlledError, unreadCounts, labelFor, avatarFor, }: ConversationListProps): react_jsx_runtime.JSX.Element;
|
|
438
445
|
|
|
439
446
|
interface MemberListProps {
|
|
440
447
|
conversationId: Uuid;
|
package/dist/index.js
CHANGED
|
@@ -933,10 +933,14 @@ function ConversationList({
|
|
|
933
933
|
conversations: controlled,
|
|
934
934
|
loading: controlledLoading,
|
|
935
935
|
error: controlledError,
|
|
936
|
-
unreadCounts
|
|
936
|
+
unreadCounts,
|
|
937
|
+
labelFor,
|
|
938
|
+
avatarFor
|
|
937
939
|
}) {
|
|
938
940
|
const theme = usePoolseTheme();
|
|
939
941
|
const auto = useConversations();
|
|
942
|
+
const { me } = useMe();
|
|
943
|
+
const meExternalId = me?.external_id ?? null;
|
|
940
944
|
const isControlled = controlled !== void 0;
|
|
941
945
|
const conversations = isControlled ? controlled : auto.conversations;
|
|
942
946
|
const loading = isControlled ? controlledLoading ?? false : auto.loading;
|
|
@@ -962,38 +966,66 @@ function ConversationList({
|
|
|
962
966
|
if (renderItem) {
|
|
963
967
|
return /* @__PURE__ */ jsx(Fragment, { children: renderItem(item, selected) });
|
|
964
968
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
Pressable,
|
|
969
|
+
return /* @__PURE__ */ jsx(
|
|
970
|
+
ConversationRow,
|
|
968
971
|
{
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
children: [
|
|
977
|
-
/* @__PURE__ */ jsx(Avatar, { src: null, name: item.name ?? null, seed: item.id, size: "md" }),
|
|
978
|
-
/* @__PURE__ */ jsxs(View, { style: styles5.body, children: [
|
|
979
|
-
/* @__PURE__ */ jsx(
|
|
980
|
-
Text,
|
|
981
|
-
{
|
|
982
|
-
style: [styles5.name, { color: theme.colors.ink, fontFamily: theme.type.fontBody }],
|
|
983
|
-
numberOfLines: 1,
|
|
984
|
-
children: item.name ?? "Untitled conversation"
|
|
985
|
-
}
|
|
986
|
-
),
|
|
987
|
-
item.last_message_at ? /* @__PURE__ */ jsx(Text, { style: [styles5.preview, { color: theme.colors.ink3 }], numberOfLines: 1, children: formatRelative(item.last_message_at) }) : null
|
|
988
|
-
] }),
|
|
989
|
-
unread > 0 ? /* @__PURE__ */ jsx(View, { style: [styles5.unreadPill, { backgroundColor: theme.colors.unreadPill }], children: /* @__PURE__ */ jsx(Text, { style: [styles5.unreadText, { color: theme.colors.unreadPillText }], children: unread > 99 ? "99+" : String(unread) }) }) : null
|
|
990
|
-
]
|
|
972
|
+
conv: item,
|
|
973
|
+
selected,
|
|
974
|
+
meExternalId,
|
|
975
|
+
unread: counts?.[item.id] ?? 0,
|
|
976
|
+
...labelFor ? { labelFor } : {},
|
|
977
|
+
...avatarFor ? { avatarFor } : {},
|
|
978
|
+
...onSelect ? { onSelect } : {}
|
|
991
979
|
}
|
|
992
980
|
);
|
|
993
981
|
}
|
|
994
982
|
}
|
|
995
983
|
);
|
|
996
984
|
}
|
|
985
|
+
function ConversationRow({
|
|
986
|
+
conv,
|
|
987
|
+
selected,
|
|
988
|
+
meExternalId,
|
|
989
|
+
unread,
|
|
990
|
+
labelFor,
|
|
991
|
+
avatarFor,
|
|
992
|
+
onSelect
|
|
993
|
+
}) {
|
|
994
|
+
const theme = usePoolseTheme();
|
|
995
|
+
const isDirect = conv.type === "direct";
|
|
996
|
+
const otherExtId = isDirect && meExternalId ? (conv.member_external_ids ?? []).find((x) => x !== meExternalId) ?? null : null;
|
|
997
|
+
const resolvedOther = useUser(isDirect ? otherExtId : null);
|
|
998
|
+
const title = isDirect ? otherExtId ? labelFor?.(otherExtId) ?? resolvedOther.profile?.displayName ?? otherExtId : "Direct chat" : conv.name ?? "Untitled conversation";
|
|
999
|
+
const avatarUrl = isDirect && otherExtId ? avatarFor?.(otherExtId) ?? resolvedOther.profile?.avatarUrl ?? null : null;
|
|
1000
|
+
const avatarSeed = isDirect ? otherExtId ?? conv.id : conv.id;
|
|
1001
|
+
return /* @__PURE__ */ jsxs(
|
|
1002
|
+
Pressable,
|
|
1003
|
+
{
|
|
1004
|
+
onPress: () => onSelect?.(conv),
|
|
1005
|
+
style: [
|
|
1006
|
+
styles5.row,
|
|
1007
|
+
{
|
|
1008
|
+
backgroundColor: selected ? theme.colors.surface2 : "transparent"
|
|
1009
|
+
}
|
|
1010
|
+
],
|
|
1011
|
+
children: [
|
|
1012
|
+
avatarUrl ? /* @__PURE__ */ jsx(Image, { source: { uri: avatarUrl }, style: styles5.rowAvatar }) : /* @__PURE__ */ jsx(Avatar, { src: null, name: title, seed: avatarSeed, size: "md" }),
|
|
1013
|
+
/* @__PURE__ */ jsxs(View, { style: styles5.body, children: [
|
|
1014
|
+
/* @__PURE__ */ jsx(
|
|
1015
|
+
Text,
|
|
1016
|
+
{
|
|
1017
|
+
style: [styles5.name, { color: theme.colors.ink, fontFamily: theme.type.fontBody }],
|
|
1018
|
+
numberOfLines: 1,
|
|
1019
|
+
children: title
|
|
1020
|
+
}
|
|
1021
|
+
),
|
|
1022
|
+
conv.last_message_preview ? /* @__PURE__ */ jsx(Text, { style: [styles5.preview, { color: theme.colors.ink3 }], numberOfLines: 1, children: conv.last_message_preview }) : conv.last_message_at ? /* @__PURE__ */ jsx(Text, { style: [styles5.preview, { color: theme.colors.ink3 }], numberOfLines: 1, children: formatRelative(conv.last_message_at) }) : null
|
|
1023
|
+
] }),
|
|
1024
|
+
unread > 0 ? /* @__PURE__ */ jsx(View, { style: [styles5.unreadPill, { backgroundColor: theme.colors.unreadPill }], children: /* @__PURE__ */ jsx(Text, { style: [styles5.unreadText, { color: theme.colors.unreadPillText }], children: unread > 99 ? "99+" : String(unread) }) }) : null
|
|
1025
|
+
]
|
|
1026
|
+
}
|
|
1027
|
+
);
|
|
1028
|
+
}
|
|
997
1029
|
function formatRelative(iso) {
|
|
998
1030
|
try {
|
|
999
1031
|
const d = new Date(iso);
|
|
@@ -1021,6 +1053,11 @@ var styles5 = StyleSheet.create({
|
|
|
1021
1053
|
paddingVertical: 10,
|
|
1022
1054
|
gap: 10
|
|
1023
1055
|
},
|
|
1056
|
+
rowAvatar: {
|
|
1057
|
+
width: 40,
|
|
1058
|
+
height: 40,
|
|
1059
|
+
borderRadius: 20
|
|
1060
|
+
},
|
|
1024
1061
|
body: {
|
|
1025
1062
|
flex: 1,
|
|
1026
1063
|
gap: 2
|
|
@@ -1767,10 +1804,10 @@ function MessageList({
|
|
|
1767
1804
|
renderItem: handleRender,
|
|
1768
1805
|
onEndReached: hasMore ? onLoadMore : void 0,
|
|
1769
1806
|
onEndReachedThreshold: 0.3,
|
|
1770
|
-
ListHeaderComponent:
|
|
1807
|
+
ListHeaderComponent: ListHeader,
|
|
1771
1808
|
ListFooterComponent: /* @__PURE__ */ jsxs(View, { children: [
|
|
1772
1809
|
hasMore && loading ? /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.colors.ink3, style: { marginVertical: 8 } }) : null,
|
|
1773
|
-
|
|
1810
|
+
ListFooter
|
|
1774
1811
|
] }),
|
|
1775
1812
|
style: { backgroundColor: theme.colors.paper },
|
|
1776
1813
|
contentContainerStyle: { paddingVertical: 8 }
|