organify-ui 0.3.33 → 0.3.36
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.
|
@@ -2931,8 +2931,11 @@ function useChat(options = {}) {
|
|
|
2931
2931
|
useEffect(() => {
|
|
2932
2932
|
setUserCache((prev) => {
|
|
2933
2933
|
const next = new Map(prev);
|
|
2934
|
-
if (userId
|
|
2935
|
-
|
|
2934
|
+
if (userId) {
|
|
2935
|
+
const existingDisplay = prev.get(userId)?.displayName;
|
|
2936
|
+
const hasRealName = existingDisplay && !existingDisplay.startsWith("User ");
|
|
2937
|
+
const displayName = user?.name || user?.email?.split("@")[0] || (hasRealName ? existingDisplay : `User ${userId.substring(0, 5)}`);
|
|
2938
|
+
next.set(userId, { displayName, avatarUrl: user?.avatarUrl ?? prev.get(userId)?.avatarUrl });
|
|
2936
2939
|
}
|
|
2937
2940
|
if (options.workspaceMembers) {
|
|
2938
2941
|
for (const member of options.workspaceMembers) {
|
|
@@ -2947,6 +2950,42 @@ function useChat(options = {}) {
|
|
|
2947
2950
|
return next;
|
|
2948
2951
|
});
|
|
2949
2952
|
}, [userId, user, options.workspaceMembers]);
|
|
2953
|
+
const GET_USER_SNAPSHOT = `
|
|
2954
|
+
query GetUserSnapshot($id: String!) {
|
|
2955
|
+
userSnapshot(id: $id) {
|
|
2956
|
+
id name avatarUrl email
|
|
2957
|
+
}
|
|
2958
|
+
}
|
|
2959
|
+
`;
|
|
2960
|
+
useEffect(() => {
|
|
2961
|
+
if (!userId || isDemoMode) return;
|
|
2962
|
+
const missingIds = Array.from(new Set(messages.map((m) => m.authorId))).filter(
|
|
2963
|
+
// Skip: already cached, system messages, and the current user (handled by the cache-populate effect above)
|
|
2964
|
+
(id) => !userCache.has(id) && id !== "system" && id !== userId
|
|
2965
|
+
);
|
|
2966
|
+
if (missingIds.length === 0) return;
|
|
2967
|
+
missingIds.forEach(async (id) => {
|
|
2968
|
+
setUserCache((prev) => {
|
|
2969
|
+
const next = new Map(prev);
|
|
2970
|
+
if (!next.has(id)) next.set(id, { displayName: `User ${id.substring(0, 5)}` });
|
|
2971
|
+
return next;
|
|
2972
|
+
});
|
|
2973
|
+
try {
|
|
2974
|
+
const data = await centralGql("workspaces", GET_USER_SNAPSHOT, { id });
|
|
2975
|
+
if (data?.userSnapshot) {
|
|
2976
|
+
setUserCache((prev) => {
|
|
2977
|
+
const next = new Map(prev);
|
|
2978
|
+
next.set(id, {
|
|
2979
|
+
displayName: data.userSnapshot.name || data.userSnapshot.email || `User ${id.substring(0, 5)}`,
|
|
2980
|
+
avatarUrl: data.userSnapshot.avatarUrl || void 0
|
|
2981
|
+
});
|
|
2982
|
+
return next;
|
|
2983
|
+
});
|
|
2984
|
+
}
|
|
2985
|
+
} catch (err) {
|
|
2986
|
+
}
|
|
2987
|
+
});
|
|
2988
|
+
}, [messages, userCache, userId, isDemoMode, centralGql]);
|
|
2950
2989
|
const fetchRooms = useCallback(async () => {
|
|
2951
2990
|
if (initialRooms && initialRooms.length > 0) return;
|
|
2952
2991
|
if (!workspaceId || workspaceId.startsWith("temp-")) return;
|
|
@@ -3130,7 +3169,7 @@ function useChat(options = {}) {
|
|
|
3130
3169
|
);
|
|
3131
3170
|
if (data?.sendMessage) {
|
|
3132
3171
|
setMessages(
|
|
3133
|
-
(prev) => prev.map((m) => m.id === tempId ? { ...
|
|
3172
|
+
(prev) => prev.map((m) => m.id === tempId ? { ...m, _status: "sent" } : m)
|
|
3134
3173
|
);
|
|
3135
3174
|
} else {
|
|
3136
3175
|
setMessages(
|
|
@@ -3525,8 +3564,8 @@ function useChat(options = {}) {
|
|
|
3525
3564
|
useEffect(() => {
|
|
3526
3565
|
if (!userId || !activeRoomId) return;
|
|
3527
3566
|
if (isDemoMode) return;
|
|
3528
|
-
const
|
|
3529
|
-
const wsUrl =
|
|
3567
|
+
const baseUrl = api?.services?.chat || typeof process !== "undefined" && process.env.NEXT_PUBLIC_GATEWAY_URL || "https://organify-gateway-service.onrender.com";
|
|
3568
|
+
const wsUrl = baseUrl.replace(/^http/, "ws") + "/graphql/chat";
|
|
3530
3569
|
let ws = null;
|
|
3531
3570
|
let pingInterval;
|
|
3532
3571
|
let reconnectTimer;
|
|
@@ -3604,18 +3643,20 @@ function useChat(options = {}) {
|
|
|
3604
3643
|
case "next":
|
|
3605
3644
|
if (msg.id === "sub_msg_created" && msg.payload?.data?.messageCreated) {
|
|
3606
3645
|
const newMsg = msg.payload.data.messageCreated;
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3646
|
+
setMessages((prev) => {
|
|
3647
|
+
if (prev.some((m) => m.id === newMsg.id)) return prev;
|
|
3648
|
+
if (String(newMsg.authorId) === String(userId)) {
|
|
3649
|
+
const ownIdx = prev.findIndex(
|
|
3650
|
+
(m) => (m._status === "pending" || m._status === "sent") && m.content === newMsg.content && String(m.authorId) === String(newMsg.authorId)
|
|
3651
|
+
);
|
|
3652
|
+
if (ownIdx !== -1) {
|
|
3653
|
+
const next = [...prev];
|
|
3654
|
+
next[ownIdx] = { ...newMsg, _status: "sent" };
|
|
3655
|
+
return next;
|
|
3656
|
+
}
|
|
3657
|
+
}
|
|
3658
|
+
return [...prev, newMsg];
|
|
3659
|
+
});
|
|
3619
3660
|
}
|
|
3620
3661
|
if (msg.id === "sub_msg_updated" && msg.payload?.data?.messageUpdated) {
|
|
3621
3662
|
const updated = msg.payload.data.messageUpdated;
|
|
@@ -4708,5 +4749,5 @@ function useAiInline({ gatewayUrl, workspaceId, projectId }) {
|
|
|
4708
4749
|
}
|
|
4709
4750
|
|
|
4710
4751
|
export { AiChatSidebar, Alert, Button, ChatMessages, ChatSidebar, CommandBar, CreateRoomDialog, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, InlineAiButton, Input, Label, MOCK_PROJECTS, MOCK_USERS, MentionPopover, MessageBubble, MessageInput, OrgLoader, OrgLoaderInline, OrganifyChat, ResponsiveDialog, RoomManagementPanel, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, TypingIndicatorMock, UserAvatar, UserDisplayName, alertVariants, buttonVariants, generateAutoReplies, getMockMentionOptions, getRoomPermissions, inputVariants, invalidateUserCache, orgLoaderVariants, resolveUser, seedUserCache, typingIndicator, useAiInline, useChat, useResolvedUser };
|
|
4711
|
-
//# sourceMappingURL=chunk-
|
|
4712
|
-
//# sourceMappingURL=chunk-
|
|
4752
|
+
//# sourceMappingURL=chunk-V3UZIPZA.js.map
|
|
4753
|
+
//# sourceMappingURL=chunk-V3UZIPZA.js.map
|