diff --git a/.lintstagedrc.json b/.lintstagedrc.json index a86b3ff7f..8bdbf1e89 100644 --- a/.lintstagedrc.json +++ b/.lintstagedrc.json @@ -1,4 +1,4 @@ { "{**/*.{js,ts,md,css,scss,json}, .eslintrc.json, .prettierrc, .babelrc}": "prettier --list-different", - "**/*.{js,md,ts}": "eslint --max-warnings 0" + "**/*.{js,md,ts}, !test": "eslint --max-warnings 0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b0354f49..fc66fca2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,42 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [8.31.0](https://github.com/GetStream/stream-chat-js/compare/v8.30.0...v8.31.0) (2024-05-02) + + +### Features + +* ability to send poll with campaigns ([#1292](https://github.com/GetStream/stream-chat-js/issues/1292)) ([cace193](https://github.com/GetStream/stream-chat-js/commit/cace1935dc808c03a291a28a084898ee5531d087)) +* member_limit option on queryThreads and getThread endpoint ([#1291](https://github.com/GetStream/stream-chat-js/issues/1291)) ([78fae3d](https://github.com/GetStream/stream-chat-js/commit/78fae3d7364150b6b3a7640b4f9b37204702a161)) + +## [8.30.0](https://github.com/GetStream/stream-chat-js/compare/v8.29.0...v8.30.0) (2024-04-30) + + +### Features + +* "include_soft_deleted_channels" option to export channels api ([#1288](https://github.com/GetStream/stream-chat-js/issues/1288)) ([dcd7621](https://github.com/GetStream/stream-chat-js/commit/dcd7621594accdadc255b0eb091616d1a83cb602)) +* support privacy settings ([#1283](https://github.com/GetStream/stream-chat-js/issues/1283)) ([f16552b](https://github.com/GetStream/stream-chat-js/commit/f16552b1e50606d47485b7a77925a1340e046626)) + +## [8.29.0](https://github.com/GetStream/stream-chat-js/compare/v8.28.0...v8.29.0) (2024-04-30) + + +### Features + +* add reaction groups fallback ([#1286](https://github.com/GetStream/stream-chat-js/issues/1286)) ([7183154](https://github.com/GetStream/stream-chat-js/commit/7183154a663701c24d9c573832288d66e9214565)) + + +### Bug Fixes + +* fix filter type for query reactions ([#1287](https://github.com/GetStream/stream-chat-js/issues/1287)) ([65174a5](https://github.com/GetStream/stream-chat-js/commit/65174a55fd30eec445033cb9af745e6d4164f23d)) + +## [8.28.0](https://github.com/GetStream/stream-chat-js/compare/v8.27.0...v8.28.0) (2024-04-29) + + +### Features + +* add reactiongroups in `MessageResponse` ([#1278](https://github.com/GetStream/stream-chat-js/issues/1278)) ([0d5f87f](https://github.com/GetStream/stream-chat-js/commit/0d5f87fe29dc946044dedd1ad6df0e8780a04e8f)) +* sort option on getReplies endpoint ([#1284](https://github.com/GetStream/stream-chat-js/issues/1284)) ([9ad65d3](https://github.com/GetStream/stream-chat-js/commit/9ad65d3ee6e275dc3ac22be1c2f87b082cf58de4)) + ## [8.27.0](https://github.com/GetStream/stream-chat-js/compare/v8.26.0...v8.27.0) (2024-04-24) diff --git a/package.json b/package.json index 7cf15afa4..1b62b3fc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "stream-chat", - "version": "8.27.0", + "version": "8.31.0", "description": "JS SDK for the Stream Chat API", "author": "GetStream", "homepage": "https://getstream.io/chat/", diff --git a/src/channel.ts b/src/channel.ts index ca9cffab3..5ffb0bcb9 100644 --- a/src/channel.ts +++ b/src/channel.ts @@ -55,6 +55,7 @@ import { QueryChannelAPIResponse, PollVoteData, SendMessageOptions, + AscDesc, } from './types'; import { Role } from './permissions'; @@ -655,7 +656,7 @@ export class Channel); } + _isTypingIndicatorsEnabled(): boolean { + if (!this.getConfig()?.typing_events) { + return false; + } + return this.getClient().user?.privacy_settings?.typing_indicators?.enabled ?? true; + } + /** * lastMessage - return the last message, takes into account that last few messages might not be perfectly sorted * @@ -823,10 +831,13 @@ export class Channel; user_id?: string }, + sort?: { created_at: AscDesc }[], ) { + const normalizedSort = sort ? normalizeQuerySort(sort) : undefined; const data = await this.getClient().get>( this.getClient().baseURL + `/messages/${parent_id}/replies`, { + sort: normalizedSort, ...options, }, ); diff --git a/src/types.ts b/src/types.ts index ef461a4dc..0fa2eba52 100644 --- a/src/types.ts +++ b/src/types.ts @@ -297,6 +297,7 @@ export type QueryReactionsOptions = Pager; export type QueryReactionsAPIResponse = APIResponse & { reactions: ReactionResponse[]; + next?: string; }; export type QueryChannelsAPIResponse = APIResponse & { @@ -524,6 +525,7 @@ export type PartialThreadUpdate = { export type QueryThreadsOptions = { limit?: number; + member_limit?: number; next?: string; participant_limit?: number; reply_limit?: number; @@ -536,6 +538,7 @@ export type QueryThreadsAPIResponse = MessageBase & { - reaction_groups: Record; type: MessageLabel; args?: string; before_message_send_failed?: boolean; @@ -651,6 +653,7 @@ export type MessageResponseBase< pinned_by?: UserResponse | null; poll?: PollResponse; reaction_counts?: { [key: string]: number } | null; + reaction_groups?: { [key: string]: ReactionGroupResponse } | null; reaction_scores?: { [key: string]: number } | null; reply_count?: number; shadowed?: boolean; @@ -715,6 +718,7 @@ export type OwnUserBase, '$eq' | '$gt' | '$lt' | '$gte' | '$lte'>> | PrimitiveFilter; - } & { - [Key in keyof Omit, 'user_id' | 'type' | 'created_at'>]: RequireOnlyOne< - QueryFilter[Key]> - >; - } + } >; export type ChannelFilters = QueryFilters< @@ -1669,6 +1679,11 @@ export type UserFilters > | PrimitiveFilter['name']>; + notifications_muted?: + | RequireOnlyOne<{ + $eq?: PrimitiveFilter['notifications_muted']>; + }> + | boolean; teams?: | RequireOnlyOne<{ $contains?: PrimitiveFilter; @@ -2314,6 +2329,7 @@ export type ExportChannelRequest = { export type ExportChannelOptions = { clear_deleted_message_text?: boolean; export_users?: boolean; + include_soft_deleted_channels?: boolean; include_truncated_messages?: boolean; version?: string; }; @@ -2783,6 +2799,7 @@ export type CampaignData = { text: string; attachments?: Attachment[]; custom?: {}; + poll_id?: string; }; name?: string; segment_ids?: string[]; diff --git a/src/utils.ts b/src/utils.ts index 9d20e49e6..3730df582 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -8,6 +8,7 @@ import { UserResponse, MessageResponse, FormatMessageResponse, + ReactionGroupResponse, } from './types'; import { AxiosRequestConfig } from 'axios'; @@ -86,6 +87,7 @@ export function isOwnUserBaseProperty(property: string) { unread_count: true, unread_threads: true, invisible: true, + privacy_settings: true, roles: true, }; @@ -295,6 +297,11 @@ export function formatMessage { } }); }); + +describe('reaction groups fallback', () => { + it('uses groups if present', () => { + const date = '2024-04-30T11:03:39.217974Z'; + const groups = { + love: { + count: 1, + sum_scores: 1, + first_reaction_at: date, + last_reaction_at: date, + }, + }; + + const message = formatMessage({ reaction_groups: groups }); + expect(message.reaction_groups).to.be.equal(groups); + }); + + it('falls back to counts + scores', () => { + const counts = { love: 1, sad: 1 }; + const scores = { love: 1, sad: 2 }; + + const message = formatMessage({ + reaction_groups: null, + reaction_counts: counts, + reaction_scores: scores, + }); + + expect(message.reaction_groups).to.deep.equal({ + love: { + count: 1, + sum_scores: 1, + }, + sad: { + count: 1, + sum_scores: 2, + }, + }); + }); +});