nucleus-core-ts 0.9.168 → 0.9.169
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/fe/components/ChatPanel/components/MessageThread.js +10 -0
- package/dist/fe/components/ChatPanel/hooks/useChat.d.ts +1 -0
- package/dist/fe/components/ChatPanel/hooks/useChat.js +5 -0
- package/dist/fe/components/ChatPanel/store/index.d.ts +1 -0
- package/dist/fe/components/ChatPanel/store/index.js +11 -0
- package/dist/fe/components/ChatPanel/theme/index.d.ts +2 -0
- package/dist/fe/components/ChatPanel/theme/index.js +3 -1
- package/package.json +1 -1
|
@@ -38,6 +38,11 @@ export function MessageThread({ conversation, messages, currentUserId, typing, h
|
|
|
38
38
|
const title = conversationTitle(conversation, currentUserId, resolveUserName);
|
|
39
39
|
const activeParticipants = conversation.participants.filter((p)=>!p.leftAt);
|
|
40
40
|
const subtitle = conversation.type === 'group' ? `${activeParticipants.length} participants` : undefined;
|
|
41
|
+
const otherReaders = conversation.participants.filter((p)=>p.userId !== currentUserId && !p.leftAt);
|
|
42
|
+
const isReadByOthers = (message)=>{
|
|
43
|
+
const created = Date.parse(message.createdAt);
|
|
44
|
+
return otherReaders.some((p)=>p.lastReadAt != null && Date.parse(p.lastReadAt) >= created);
|
|
45
|
+
};
|
|
41
46
|
const typingUsers = typing.filter((t)=>t.conversationId === conversation.id && Date.now() - t.at < 6000);
|
|
42
47
|
const typingLabel = typingUsers.length === 1 ? `${resolveUserName?.(typingUsers[0]?.userId ?? '') ?? 'Someone'} is typing` : 'Several people are typing';
|
|
43
48
|
return /*#__PURE__*/ _jsxs("div", {
|
|
@@ -105,6 +110,11 @@ export function MessageThread({ conversation, messages, currentUserId, typing, h
|
|
|
105
110
|
message.editedAt && /*#__PURE__*/ _jsx("span", {
|
|
106
111
|
className: theme.message.edited,
|
|
107
112
|
children: "· edited"
|
|
113
|
+
}),
|
|
114
|
+
own && !message.deletedAt && /*#__PURE__*/ _jsx("span", {
|
|
115
|
+
className: cn(theme.message.receipt, isReadByOthers(message) && theme.message.receiptRead),
|
|
116
|
+
title: isReadByOthers(message) ? 'Görüldü' : 'Gönderildi',
|
|
117
|
+
children: isReadByOthers(message) ? '✓✓' : '✓'
|
|
108
118
|
})
|
|
109
119
|
]
|
|
110
120
|
})
|
|
@@ -22,6 +22,7 @@ export declare function useChat(props: ChatPanelProps): {
|
|
|
22
22
|
clearTyping: (conversationId: string, userId: string) => void;
|
|
23
23
|
resetUnread: (conversationId: string) => void;
|
|
24
24
|
incrementUnread: (conversationId: string) => void;
|
|
25
|
+
applyRead: (conversationId: string, userId: string, lastReadMessageId: string | null) => void;
|
|
25
26
|
bumpConversationPreview: (conversationId: string, preview: string, at: string) => void;
|
|
26
27
|
reset: () => void;
|
|
27
28
|
}>;
|
|
@@ -222,6 +222,11 @@ export function useChat(props) {
|
|
|
222
222
|
case 'conversation.created':
|
|
223
223
|
if (payload.conversation) store.upsertConversation(payload.conversation);
|
|
224
224
|
break;
|
|
225
|
+
case 'conversation.read':
|
|
226
|
+
if (payload.conversationId && payload.userId) {
|
|
227
|
+
store.applyRead(payload.conversationId, payload.userId, payload.lastReadMessageId ?? null);
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
225
230
|
case 'participant.removed':
|
|
226
231
|
if (payload.userId === currentUserId) loadConversations();
|
|
227
232
|
break;
|
|
@@ -19,6 +19,7 @@ type ChatPanelMethods = {
|
|
|
19
19
|
clearTyping: (conversationId: string, userId: string) => void;
|
|
20
20
|
resetUnread: (conversationId: string) => void;
|
|
21
21
|
incrementUnread: (conversationId: string) => void;
|
|
22
|
+
applyRead: (conversationId: string, userId: string, lastReadMessageId: string | null) => void;
|
|
22
23
|
bumpConversationPreview: (conversationId: string, preview: string, at: string) => void;
|
|
23
24
|
reset: () => void;
|
|
24
25
|
};
|
|
@@ -112,6 +112,17 @@ export const { useStore: useChatStore } = createStore(initialState, {
|
|
|
112
112
|
} : c.myParticipant
|
|
113
113
|
} : c);
|
|
114
114
|
},
|
|
115
|
+
applyRead: (store)=>(conversationId, userId, lastReadMessageId)=>{
|
|
116
|
+
const now = new Date().toISOString();
|
|
117
|
+
store.conversations = store.conversations.map((c)=>c.id === conversationId ? {
|
|
118
|
+
...c,
|
|
119
|
+
participants: c.participants.map((p)=>p.userId === userId ? {
|
|
120
|
+
...p,
|
|
121
|
+
lastReadMessageId,
|
|
122
|
+
lastReadAt: now
|
|
123
|
+
} : p)
|
|
124
|
+
} : c);
|
|
125
|
+
},
|
|
115
126
|
bumpConversationPreview: (store)=>(conversationId, preview, at)=>{
|
|
116
127
|
store.conversations = sortConversations(store.conversations.map((c)=>c.id === conversationId ? {
|
|
117
128
|
...c,
|
|
@@ -41,6 +41,8 @@ export declare const chatPanelTheme: {
|
|
|
41
41
|
readonly meta: "mt-1 flex items-center gap-1 text-[10px] opacity-60";
|
|
42
42
|
readonly deleted: "italic opacity-60";
|
|
43
43
|
readonly edited: "opacity-60";
|
|
44
|
+
readonly receipt: "inline-flex items-center gap-0.5";
|
|
45
|
+
readonly receiptRead: "text-sky-300 opacity-100";
|
|
44
46
|
};
|
|
45
47
|
readonly attachment: {
|
|
46
48
|
readonly grid: "mt-1.5 flex flex-col gap-1.5";
|
|
@@ -39,7 +39,9 @@ export const chatPanelTheme = {
|
|
|
39
39
|
sender: 'mb-0.5 text-[11px] font-semibold opacity-70',
|
|
40
40
|
meta: 'mt-1 flex items-center gap-1 text-[10px] opacity-60',
|
|
41
41
|
deleted: 'italic opacity-60',
|
|
42
|
-
edited: 'opacity-60'
|
|
42
|
+
edited: 'opacity-60',
|
|
43
|
+
receipt: 'inline-flex items-center gap-0.5',
|
|
44
|
+
receiptRead: 'text-sky-300 opacity-100'
|
|
43
45
|
},
|
|
44
46
|
attachment: {
|
|
45
47
|
grid: 'mt-1.5 flex flex-col gap-1.5',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nucleus-core-ts",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.169",
|
|
4
4
|
"description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
|
|
5
5
|
"author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|