From 92f24ebcb921561c726a996afed6f8a64024955c Mon Sep 17 00:00:00 2001 From: Vishal Narkhede Date: Thu, 25 Jan 2024 15:23:19 +0100 Subject: [PATCH] fix: date constructor for last_read_at date stamp --- src/thread.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/thread.ts b/src/thread.ts index 9aa94ca48..478e53359 100644 --- a/src/thread.ts +++ b/src/thread.ts @@ -7,9 +7,19 @@ import { ChannelResponse, FormatMessageResponse, ReactionResponse, + UserResponse, } from './types'; import { addToMessageList, formatMessage } from './utils'; +type ThreadReadStatus = Record< + string, + { + last_read: Date; + last_read_message_id: string; + unread_messages: number; + user: UserResponse; + } +>; export class Thread { id: string; latestReplies: FormatMessageResponse[] = []; @@ -19,7 +29,8 @@ export class Thread['channel']>; replyCount = 0; _client: StreamChat; - read: ThreadResponse['read'] = []; + read: ThreadReadStatus = {}; + constructor(client: StreamChat, t: ThreadResponse) { this.id = t.parent_message.id; this.message = formatMessage(t.parent_message); @@ -29,7 +40,12 @@ export class Thread {