stream-chat-angular 4.58.1 → 4.58.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.
@@ -1 +1 @@
1
- export declare const version = "4.58.1";
1
+ export declare const version = "4.58.2";
@@ -356,7 +356,7 @@
356
356
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
357
357
  }
358
358
 
359
- var version = '4.58.1';
359
+ var version = '4.58.2';
360
360
 
361
361
  /**
362
362
  * The `NotificationService` can be used to add or remove notifications. By default the [`NotificationList`](../components/NotificationListComponent.mdx) component displays the currently active notifications.
@@ -1184,15 +1184,9 @@
1184
1184
  return __awaiter(this, void 0, void 0, function () {
1185
1185
  var channel;
1186
1186
  return __generator(this, function (_h) {
1187
- switch (_h.label) {
1188
- case 0:
1189
- channel = this.activeChannelSubject.getValue();
1190
- channel.state.addMessageSorted(Object.assign(Object.assign({}, message), { errorStatusCode: undefined, status: 'sending' }), true);
1191
- return [4 /*yield*/, this.sendMessageRequest(message)];
1192
- case 1:
1193
- _h.sent();
1194
- return [2 /*return*/];
1195
- }
1187
+ channel = this.activeChannelSubject.getValue();
1188
+ channel.state.addMessageSorted(Object.assign(Object.assign({}, message), { errorStatusCode: undefined, status: 'sending' }), true);
1189
+ return [2 /*return*/, this.sendMessageRequest(message, undefined, true)];
1196
1190
  });
1197
1191
  });
1198
1192
  };
@@ -1440,10 +1434,11 @@
1440
1434
  this.watchForChannelEvents(channel);
1441
1435
  }
1442
1436
  };
1443
- ChannelService.prototype.sendMessageRequest = function (preview, customData) {
1444
- var _a;
1437
+ ChannelService.prototype.sendMessageRequest = function (preview, customData, isResend) {
1438
+ if (isResend === void 0) { isResend = false; }
1439
+ var _a, _b, _c, _d;
1445
1440
  return __awaiter(this, void 0, void 0, function () {
1446
- var channel, isThreadReply, response, messages_1, newMessage, error_2, stringError, parsedError, messages_2, newMessage;
1441
+ var channel, isThreadReply, response, messages_1, newMessage, error_2, stringError, parsedError, isAlreadyExists, messages_2, newMessage;
1447
1442
  return __generator(this, function (_h) {
1448
1443
  switch (_h.label) {
1449
1444
  case 0:
@@ -1470,10 +1465,18 @@
1470
1465
  case 3:
1471
1466
  error_2 = _h.sent();
1472
1467
  stringError = JSON.stringify(error_2);
1473
- parsedError = stringError
1474
- ? JSON.parse(stringError)
1475
- : {};
1476
- channel.state.addMessageSorted(Object.assign(Object.assign({}, preview), { errorStatusCode: parsedError.status || undefined, status: 'failed' }), true);
1468
+ parsedError = stringError ? JSON.parse(stringError) : {};
1469
+ isAlreadyExists = false;
1470
+ if (isResend) {
1471
+ if (parsedError.status === 400 &&
1472
+ parsedError.code === 4 &&
1473
+ ((_d = (_c = (_b = parsedError === null || parsedError === void 0 ? void 0 : parsedError.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.message) === null || _d === void 0 ? void 0 : _d.includes('already exists'))) {
1474
+ isAlreadyExists = true;
1475
+ }
1476
+ }
1477
+ channel.state.addMessageSorted(Object.assign(Object.assign({}, preview), { errorStatusCode: isAlreadyExists
1478
+ ? undefined
1479
+ : parsedError.status || undefined, status: isAlreadyExists ? 'received' : 'failed' }), true);
1477
1480
  isThreadReply
1478
1481
  ? this.activeThreadMessagesSubject.next(__spreadArray([], __read(channel.state.threads[preview.parent_id])))
1479
1482
  : this.activeChannelMessagesSubject.next(__spreadArray([], __read(channel.state.messages)));