stream-chat-angular 4.36.2 → 4.38.0

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.36.2";
1
+ export declare const version = "4.38.0";
@@ -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.36.2';
359
+ var version = '4.38.0';
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.
@@ -1096,7 +1096,7 @@
1096
1096
  if (quotedMessageId === void 0) { quotedMessageId = undefined; }
1097
1097
  if (customData === void 0) { customData = undefined; }
1098
1098
  return __awaiter(this, void 0, void 0, function () {
1099
- var preview, channel;
1099
+ var preview, channel, response;
1100
1100
  return __generator(this, function (_h) {
1101
1101
  switch (_h.label) {
1102
1102
  case 0:
@@ -1106,8 +1106,8 @@
1106
1106
  channel.state.addMessageSorted(preview, true);
1107
1107
  return [4 /*yield*/, this.sendMessageRequest(preview, customData)];
1108
1108
  case 1:
1109
- _h.sent();
1110
- return [2 /*return*/];
1109
+ response = _h.sent();
1110
+ return [2 /*return*/, response];
1111
1111
  }
1112
1112
  });
1113
1113
  });
@@ -1137,8 +1137,9 @@
1137
1137
  * @param message Mesage to be updated
1138
1138
  */
1139
1139
  ChannelService.prototype.updateMessage = function (message) {
1140
+ var _a;
1140
1141
  return __awaiter(this, void 0, void 0, function () {
1141
- var messageToUpdate;
1142
+ var messageToUpdate, response, channel;
1142
1143
  return __generator(this, function (_h) {
1143
1144
  switch (_h.label) {
1144
1145
  case 0:
@@ -1146,8 +1147,10 @@
1146
1147
  delete messageToUpdate.i18n;
1147
1148
  return [4 /*yield*/, this.chatClientService.chatClient.updateMessage(messageToUpdate)];
1148
1149
  case 1:
1149
- _h.sent();
1150
- return [2 /*return*/];
1150
+ response = _h.sent();
1151
+ channel = (_a = this.channelsSubject
1152
+ .getValue()) === null || _a === void 0 ? void 0 : _a.find(function (c) { return c.cid === message.cid; });
1153
+ return [2 /*return*/, this.transformToStreamMessage(response.message, channel)];
1151
1154
  }
1152
1155
  });
1153
1156
  });
@@ -1332,7 +1335,7 @@
1332
1335
  ChannelService.prototype.sendMessageRequest = function (preview, customData) {
1333
1336
  var _a;
1334
1337
  return __awaiter(this, void 0, void 0, function () {
1335
- var channel, isThreadReply, response, error_2, stringError, parsedError;
1338
+ var channel, isThreadReply, response, messages_1, newMessage, error_2, stringError, parsedError, messages_2, newMessage;
1336
1339
  return __generator(this, function (_h) {
1337
1340
  switch (_h.label) {
1338
1341
  case 0:
@@ -1347,13 +1350,15 @@
1347
1350
  return [4 /*yield*/, channel.sendMessage(Object.assign({ id: preview.id, text: preview.text, attachments: preview.attachments, mentioned_users: (_a = preview.mentioned_users) === null || _a === void 0 ? void 0 : _a.map(function (u) { return u.id; }), parent_id: preview.parent_id, quoted_message_id: preview.quoted_message_id }, customData))];
1348
1351
  case 2:
1349
1352
  response = _h.sent();
1350
- if (response === null || response === void 0 ? void 0 : response.message) {
1351
- channel.state.addMessageSorted(Object.assign(Object.assign({}, response.message), { status: 'received' }), true);
1352
- isThreadReply
1353
- ? this.activeThreadMessagesSubject.next(__spreadArray([], __read(channel.state.threads[preview.parent_id])))
1354
- : this.activeChannelMessagesSubject.next(__spreadArray([], __read(channel.state.messages)));
1355
- }
1356
- return [3 /*break*/, 4];
1353
+ channel.state.addMessageSorted(Object.assign(Object.assign({}, response.message), { status: 'received' }), true);
1354
+ isThreadReply
1355
+ ? this.activeThreadMessagesSubject.next(__spreadArray([], __read(channel.state.threads[preview.parent_id])))
1356
+ : this.activeChannelMessagesSubject.next(__spreadArray([], __read(channel.state.messages)));
1357
+ (isThreadReply ? this.activeThreadMessages$ : this.activeChannelMessages$)
1358
+ .pipe(operators.take(1))
1359
+ .subscribe(function (m) { return (messages_1 = m); });
1360
+ newMessage = messages_1[messages_1.length - 1];
1361
+ return [2 /*return*/, newMessage];
1357
1362
  case 3:
1358
1363
  error_2 = _h.sent();
1359
1364
  stringError = JSON.stringify(error_2);
@@ -1364,7 +1369,11 @@
1364
1369
  isThreadReply
1365
1370
  ? this.activeThreadMessagesSubject.next(__spreadArray([], __read(channel.state.threads[preview.parent_id])))
1366
1371
  : this.activeChannelMessagesSubject.next(__spreadArray([], __read(channel.state.messages)));
1367
- return [3 /*break*/, 4];
1372
+ (isThreadReply ? this.activeThreadMessages$ : this.activeChannelMessages$)
1373
+ .pipe(operators.take(1))
1374
+ .subscribe(function (m) { return (messages_2 = m); });
1375
+ newMessage = messages_2[messages_2.length - 1];
1376
+ return [2 /*return*/, newMessage];
1368
1377
  case 4: return [2 /*return*/];
1369
1378
  }
1370
1379
  });
@@ -1950,11 +1959,19 @@
1950
1959
  message.quoted_message = Object.assign(Object.assign({}, message.quoted_message), { translation: getMessageTranslation(message.quoted_message, channel, this.chatClientService.chatClient.user) });
1951
1960
  }
1952
1961
  if (this.isFormatMessageResponse(message)) {
1953
- return Object.assign(Object.assign({}, message), { readBy: isThreadMessage ? [] : getReadBy(message, channel), translation: getMessageTranslation(message, channel, this.chatClientService.chatClient.user) });
1962
+ return Object.assign(Object.assign({}, message), { readBy: isThreadMessage
1963
+ ? []
1964
+ : channel
1965
+ ? getReadBy(message, channel)
1966
+ : [], translation: getMessageTranslation(message, channel, this.chatClientService.chatClient.user) });
1954
1967
  }
1955
1968
  else {
1956
1969
  var formatMessage = this.formatMessage(message);
1957
- return Object.assign(Object.assign({}, formatMessage), { readBy: isThreadMessage ? [] : getReadBy(formatMessage, channel), translation: getMessageTranslation(message, channel, this.chatClientService.chatClient.user) });
1970
+ return Object.assign(Object.assign({}, formatMessage), { readBy: isThreadMessage
1971
+ ? []
1972
+ : channel
1973
+ ? getReadBy(formatMessage, channel)
1974
+ : [], translation: getMessageTranslation(message, channel, this.chatClientService.chatClient.user) });
1958
1975
  }
1959
1976
  }
1960
1977
  };
@@ -3115,8 +3132,10 @@
3115
3132
  * The `AvatarPlaceholder` component displays the [default avatar](./AvatarComponent.mdx) unless a [custom template](../services/CustomTemplatesService.mdx) is provided. This component is used by the SDK internally, you likely won't need to use it.
3116
3133
  */
3117
3134
  var AvatarPlaceholderComponent = /** @class */ (function () {
3118
- function AvatarPlaceholderComponent(customTemplatesService) {
3135
+ function AvatarPlaceholderComponent(customTemplatesService, hostElement, cdRef) {
3119
3136
  this.customTemplatesService = customTemplatesService;
3137
+ this.hostElement = hostElement;
3138
+ this.cdRef = cdRef;
3120
3139
  /**
3121
3140
  * The size in pixels of the avatar image.
3122
3141
  */
@@ -3135,7 +3154,28 @@
3135
3154
  type: undefined,
3136
3155
  initialsType: undefined,
3137
3156
  };
3157
+ this.isVisible = true;
3138
3158
  }
3159
+ AvatarPlaceholderComponent.prototype.ngAfterViewInit = function () {
3160
+ var _this = this;
3161
+ var _a, _b;
3162
+ if (this.location !== 'message-sender') {
3163
+ this.isVisible = true;
3164
+ this.cdRef.detectChanges();
3165
+ return;
3166
+ }
3167
+ this.checkIfVisible();
3168
+ var elementToObserve = (_b = (_a = this.hostElement.nativeElement.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement;
3169
+ if (!elementToObserve) {
3170
+ return;
3171
+ }
3172
+ this.mutationObserver = new MutationObserver(function () {
3173
+ _this.checkIfVisible();
3174
+ });
3175
+ this.mutationObserver.observe(elementToObserve, {
3176
+ attributeFilter: ['class'],
3177
+ });
3178
+ };
3139
3179
  AvatarPlaceholderComponent.prototype.ngOnChanges = function () {
3140
3180
  this.context = {
3141
3181
  name: this.name,
@@ -3148,10 +3188,21 @@
3148
3188
  initialsType: this.initialsType,
3149
3189
  };
3150
3190
  };
3191
+ AvatarPlaceholderComponent.prototype.ngOnDestroy = function () {
3192
+ var _a;
3193
+ (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
3194
+ };
3195
+ AvatarPlaceholderComponent.prototype.checkIfVisible = function () {
3196
+ var isVisible = getComputedStyle(this.hostElement.nativeElement).getPropertyValue('visibility') === 'visible';
3197
+ if (isVisible !== this.isVisible) {
3198
+ this.isVisible = isVisible;
3199
+ this.cdRef.detectChanges();
3200
+ }
3201
+ };
3151
3202
  return AvatarPlaceholderComponent;
3152
3203
  }());
3153
- AvatarPlaceholderComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: AvatarPlaceholderComponent, deps: [{ token: CustomTemplatesService }], target: i0__namespace.ɵɵFactoryTarget.Component });
3154
- AvatarPlaceholderComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.5", type: AvatarPlaceholderComponent, selector: "stream-avatar-placeholder", inputs: { name: "name", imageUrl: "imageUrl", size: "size", location: "location", channel: "channel", user: "user", type: "type", initialsType: "initialsType" }, usesOnChanges: true, ngImport: i0__namespace, template: "<ng-template\n #defaultAvatar\n let-name=\"name\"\n let-imageUrl=\"imageUrl\"\n let-size=\"size\"\n let-type=\"type\"\n let-channel=\"channel\"\n let-user=\"user\"\n let-location=\"location\"\n let-initialsType=\"initialsType\"\n>\n <stream-avatar\n [name]=\"name\"\n [imageUrl]=\"imageUrl\"\n [size]=\"size\"\n [type]=\"type\"\n [channel]=\"channel\"\n [user]=\"user\"\n [location]=\"location\"\n [initialsType]=\"initialsType\"\n ></stream-avatar>\n</ng-template>\n<ng-container\n *ngTemplateOutlet=\"\n (customTemplatesService.avatarTemplate$ | async) || defaultAvatar;\n context: context\n \"\n></ng-container>\n", components: [{ type: AvatarComponent, selector: "stream-avatar", inputs: ["name", "imageUrl", "size", "location", "channel", "user", "type", "showOnlineIndicator", "initialsType"] }], directives: [{ type: i5__namespace.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "async": i5__namespace.AsyncPipe } });
3204
+ AvatarPlaceholderComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: AvatarPlaceholderComponent, deps: [{ token: CustomTemplatesService }, { token: i0__namespace.ElementRef }, { token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
3205
+ AvatarPlaceholderComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.5", type: AvatarPlaceholderComponent, selector: "stream-avatar-placeholder", inputs: { name: "name", imageUrl: "imageUrl", size: "size", location: "location", channel: "channel", user: "user", type: "type", initialsType: "initialsType" }, usesOnChanges: true, ngImport: i0__namespace, template: "<ng-template\n #defaultAvatar\n let-name=\"name\"\n let-imageUrl=\"imageUrl\"\n let-size=\"size\"\n let-type=\"type\"\n let-channel=\"channel\"\n let-user=\"user\"\n let-location=\"location\"\n let-initialsType=\"initialsType\"\n>\n <stream-avatar\n [name]=\"name\"\n [imageUrl]=\"imageUrl\"\n [size]=\"size\"\n [type]=\"type\"\n [channel]=\"channel\"\n [user]=\"user\"\n [location]=\"location\"\n [initialsType]=\"initialsType\"\n ></stream-avatar>\n</ng-template>\n<ng-container *ngIf=\"isVisible; else emptyPlaceholder\">\n <ng-container\n *ngTemplateOutlet=\"\n (customTemplatesService.avatarTemplate$ | async) || defaultAvatar;\n context: context\n \"\n ></ng-container>\n</ng-container>\n<ng-template #emptyPlaceholder>\n <div\n class=\"str-chat__avatar\"\n [ngStyle]=\"{\n width: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')',\n height: 'calc(var(--str-chat__spacing-px, 1px) * ' + size + ')'\n }\"\n ></div>\n</ng-template>\n", components: [{ type: AvatarComponent, selector: "stream-avatar", inputs: ["name", "imageUrl", "size", "location", "channel", "user", "type", "showOnlineIndicator", "initialsType"] }], directives: [{ type: i5__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5__namespace.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i5__namespace.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], pipes: { "async": i5__namespace.AsyncPipe } });
3155
3206
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0__namespace, type: AvatarPlaceholderComponent, decorators: [{
3156
3207
  type: i0.Component,
3157
3208
  args: [{
@@ -3159,7 +3210,7 @@
3159
3210
  templateUrl: './avatar-placeholder.component.html',
3160
3211
  styles: [],
3161
3212
  }]
3162
- }], ctorParameters: function () { return [{ type: CustomTemplatesService }]; }, propDecorators: { name: [{
3213
+ }], ctorParameters: function () { return [{ type: CustomTemplatesService }, { type: i0__namespace.ElementRef }, { type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { name: [{
3163
3214
  type: i0.Input
3164
3215
  }], imageUrl: [{
3165
3216
  type: i0.Input
@@ -3940,7 +3991,7 @@
3940
3991
  MessageInputComponent.prototype.messageSent = function () {
3941
3992
  var _a;
3942
3993
  return __awaiter(this, void 0, void 0, function () {
3943
- var attachmentUploadInProgressCounter, attachments, text, textContainsOnlySpaceChars, error_1;
3994
+ var attachmentUploadInProgressCounter, attachments, text, textContainsOnlySpaceChars, message, error_1;
3944
3995
  return __generator(this, function (_12) {
3945
3996
  switch (_12.label) {
3946
3997
  case 0:
@@ -3983,8 +4034,8 @@
3983
4034
  ? this.channelService.updateMessage(Object.assign(Object.assign({}, this.message), { text: text, attachments: attachments }))
3984
4035
  : this.channelService.sendMessage(text, attachments, this.mentionedUsers, this.parentMessageId, (_a = this.quotedMessage) === null || _a === void 0 ? void 0 : _a.id))];
3985
4036
  case 2:
3986
- _12.sent();
3987
- this.messageUpdate.emit();
4037
+ message = _12.sent();
4038
+ this.messageUpdate.emit({ message: message });
3988
4039
  if (!this.isUpdate) {
3989
4040
  this.attachmentService.resetAttachmentUploads();
3990
4041
  }