stream-chat 9.27.1 → 9.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -326,4 +326,6 @@ export declare const runDetached: <T>(callback: Promise<void | T>, options?: {
326
326
  onSuccessCallback?: (res: T | void) => void | Promise<void>;
327
327
  onErrorCallback?: (error: Error) => void | Promise<void>;
328
328
  }) => void;
329
+ export declare const isBlockedMessage: (message: LocalMessage) => boolean;
330
+ export declare const isBouncedMessage: (message: LocalMessage) => boolean;
329
331
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stream-chat",
3
- "version": "9.27.1",
3
+ "version": "9.27.2",
4
4
  "description": "JS SDK for the Stream Chat API",
5
5
  "homepage": "https://getstream.io/chat/",
6
6
  "author": {
@@ -15,6 +15,7 @@ import {
15
15
  deleteUserMessages as _deleteUserMessages,
16
16
  addToMessageList,
17
17
  formatMessage,
18
+ isBlockedMessage,
18
19
  } from './utils';
19
20
  import { DEFAULT_MESSAGE_SET_PAGINATION } from './constants';
20
21
 
@@ -798,6 +799,12 @@ export class ChannelState {
798
799
  (message) => message.type !== 'error',
799
800
  );
800
801
 
802
+ const blockedMessages = this.latestMessages.filter(isBlockedMessage);
803
+ // We need to hard delete the blocked messages from the offline database.
804
+ for (const message of blockedMessages) {
805
+ this._channel.getClient().offlineDb?.hardDeleteMessage({ id: message.id });
806
+ }
807
+
801
808
  this.latestMessages = filteredMessages;
802
809
  }
803
810
 
@@ -15,8 +15,13 @@ export const createCompositionDataCleanupMiddleware = (
15
15
  state,
16
16
  next,
17
17
  }: MiddlewareHandlerParams<MessageComposerMiddlewareState>) => {
18
+ const messageType =
19
+ !composer.editedMessage?.type || composer.editedMessage.type === 'error'
20
+ ? 'regular'
21
+ : composer.editedMessage.type;
22
+
18
23
  const common = {
19
- type: composer.editedMessage?.type ?? 'regular',
24
+ type: messageType,
20
25
  };
21
26
 
22
27
  const editedMessagePayloadToBeSent = composer.editedMessage
package/src/utils.ts CHANGED
@@ -1342,3 +1342,13 @@ export const runDetached = <T>(
1342
1342
 
1343
1343
  promise.catch(onError);
1344
1344
  };
1345
+
1346
+ export const isBlockedMessage = (message: LocalMessage) =>
1347
+ message.type === 'error' &&
1348
+ (message.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_REMOVE' ||
1349
+ message.moderation?.action === 'remove');
1350
+
1351
+ export const isBouncedMessage = (message: LocalMessage) =>
1352
+ message.type === 'error' &&
1353
+ (message?.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE' ||
1354
+ message?.moderation?.action === 'bounce');