Skip to content

Commit

Permalink
fix: Revert "fix: remove unused unread count api endpoint (#1143)"
Browse files Browse the repository at this point in the history
This reverts commit 5700abd.
  • Loading branch information
shaljam committed Sep 20, 2023
1 parent fd24276 commit cd20b8c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import {
GetImportResponse,
GetMessageAPIResponse,
GetRateLimitsResponse,
GetUnreadCountAPIResponse,
ListChannelResponse,
ListCommandsResponse,
ListImportsPaginationOptions,
Expand Down Expand Up @@ -1663,6 +1664,10 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG
);
}

async getUnreadCount(userID?: string) {
return await this.get<GetUnreadCountAPIResponse>(this.baseURL + '/unread', userID ? { user_id: userID } : {});
}

/**
* removeDevice - Removes the device with the given id. Clientside users can only delete their own devices
*
Expand Down
14 changes: 14 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,20 @@ export type GetRepliesAPIResponse<StreamChatGenerics extends ExtendableGenerics
messages: MessageResponse<StreamChatGenerics>[];
};

export type GetUnreadCountAPIResponse = APIResponse & {
channel_type: {
channel_count: number;
channel_type: string;
unread_count: number;
}[];
channels: {
channel_id: string;
last_read: string;
unread_count: number;
}[];
total_unread_count: number;
};

export type ListChannelResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = APIResponse & {
channel_types: Record<
string,
Expand Down

0 comments on commit cd20b8c

Please sign in to comment.