stream-chat-angular 3.0.0-beta.4 → 3.0.0-beta.7

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.
Files changed (40) hide show
  1. package/assets/version.d.ts +1 -1
  2. package/bundles/stream-chat-angular.umd.js +37 -68
  3. package/bundles/stream-chat-angular.umd.js.map +1 -1
  4. package/esm2015/assets/version.js +2 -2
  5. package/esm2015/lib/attachment-list/attachment-list.component.js +1 -1
  6. package/esm2015/lib/channel-header/channel-header.component.js +1 -1
  7. package/esm2015/lib/channel-list/channel-list.component.js +1 -1
  8. package/esm2015/lib/channel-preview/channel-preview.component.js +1 -1
  9. package/esm2015/lib/channel.service.js +28 -35
  10. package/esm2015/lib/chat-client.service.js +5 -4
  11. package/esm2015/lib/message/message.component.js +1 -1
  12. package/esm2015/lib/message-actions-box/message-actions-box.component.js +5 -17
  13. package/esm2015/lib/message-input/message-input.component.js +1 -1
  14. package/esm2015/lib/message-list/message-list.component.js +1 -1
  15. package/esm2015/lib/message-preview.js +4 -17
  16. package/esm2015/lib/message-reactions/message-reactions.component.js +1 -1
  17. package/esm2015/lib/read-by.js +1 -1
  18. package/esm2015/lib/types.js +1 -1
  19. package/fesm2015/stream-chat-angular.js +39 -70
  20. package/fesm2015/stream-chat-angular.js.map +1 -1
  21. package/lib/attachment-list/attachment-list.component.d.ts +6 -6
  22. package/lib/attachment.service.d.ts +1 -1
  23. package/lib/channel-header/channel-header.component.d.ts +3 -3
  24. package/lib/channel-list/channel-list.component.d.ts +4 -4
  25. package/lib/channel-preview/channel-preview.component.d.ts +3 -2
  26. package/lib/channel.service.d.ts +32 -30
  27. package/lib/chat-client.service.d.ts +12 -11
  28. package/lib/custom-templates.service.d.ts +2 -2
  29. package/lib/message/message.component.d.ts +22 -3
  30. package/lib/message-actions-box/message-actions-box.component.d.ts +1 -1
  31. package/lib/message-input/autocomplete-textarea/autocomplete-textarea.component.d.ts +1 -1
  32. package/lib/message-input/message-input.component.d.ts +21 -2
  33. package/lib/message-input/textarea.directive.d.ts +1 -1
  34. package/lib/message-list/group-styles.d.ts +1 -1
  35. package/lib/message-preview.d.ts +2 -1
  36. package/lib/message-reactions/message-reactions.component.d.ts +4 -4
  37. package/lib/read-by.d.ts +2 -1
  38. package/lib/types.d.ts +26 -19
  39. package/package.json +2 -2
  40. package/src/assets/version.ts +1 -1
@@ -1 +1 @@
1
- export declare const version = "3.0.0-beta.4";
1
+ export declare const version = "3.0.0-beta.7";
@@ -354,7 +354,7 @@
354
354
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
355
355
  }
356
356
 
357
- var version = '3.0.0-beta.4';
357
+ var version = '3.0.0-beta.7';
358
358
 
359
359
  /**
360
360
  * The `NotificationService` can be used to add or remove notifications. By default the [`NotificationList`](../components/NotificationListComponent.mdx) component displays the currently active notifications.
@@ -449,7 +449,7 @@
449
449
  this.connectionStateSubject = new rxjs.ReplaySubject(1);
450
450
  this.appSettingsSubject = new rxjs.BehaviorSubject(undefined);
451
451
  this.pendingInvitesSubject = new rxjs.BehaviorSubject([]);
452
- this.notification$ = this.notificationSubject.asObservable();
452
+ this.events$ = this.notificationSubject.asObservable();
453
453
  this.connectionState$ = this.connectionStateSubject.asObservable();
454
454
  this.appSettings$ = this.appSettingsSubject.asObservable();
455
455
  this.pendingInvites$ = this.pendingInvitesSubject.asObservable();
@@ -486,7 +486,8 @@
486
486
  }); })];
487
487
  case 1:
488
488
  _d.sent();
489
- return [4 /*yield*/, this.chatClient.queryChannels({ invite: 'pending' }, {}, { user_id: (_a = this.chatClient.user) === null || _a === void 0 ? void 0 : _a.id })];
489
+ return [4 /*yield*/, this.chatClient.queryChannels({ invite: 'pending' }, // TODO: find out why we need this typecast
490
+ {}, { user_id: (_a = this.chatClient.user) === null || _a === void 0 ? void 0 : _a.id })];
490
491
  case 2:
491
492
  channels = _d.sent();
492
493
  this.pendingInvitesSubject.next(channels);
@@ -628,27 +629,13 @@
628
629
  }]
629
630
  }], ctorParameters: function () { return [{ type: i0__namespace.NgZone }, { type: NotificationService }]; } });
630
631
 
631
- var createMessagePreview = function (user, text, attachments, mentionedUsers, parentId, quotedMessageId) {
632
+ var createMessagePreview = function (user, text, attachments, mentionedUsers, parentId, quotedMessageId, customData) {
632
633
  if (attachments === void 0) { attachments = []; }
633
634
  if (mentionedUsers === void 0) { mentionedUsers = []; }
634
635
  if (parentId === void 0) { parentId = undefined; }
635
636
  if (quotedMessageId === void 0) { quotedMessageId = undefined; }
636
637
  var clientSideId = user.id + "-" + uuid.v4();
637
- return {
638
- __html: text,
639
- created_at: new Date(),
640
- html: text,
641
- id: clientSideId,
642
- reactions: [],
643
- status: 'sending',
644
- text: text,
645
- type: 'regular',
646
- user: user,
647
- attachments: attachments,
648
- mentioned_users: mentionedUsers,
649
- parent_id: parentId,
650
- quoted_message_id: quotedMessageId,
651
- };
638
+ return Object.assign({ __html: text, created_at: new Date(), html: text, id: clientSideId, reactions: [], status: 'sending', text: text, type: 'regular', user: user, attachments: attachments, mentioned_users: mentionedUsers, parent_id: parentId, quoted_message_id: quotedMessageId }, customData);
652
639
  };
653
640
 
654
641
  var getReadBy = function (message, channel) {
@@ -875,7 +862,7 @@
875
862
  return [4 /*yield*/, this.queryChannels()];
876
863
  case 1:
877
864
  _h.sent();
878
- this.chatClientService.notification$.subscribe(function (notification) { return void _this.handleNotification(notification); });
865
+ this.chatClientService.events$.subscribe(function (notification) { return void _this.handleNotification(notification); });
879
866
  return [2 /*return*/];
880
867
  }
881
868
  });
@@ -914,15 +901,14 @@
914
901
  * Adds a reaction to a message.
915
902
  * @param messageId The id of the message to add the reaction to
916
903
  * @param reactionType The type of the reaction
904
+ * @param customData
917
905
  */
918
- ChannelService.prototype.addReaction = function (messageId, reactionType) {
906
+ ChannelService.prototype.addReaction = function (messageId, reactionType, customData) {
919
907
  var _a;
920
908
  return __awaiter(this, void 0, void 0, function () {
921
909
  return __generator(this, function (_h) {
922
910
  switch (_h.label) {
923
- case 0: return [4 /*yield*/, ((_a = this.activeChannelSubject.getValue()) === null || _a === void 0 ? void 0 : _a.sendReaction(messageId, {
924
- type: reactionType,
925
- }))];
911
+ case 0: return [4 /*yield*/, ((_a = this.activeChannelSubject.getValue()) === null || _a === void 0 ? void 0 : _a.sendReaction(messageId, Object.assign({ type: reactionType }, customData)))];
926
912
  case 1:
927
913
  _h.sent();
928
914
  return [2 /*return*/];
@@ -956,22 +942,24 @@
956
942
  * @param mentionedUsers Mentioned users
957
943
  * @param parentId Id of the parent message (if sending a thread reply)
958
944
  * @param quotedMessageId Id of the message to quote (if sending a quote reply)
945
+ * @param customData
959
946
  */
960
- ChannelService.prototype.sendMessage = function (text, attachments, mentionedUsers, parentId, quotedMessageId) {
947
+ ChannelService.prototype.sendMessage = function (text, attachments, mentionedUsers, parentId, quotedMessageId, customData) {
961
948
  if (attachments === void 0) { attachments = []; }
962
949
  if (mentionedUsers === void 0) { mentionedUsers = []; }
963
950
  if (parentId === void 0) { parentId = undefined; }
964
951
  if (quotedMessageId === void 0) { quotedMessageId = undefined; }
952
+ if (customData === void 0) { customData = undefined; }
965
953
  return __awaiter(this, void 0, void 0, function () {
966
954
  var preview, channel;
967
955
  return __generator(this, function (_h) {
968
956
  switch (_h.label) {
969
957
  case 0:
970
- preview = createMessagePreview(this.chatClientService.chatClient.user, text, attachments, mentionedUsers, parentId, quotedMessageId);
958
+ preview = createMessagePreview(this.chatClientService.chatClient.user, text, attachments, mentionedUsers, parentId, quotedMessageId, customData);
971
959
  channel = this.activeChannelSubject.getValue();
972
960
  preview.readBy = [];
973
961
  channel.state.addMessageSorted(preview, true);
974
- return [4 /*yield*/, this.sendMessageRequest(preview)];
962
+ return [4 /*yield*/, this.sendMessageRequest(preview, customData)];
975
963
  case 1:
976
964
  _h.sent();
977
965
  return [2 /*return*/];
@@ -1170,7 +1158,7 @@
1170
1158
  ChannelService.prototype.selectMessageToQuote = function (message) {
1171
1159
  this.messageToQuoteSubject.next(message);
1172
1160
  };
1173
- ChannelService.prototype.sendMessageRequest = function (preview) {
1161
+ ChannelService.prototype.sendMessageRequest = function (preview, customData) {
1174
1162
  var _a;
1175
1163
  return __awaiter(this, void 0, void 0, function () {
1176
1164
  var channel, isThreadReply, response, error_1, stringError, parsedError;
@@ -1185,14 +1173,7 @@
1185
1173
  _h.label = 1;
1186
1174
  case 1:
1187
1175
  _h.trys.push([1, 3, , 4]);
1188
- return [4 /*yield*/, channel.sendMessage({
1189
- text: preview.text,
1190
- attachments: preview.attachments,
1191
- mentioned_users: (_a = preview.mentioned_users) === null || _a === void 0 ? void 0 : _a.map(function (u) { return u.id; }),
1192
- id: preview.id,
1193
- parent_id: preview.parent_id,
1194
- quoted_message_id: preview.quoted_message_id,
1195
- })];
1176
+ 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))];
1196
1177
  case 2:
1197
1178
  response = _h.sent();
1198
1179
  if (response === null || response === void 0 ? void 0 : response.message) {
@@ -1218,16 +1199,16 @@
1218
1199
  });
1219
1200
  });
1220
1201
  };
1221
- ChannelService.prototype.handleNotification = function (notification) {
1202
+ ChannelService.prototype.handleNotification = function (clientEvent) {
1222
1203
  var _this = this;
1223
- switch (notification.eventType) {
1204
+ switch (clientEvent.eventType) {
1224
1205
  case 'notification.message_new': {
1225
1206
  this.ngZone.run(function () {
1226
1207
  if (_this.customNewMessageNotificationHandler) {
1227
- _this.customNewMessageNotificationHandler(notification, _this.channelListSetter);
1208
+ _this.customNewMessageNotificationHandler(clientEvent, _this.channelListSetter);
1228
1209
  }
1229
1210
  else {
1230
- _this.handleNewMessageNotification(notification);
1211
+ _this.handleNewMessageNotification(clientEvent);
1231
1212
  }
1232
1213
  });
1233
1214
  break;
@@ -1235,10 +1216,10 @@
1235
1216
  case 'notification.added_to_channel': {
1236
1217
  this.ngZone.run(function () {
1237
1218
  if (_this.customAddedToChannelNotificationHandler) {
1238
- _this.customAddedToChannelNotificationHandler(notification, _this.channelListSetter);
1219
+ _this.customAddedToChannelNotificationHandler(clientEvent, _this.channelListSetter);
1239
1220
  }
1240
1221
  else {
1241
- _this.handleAddedToChannelNotification(notification);
1222
+ _this.handleAddedToChannelNotification(clientEvent);
1242
1223
  }
1243
1224
  });
1244
1225
  break;
@@ -1246,27 +1227,27 @@
1246
1227
  case 'notification.removed_from_channel': {
1247
1228
  this.ngZone.run(function () {
1248
1229
  if (_this.customRemovedFromChannelNotificationHandler) {
1249
- _this.customRemovedFromChannelNotificationHandler(notification, _this.channelListSetter);
1230
+ _this.customRemovedFromChannelNotificationHandler(clientEvent, _this.channelListSetter);
1250
1231
  }
1251
1232
  else {
1252
- _this.handleRemovedFromChannelNotification(notification);
1233
+ _this.handleRemovedFromChannelNotification(clientEvent);
1253
1234
  }
1254
1235
  });
1255
1236
  }
1256
1237
  }
1257
1238
  };
1258
- ChannelService.prototype.handleRemovedFromChannelNotification = function (notification) {
1259
- var channelIdToBeRemoved = notification.event.channel.cid;
1239
+ ChannelService.prototype.handleRemovedFromChannelNotification = function (clientEvent) {
1240
+ var channelIdToBeRemoved = clientEvent.event.channel.cid;
1260
1241
  this.removeChannelsFromChannelList([channelIdToBeRemoved]);
1261
1242
  };
1262
- ChannelService.prototype.handleNewMessageNotification = function (notification) {
1263
- if (notification.event.channel) {
1264
- this.addChannelsFromNotification([notification.event.channel]);
1243
+ ChannelService.prototype.handleNewMessageNotification = function (clientEvent) {
1244
+ if (clientEvent.event.channel) {
1245
+ this.addChannelsFromNotification([clientEvent.event.channel]);
1265
1246
  }
1266
1247
  };
1267
- ChannelService.prototype.handleAddedToChannelNotification = function (notification) {
1268
- if (notification.event.channel) {
1269
- this.addChannelsFromNotification([notification.event.channel]);
1248
+ ChannelService.prototype.handleAddedToChannelNotification = function (clientEvent) {
1249
+ if (clientEvent.event.channel) {
1250
+ this.addChannelsFromNotification([clientEvent.event.channel]);
1270
1251
  }
1271
1252
  };
1272
1253
  ChannelService.prototype.addChannelsFromNotification = function (channelResponses) {
@@ -3424,15 +3405,14 @@
3424
3405
  actionName: 'quote',
3425
3406
  actionLabelOrTranslationKey: 'streamChat.Reply',
3426
3407
  actionHandler: function (message) { return _this.channelService.selectMessageToQuote(message); },
3427
- isVisible: function (enabledActions, isMine, message) { return (enabledActions.indexOf('quote') !== -1 ||
3428
- enabledActions.indexOf('quote-message') !== -1) &&
3408
+ isVisible: function (enabledActions, isMine, message) { return enabledActions.indexOf('quote-message') !== -1 &&
3429
3409
  !(message === null || message === void 0 ? void 0 : message.quoted_message); },
3430
3410
  },
3431
3411
  {
3432
3412
  actionName: 'pin',
3433
3413
  actionLabelOrTranslationKey: function () { var _a; return ((_a = _this.message) === null || _a === void 0 ? void 0 : _a.pinned) ? 'streamChat.Unpin' : 'streamChat.Pin'; },
3434
3414
  actionHandler: function () { return alert('Feature not yet implemented'); },
3435
- isVisible: function (enabledActions) { return enabledActions.indexOf('pin') !== -1; },
3415
+ isVisible: function () { return false; },
3436
3416
  },
3437
3417
  {
3438
3418
  actionName: 'flag',
@@ -3456,15 +3436,7 @@
3456
3436
  }
3457
3437
  });
3458
3438
  }); },
3459
- isVisible: function (enabledActions, isMine) { return (enabledActions.indexOf('flag') !== -1 ||
3460
- enabledActions.indexOf('flag-message') !== -1) &&
3461
- !isMine; },
3462
- },
3463
- {
3464
- actionName: 'mute',
3465
- actionLabelOrTranslationKey: 'streamChat.Mute',
3466
- actionHandler: function () { return alert('Feature not yet implemented'); },
3467
- isVisible: function (enabledActions) { return enabledActions.indexOf('mute') !== -1; },
3439
+ isVisible: function (enabledActions, isMine) { return enabledActions.indexOf('flag-message') !== -1 && !isMine; },
3468
3440
  },
3469
3441
  {
3470
3442
  actionName: 'edit',
@@ -3473,10 +3445,7 @@
3473
3445
  _this.isEditing.emit(true);
3474
3446
  _this.isEditModalOpen = true;
3475
3447
  },
3476
- isVisible: function (enabledActions, isMine) { return ((enabledActions.indexOf('edit') !== -1 ||
3477
- enabledActions.indexOf('update-own-message') !== -1) &&
3478
- isMine) ||
3479
- enabledActions.indexOf('edit-any') !== -1 ||
3448
+ isVisible: function (enabledActions, isMine) { return (enabledActions.indexOf('update-own-message') !== -1 && isMine) ||
3480
3449
  enabledActions.indexOf('update-any-message') !== -1; },
3481
3450
  },
3482
3451
  {