Skip to content

Commit

Permalink
feat: receive last_read_message_id from server (#1113)
Browse files Browse the repository at this point in the history
* feat: receive last_read_msg_id from server

also populate last_read_message_id

* make last_read_msg_id optional

to resolve some type test failing

* fix: last_read_msg_id was changed on server
  • Loading branch information
shaljam authored Apr 19, 2023
1 parent 716db00 commit 64e9165
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,7 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
for (const read of state.read) {
this.state.read[read.user.id] = {
last_read: new Date(read.last_read),
last_read_message_id: read.last_read_message_id,
unread_messages: read.unread_messages ?? 0,
user: read.user,
};
Expand Down
2 changes: 1 addition & 1 deletion src/channel_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {

type ChannelReadStatus<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Record<
string,
{ last_read: Date; unread_messages: number; user: UserResponse<StreamChatGenerics> }
{ last_read: Date; unread_messages: number; user: UserResponse<StreamChatGenerics>; last_read_message_id?: string }
>;

/**
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ export type ReactionResponse<
export type ReadResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
last_read: string;
user: UserResponse<StreamChatGenerics>;
last_read_message_id?: string;
unread_messages?: number;
};

Expand Down

0 comments on commit 64e9165

Please sign in to comment.