Skip to content

Commit

Permalink
Merge branch 'master' into fix/export-status
Browse files Browse the repository at this point in the history
* master: (44 commits)
  chore: release v8.14.4 (GetStream#1203)
  fix: add default contentType as multipart/form-data in sendFile (GetStream#1202)
  chore: release v8.14.3 (GetStream#1200)
  fix: use postForm instead of post for sending files (GetStream#1199)
  chore: release v8.14.2 (GetStream#1197)
  fix: reload channel state if frozen flag changed (GetStream#1196)
  chore(release): v8.14.1 (GetStream#1195)
  Update user reference in channel read data (GetStream#1194)
  chore(release): v8.14.0 (GetStream#1193)
  feat: axios upgrade to v1 (GetStream#1192)
  Revert "fix: queue channel WS events until the channel is initialized" (GetStream#1189)
  chore(release): v8.13.1 (GetStream#1188)
  fix: undefined values in query params (GetStream#1187)
  chore(release): v8.13.0 (GetStream#1186)
  feat: support for SNS (GetStream#1185)
  chore: release v8.12.4 (GetStream#1184)
  fix: evaluate channel.lastRead when channel is not initialized (GetStream#1183)
  chore(release): v8.12.3 (GetStream#1182)
  fix: queue channel WS events until the channel is initialized (GetStream#1179)
  chore: release v8.12.2 (GetStream#1181)
  ...
  • Loading branch information
rchl committed Nov 29, 2023
2 parents f017f85 + 30df2c2 commit f051340
Show file tree
Hide file tree
Showing 14 changed files with 757 additions and 96 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @vishalnarkhede @vanGalilea
* @vishalnarkhede @santhoshvai @khushal87 @szuperaz @oliverlaz @arnautov-anton @MartinCupela
119 changes: 119 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,125 @@

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.14.4](https://github.com/GetStream/stream-chat-js/compare/v8.14.3...v8.14.4) (2023-11-29)


### Bug Fixes

* add default contentType as multipart/form-data in sendFile ([#1202](https://github.com/GetStream/stream-chat-js/issues/1202)) ([64e2a2a](https://github.com/GetStream/stream-chat-js/commit/64e2a2aeba1176be1eb8816f654fcf78c1c07066))

### [8.14.3](https://github.com/GetStream/stream-chat-js/compare/v8.14.2...v8.14.3) (2023-11-22)


### Bug Fixes

* use postForm instead of post for sending files ([#1199](https://github.com/GetStream/stream-chat-js/issues/1199)) ([2b06ca4](https://github.com/GetStream/stream-chat-js/commit/2b06ca48db8a50e40d870f87e0ea7d7ccbb7369b))

### [8.14.2](https://github.com/GetStream/stream-chat-js/compare/v8.14.1...v8.14.2) (2023-11-16)


### Bug Fixes

* reload channel state if frozen flag changed ([#1196](https://github.com/GetStream/stream-chat-js/issues/1196)) ([c88d941](https://github.com/GetStream/stream-chat-js/commit/c88d9412ea2c1ce64403e557a977c446fa069b04))

### [8.14.1](https://github.com/GetStream/stream-chat-js/compare/v8.14.0...v8.14.1) (2023-11-03)

## [8.14.0](https://github.com/GetStream/stream-chat-js/compare/v8.13.1...v8.14.0) (2023-11-01)


### Features

* axios upgrade to v1 ([#1192](https://github.com/GetStream/stream-chat-js/issues/1192)) ([77b8bc8](https://github.com/GetStream/stream-chat-js/commit/77b8bc8964b5a454dafbc4fe81415570b5def45e))

### [8.13.1](https://github.com/GetStream/stream-chat-js/compare/v8.13.0...v8.13.1) (2023-10-19)


### Bug Fixes

* undefined values in query params ([#1187](https://github.com/GetStream/stream-chat-js/issues/1187)) ([a325737](https://github.com/GetStream/stream-chat-js/commit/a325737d8318e58d891d7106b543b1a36ed401a0))

## [8.13.0](https://github.com/GetStream/stream-chat-js/compare/v8.12.4...v8.13.0) (2023-10-16)


### Features

* support for SNS ([#1185](https://github.com/GetStream/stream-chat-js/issues/1185)) ([9a4bdfb](https://github.com/GetStream/stream-chat-js/commit/9a4bdfb68424cc02083c1e05f8512900696c0efc))

### [8.12.4](https://github.com/GetStream/stream-chat-js/compare/v8.12.3...v8.12.4) (2023-10-06)


### Bug Fixes

* evaluate channel.lastRead when channel is not initialized ([#1183](https://github.com/GetStream/stream-chat-js/issues/1183)) ([13fa28a](https://github.com/GetStream/stream-chat-js/commit/13fa28a75ca623fc5b7b328aaa9edb3e87f99f1c))

### [8.12.3](https://github.com/GetStream/stream-chat-js/compare/v8.12.2...v8.12.3) (2023-10-03)


### Bug Fixes

* queue channel WS events until the channel is initialized ([#1179](https://github.com/GetStream/stream-chat-js/issues/1179)) ([2073579](https://github.com/GetStream/stream-chat-js/commit/2073579ecfe4e8a1d5d37aa7f0a43b53bb57cd02))

### [8.12.2](https://github.com/GetStream/stream-chat-js/compare/v8.12.1...v8.12.2) (2023-10-03)


### Bug Fixes

* axios param serializer to comply with RFC 3986 ([#1180](https://github.com/GetStream/stream-chat-js/issues/1180)) ([d2ff8ec](https://github.com/GetStream/stream-chat-js/commit/d2ff8ecc68bd6a48fe76bc22ab8404b6cfa42a85)), closes https://github.com/GetStream/stream-chat-react-native/issues/2235

### [8.12.1](https://github.com/GetStream/stream-chat-js/compare/v8.12.0...v8.12.1) (2023-09-20)


### Bug Fixes

* allow search with offset and sort ([d0c3f35](https://github.com/GetStream/stream-chat-js/commit/d0c3f357e8f559d2e60922098223525f9b06da8e))
* allow search with offset and sort ([#1174](https://github.com/GetStream/stream-chat-js/issues/1174)) ([fd24276](https://github.com/GetStream/stream-chat-js/commit/fd242769717ef44068cacd61503aa0d958febabc))
* remove unused unread count api endpoint ([33823be](https://github.com/GetStream/stream-chat-js/commit/33823be128ad917bec51447038e34f56256f8986))

## [8.12.0](https://github.com/GetStream/stream-chat-js/compare/v8.11.0...v8.12.0) (2023-09-18)


### Features

* add field deleted_reply_count to MessageResponseBase ([#1172](https://github.com/GetStream/stream-chat-js/issues/1172)) ([f350692](https://github.com/GetStream/stream-chat-js/commit/f35069251740c9831816ce36c1e2ff73d03a4b09))
* declare and export types SendMessageOptions and UpdateMessageOptions ([#1170](https://github.com/GetStream/stream-chat-js/issues/1170)) ([8a2ad69](https://github.com/GetStream/stream-chat-js/commit/8a2ad699e058016b61ecef91c8c782c4cb0c9be7))


### Bug Fixes

* handle getting channel by members with channel id explicitly undefined ([#1169](https://github.com/GetStream/stream-chat-js/issues/1169)) ([a721b59](https://github.com/GetStream/stream-chat-js/commit/a721b591bf3fbde3a59116eeb63f4a15f3f3d389))

## [8.11.0](https://github.com/GetStream/stream-chat-js/compare/v8.10.1...v8.11.0) (2023-08-21)


### Features

* add the option to exclude expired bans ([#1147](https://github.com/GetStream/stream-chat-js/issues/1147)) ([9a488a6](https://github.com/GetStream/stream-chat-js/commit/9a488a6d66c00daf6b932f954be4ca470338b004))
* update last_read_message_id on message.read ([#1155](https://github.com/GetStream/stream-chat-js/issues/1155)) ([83f1c56](https://github.com/GetStream/stream-chat-js/commit/83f1c5640d6df1cb928c0a774bce6b43726366a4))


### Bug Fixes

* add geofences type ([#1148](https://github.com/GetStream/stream-chat-js/issues/1148)) ([31da90b](https://github.com/GetStream/stream-chat-js/commit/31da90b4a2ef881284f07268e06a2600cebea97c))
* add missing property 'silent' to MessageBase type ([#1154](https://github.com/GetStream/stream-chat-js/issues/1154)) ([ba30397](https://github.com/GetStream/stream-chat-js/commit/ba30397fed441bc797836806129117f9707b83e0))

### [8.10.1](https://github.com/GetStream/stream-chat-js/compare/v8.10.0...v8.10.1) (2023-07-06)


### Bug Fixes

* remove unused unread count api endpoint ([#1143](https://github.com/GetStream/stream-chat-js/issues/1143)) ([5700abd](https://github.com/GetStream/stream-chat-js/commit/5700abdb072e41c23e4439b8fb01eafd1993d5e8))

## [8.10.0](https://github.com/GetStream/stream-chat-js/compare/v8.9.0...v8.10.0) (2023-07-03)


### Features

* added 'pending' property to message ([#1137](https://github.com/GetStream/stream-chat-js/issues/1137)) ([6209380](https://github.com/GetStream/stream-chat-js/commit/6209380e145e9f6ffcde3abd282effed24540172))

### Bug Fixes

* prevent truncating message timestamps when updating references to deleted quoted message ([#1141](https://github.com/GetStream/stream-chat-js/issues/1141)) ([ab54f94](https://github.com/GetStream/stream-chat-js/commit/ab54f94a384a772902027f50f84038ac01cbf728))

## [8.9.0](https://github.com/GetStream/stream-chat-js/compare/v8.8.0...v8.9.0) (2023-06-09)


Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stream-chat",
"version": "8.9.0",
"version": "8.14.4",
"description": "JS SDK for the Stream Chat API",
"author": "GetStream",
"homepage": "https://getstream.io/chat/",
Expand Down Expand Up @@ -38,7 +38,7 @@
"@babel/runtime": "^7.16.3",
"@types/jsonwebtoken": "~9.0.0",
"@types/ws": "^7.4.0",
"axios": "^0.22.0",
"axios": "^1.6.0",
"base64-js": "^1.5.1",
"form-data": "^4.0.0",
"isomorphic-ws": "^4.0.1",
Expand Down
45 changes: 25 additions & 20 deletions src/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {
UserFilters,
UserResponse,
QueryChannelAPIResponse,
SendMessageOptions,
} from './types';
import { Role } from './permissions';

Expand Down Expand Up @@ -161,27 +162,14 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
* @param {Message<StreamChatGenerics>} message The Message object
* @param {boolean} [options.skip_enrich_url] Do not try to enrich the URLs within message
* @param {boolean} [options.skip_push] Skip sending push notifications
* @param {boolean} [options.is_pending_message] Make this message pending
* @param {boolean} [options.is_pending_message] DEPRECATED, please use `pending` instead.
* @param {boolean} [options.pending] Make this message pending
* @param {Record<string,string>} [options.pending_message_metadata] Metadata for the pending message
* @param {boolean} [options.force_moderation] Apply force moderation for server-side requests
*
* @return {Promise<SendMessageAPIResponse<StreamChatGenerics>>} The Server Response
*/
async sendMessage(
message: Message<StreamChatGenerics>,
options?: {
force_moderation?: boolean;
is_pending_message?: boolean;
keep_channel_hidden?: boolean;
pending_message_metadata?: Record<string, string>;
skip_enrich_url?: boolean;
skip_push?: boolean;
},
) {
if (options?.is_pending_message !== undefined && !this._client._isUsingServerAuth()) {
throw new Error('Setting is_pending_message on client side is not supported');
}

async sendMessage(message: Message<StreamChatGenerics>, options?: SendMessageOptions) {
const sendMessageResponse = await this.getClient().post<SendMessageAPIResponse<StreamChatGenerics>>(
this._channelURL() + '/message',
{
Expand Down Expand Up @@ -253,8 +241,8 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
query?: string;
} = {},
) {
if (options.offset && (options.sort || options.next)) {
throw Error(`Cannot specify offset with sort or next parameters`);
if (options.offset && options.next) {
throw Error(`Cannot specify offset with next`);
}
// Return a list of channels
const payload: SearchPayload<StreamChatGenerics> = {
Expand Down Expand Up @@ -902,7 +890,6 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
* @return {Date | null | undefined}
*/
lastRead() {
this._checkInitialized();
const { userID } = this.getClient();
if (userID) {
return this.state.read[userID] ? this.state.read[userID].last_read : null;
Expand Down Expand Up @@ -1039,9 +1026,20 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
// add any messages to our channel state
const { messageSet } = this._initializeState(state, messageSetToAddToIfDoesNotExist);

const areCapabilitiesChanged =
[...(state.channel.own_capabilities || [])].sort().join() !==
[...(Array.isArray(this.data?.own_capabilities) ? (this.data?.own_capabilities as string[]) : [])].sort().join();
this.data = state.channel;
this.offlineMode = false;

if (areCapabilitiesChanged) {
this.getClient().dispatchEvent({
type: 'capabilities.changed',
cid: this.cid,
own_capabilities: state.channel.own_capabilities,
});
}

this.getClient().dispatchEvent({
type: 'channels.queried',
queriedChannels: {
Expand Down Expand Up @@ -1245,6 +1243,7 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
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),
last_read_message_id: event.last_read_message_id,
user: event.user,
unread_messages: 0,
};
Expand Down Expand Up @@ -1363,6 +1362,10 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
break;
case 'channel.updated':
if (event.channel) {
const isFrozenChanged = event.channel?.frozen !== undefined && event.channel.frozen !== channel.data?.frozen;
if (isFrozenChanged) {
this.query({ state: false, messages: { limit: 0 }, watchers: { limit: 0 } });
}
channel.data = {
...event.channel,
hidden: event.channel?.hidden ?? channel.data?.hidden,
Expand Down Expand Up @@ -1492,7 +1495,9 @@ export class Channel<StreamChatGenerics extends ExtendableGenerics = DefaultGene
if (state.pending_messages) {
this.state.pending_messages = state.pending_messages;
}
this.state.watcher_count = state.watcher_count || 0;
if (state.watcher_count !== undefined) {
this.state.watcher_count = state.watcher_count;
}
// convert the arrays into objects for easier syncing...
if (state.watchers) {
for (const watcher of state.watchers) {
Expand Down
6 changes: 3 additions & 3 deletions src/channel_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ export class ChannelState<StreamChatGenerics extends ExtendableGenerics = Defaul
const parseMessage = (m: ReturnType<ChannelState<StreamChatGenerics>['formatMessage']>) =>
(({
...m,
created_at: m.created_at.toString(),
pinned_at: m.pinned_at?.toString(),
updated_at: m.updated_at?.toString(),
created_at: m.created_at.toISOString(),
pinned_at: m.pinned_at?.toISOString(),
updated_at: m.updated_at?.toISOString(),
} as unknown) as MessageResponse<StreamChatGenerics>);

this.messageSets.forEach((set) => {
Expand Down
Loading

0 comments on commit f051340

Please sign in to comment.