nucleus-core-ts 0.9.168 → 0.9.170

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.
@@ -100,7 +100,7 @@ export function ChatPanel(props) {
100
100
  ]
101
101
  }),
102
102
  /*#__PURE__*/ _jsxs("div", {
103
- className: "flex flex-1 flex-col",
103
+ className: "flex min-h-0 flex-1 flex-col",
104
104
  children: [
105
105
  /*#__PURE__*/ _jsx(MessageThread, {
106
106
  conversation: active,
@@ -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,
@@ -21,11 +21,11 @@ export declare const chatPanelTheme: {
21
21
  readonly badge: "ml-2 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-emerald-500 px-1.5 text-[11px] font-semibold text-white";
22
22
  };
23
23
  readonly thread: {
24
- readonly base: "flex flex-1 flex-col";
24
+ readonly base: "flex min-h-0 flex-1 flex-col";
25
25
  readonly header: "flex items-center gap-3 border-b border-zinc-200 px-5 py-3 dark:border-zinc-800";
26
26
  readonly headerTitle: "text-sm font-semibold";
27
27
  readonly headerSubtitle: "text-xs text-zinc-400";
28
- readonly messages: "flex flex-1 flex-col gap-2 overflow-y-auto px-5 py-4";
28
+ readonly messages: "flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-5 py-4";
29
29
  readonly loadMore: "mx-auto mb-2 rounded-full border border-zinc-200 px-3 py-1 text-xs text-zinc-500 transition hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900";
30
30
  readonly empty: "flex flex-1 items-center justify-center text-sm text-zinc-400";
31
31
  readonly placeholder: "flex flex-1 items-center justify-center px-6 text-center text-sm text-zinc-400";
@@ -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";
@@ -20,11 +20,11 @@ export const chatPanelTheme = {
20
20
  badge: 'ml-2 inline-flex h-5 min-w-5 items-center justify-center rounded-full bg-emerald-500 px-1.5 text-[11px] font-semibold text-white'
21
21
  },
22
22
  thread: {
23
- base: 'flex flex-1 flex-col',
23
+ base: 'flex min-h-0 flex-1 flex-col',
24
24
  header: 'flex items-center gap-3 border-b border-zinc-200 px-5 py-3 dark:border-zinc-800',
25
25
  headerTitle: 'text-sm font-semibold',
26
26
  headerSubtitle: 'text-xs text-zinc-400',
27
- messages: 'flex flex-1 flex-col gap-2 overflow-y-auto px-5 py-4',
27
+ messages: 'flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-5 py-4',
28
28
  loadMore: 'mx-auto mb-2 rounded-full border border-zinc-200 px-3 py-1 text-xs text-zinc-500 transition hover:bg-zinc-50 dark:border-zinc-800 dark:hover:bg-zinc-900',
29
29
  empty: 'flex flex-1 items-center justify-center text-sm text-zinc-400',
30
30
  placeholder: 'flex flex-1 items-center justify-center px-6 text-center text-sm text-zinc-400'
@@ -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',