stream-chat
Advanced tools
Comparing version 8.14.5 to 8.15.0
@@ -7,2 +7,3 @@ import { Channel } from './channel'; | ||
user: UserResponse<StreamChatGenerics>; | ||
first_unread_message_id?: string; | ||
last_read_message_id?: string; | ||
@@ -9,0 +10,0 @@ }>; |
@@ -27,2 +27,3 @@ export declare const EVENT_MAP: { | ||
'notification.mark_read': boolean; | ||
'notification.mark_unread': boolean; | ||
'notification.message_new': boolean; | ||
@@ -29,0 +30,0 @@ 'notification.mutes_updated': boolean; |
{ | ||
"name": "stream-chat", | ||
"version": "8.14.5", | ||
"version": "8.15.0", | ||
"description": "JS SDK for the Stream Chat API", | ||
@@ -5,0 +5,0 @@ "author": "GetStream", |
@@ -18,3 +18,9 @@ import { Channel } from './channel'; | ||
string, | ||
{ last_read: Date; unread_messages: number; user: UserResponse<StreamChatGenerics>; last_read_message_id?: string } | ||
{ | ||
last_read: Date; | ||
unread_messages: number; | ||
user: UserResponse<StreamChatGenerics>; | ||
first_unread_message_id?: string; | ||
last_read_message_id?: string; | ||
} | ||
>; | ||
@@ -21,0 +27,0 @@ |
@@ -173,14 +173,6 @@ import { ChannelState } from './channel_state'; | ||
async sendMessage(message: Message<StreamChatGenerics>, options?: SendMessageOptions) { | ||
const sendMessageResponse = await this.getClient().post<SendMessageAPIResponse<StreamChatGenerics>>( | ||
this._channelURL() + '/message', | ||
{ | ||
message, | ||
...options, | ||
}, | ||
); | ||
// Reset unreadCount to 0. | ||
this.state.unreadCount = 0; | ||
return sendMessageResponse; | ||
return await this.getClient().post<SendMessageAPIResponse<StreamChatGenerics>>(this._channelURL() + '/message', { | ||
message, | ||
...options, | ||
}); | ||
} | ||
@@ -1245,3 +1237,2 @@ | ||
channelState.read[event.user.id] = { | ||
// because in client.ts the handleEvent call that flows to this sets this `event.received_at = new Date();` | ||
last_read: new Date(event.created_at), | ||
@@ -1295,2 +1286,8 @@ last_read_message_id: event.last_read_message_id, | ||
// do not increase the unread count - the back-end does not increase the count neither in the following cases: | ||
// 1. the message is mine | ||
// 2. the message is a thread reply from any user | ||
const preventUnreadCountUpdate = ownMessage || isThreadMessage; | ||
if (preventUnreadCountUpdate) break; | ||
if (event.user?.id) { | ||
@@ -1310,5 +1307,3 @@ for (const userId in channelState.read) { | ||
if (ownMessage) { | ||
channelState.unreadCount = 0; | ||
} else if (this._countMessageAsUnread(event.message)) { | ||
if (this._countMessageAsUnread(event.message)) { | ||
channelState.unreadCount = channelState.unreadCount + 1; | ||
@@ -1367,2 +1362,19 @@ } | ||
break; | ||
case 'notification.mark_unread': { | ||
const ownMessage = event.user?.id === this.getClient().user?.id; | ||
if (!(ownMessage && event.user)) break; | ||
const unreadCount = event.unread_messages ?? 0; | ||
channelState.read[event.user.id] = { | ||
first_unread_message_id: event.first_unread_message_id, | ||
last_read: new Date(event.last_read_at as string), | ||
last_read_message_id: event.last_read_message_id, | ||
user: event.user, | ||
unread_messages: unreadCount, | ||
}; | ||
channelState.unreadCount = unreadCount; | ||
break; | ||
} | ||
case 'channel.updated': | ||
@@ -1369,0 +1381,0 @@ if (event.channel) { |
@@ -27,2 +27,3 @@ export const EVENT_MAP = { | ||
'notification.mark_read': true, | ||
'notification.mark_unread': true, | ||
'notification.message_new': true, | ||
@@ -29,0 +30,0 @@ 'notification.mutes_updated': true, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
5201529
54392