stream-chat-angular 3.5.0 → 3.5.3

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 = "3.5.0";
1
+ export declare const version = "3.5.3";
@@ -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.5.0';
357
+ var version = '3.5.3';
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,6 +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.subscriptions = [];
452
453
  this.events$ = this.notificationSubject.asObservable();
453
454
  this.connectionState$ = this.connectionStateSubject.asObservable();
454
455
  this.appSettings$ = this.appSettingsSubject.asObservable();
@@ -463,7 +464,7 @@
463
464
  ChatClientService.prototype.init = function (apiKey, userOrId, userTokenOrProvider) {
464
465
  var _a;
465
466
  return __awaiter(this, void 0, void 0, function () {
466
- var channels, removeNotification;
467
+ var result, channels, removeNotification;
467
468
  var _this = this;
468
469
  return __generator(this, function (_d) {
469
470
  switch (_d.label) {
@@ -478,7 +479,7 @@
478
479
  user = typeof userOrId === 'string' ? { id: userOrId } : userOrId;
479
480
  return [4 /*yield*/, this.chatClient.connectUser(user, userTokenOrProvider)];
480
481
  case 1:
481
- _d.sent();
482
+ result = _d.sent();
482
483
  this.chatClient.setUserAgent("stream-chat-angular-" + version + "-" + this.chatClient.getUserAgent());
483
484
  return [2 /*return*/];
484
485
  }
@@ -492,14 +493,14 @@
492
493
  channels = _d.sent();
493
494
  this.pendingInvitesSubject.next(channels);
494
495
  this.appSettingsSubject.next(undefined);
495
- this.chatClient.on(function (e) {
496
+ this.subscriptions.push(this.chatClient.on(function (e) {
496
497
  _this.updatePendingInvites(e);
497
498
  _this.notificationSubject.next({
498
499
  eventType: e.type,
499
500
  event: e,
500
501
  });
501
- });
502
- this.chatClient.on('connection.changed', function (e) {
502
+ }));
503
+ this.subscriptions.push(this.chatClient.on('connection.changed', function (e) {
503
504
  _this.ngZone.run(function () {
504
505
  var isOnline = e.online;
505
506
  if (isOnline) {
@@ -513,8 +514,8 @@
513
514
  }
514
515
  _this.connectionStateSubject.next(isOnline ? 'online' : 'offline');
515
516
  });
516
- });
517
- return [2 /*return*/];
517
+ }));
518
+ return [2 /*return*/, result];
518
519
  }
519
520
  });
520
521
  });
@@ -531,6 +532,7 @@
531
532
  return [4 /*yield*/, this.chatClient.disconnectUser()];
532
533
  case 1:
533
534
  _d.sent();
535
+ this.subscriptions.forEach(function (s) { return s.unsubscribe(); });
534
536
  return [2 /*return*/];
535
537
  }
536
538
  });
@@ -672,6 +674,7 @@
672
674
  this.usersTypingInChannelSubject = new rxjs.BehaviorSubject([]);
673
675
  this.usersTypingInThreadSubject = new rxjs.BehaviorSubject([]);
674
676
  this._shouldMarkActiveChannelAsRead = true;
677
+ this.isStateRecoveryInProgress = false;
675
678
  this.channelListSetter = function (channels) {
676
679
  var currentChannels = _this.channelsSubject.getValue() || [];
677
680
  var newChannels = channels.filter(function (c) { return !currentChannels.find(function (channel) { return channel.cid === c.cid; }); });
@@ -1251,10 +1254,32 @@
1251
1254
  var _this = this;
1252
1255
  switch (clientEvent.eventType) {
1253
1256
  case 'connection.recovered': {
1254
- this.ngZone.run(function () {
1255
- _this.reset();
1256
- void _this.init(_this.filters, _this.sort, _this.options, _this.shouldSetActiveChannel);
1257
- });
1257
+ void this.ngZone.run(function () { return __awaiter(_this, void 0, void 0, function () {
1258
+ var _a_1;
1259
+ return __generator(this, function (_h) {
1260
+ switch (_h.label) {
1261
+ case 0:
1262
+ if (this.isStateRecoveryInProgress) {
1263
+ return [2 /*return*/];
1264
+ }
1265
+ this.isStateRecoveryInProgress = true;
1266
+ this.reset();
1267
+ _h.label = 1;
1268
+ case 1:
1269
+ _h.trys.push([1, 3, , 4]);
1270
+ return [4 /*yield*/, this.init(this.filters, this.sort, this.options, this.shouldSetActiveChannel)];
1271
+ case 2:
1272
+ _h.sent();
1273
+ this.isStateRecoveryInProgress = false;
1274
+ return [3 /*break*/, 4];
1275
+ case 3:
1276
+ _a_1 = _h.sent();
1277
+ this.isStateRecoveryInProgress = false;
1278
+ return [3 /*break*/, 4];
1279
+ case 4: return [2 /*return*/];
1280
+ }
1281
+ });
1282
+ }); });
1258
1283
  break;
1259
1284
  }
1260
1285
  case 'notification.message_new': {
@@ -2251,10 +2276,9 @@
2251
2276
  result = (_e = (_d = this.channel) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.name;
2252
2277
  }
2253
2278
  else {
2254
- var otherMembers = Object.values(((_g = (_f = this.channel) === null || _f === void 0 ? void 0 : _f.state) === null || _g === void 0 ? void 0 : _g.members) || {}).filter(function (m) { return m.user_id !== _this.chatClientService.chatClient.user.id; });
2279
+ var otherMembers = Object.values(((_g = (_f = this.channel) === null || _f === void 0 ? void 0 : _f.state) === null || _g === void 0 ? void 0 : _g.members) || {}).filter(function (m) { var _a; return m.user_id !== ((_a = _this.chatClientService.chatClient.user) === null || _a === void 0 ? void 0 : _a.id); });
2255
2280
  if (otherMembers.length === 1) {
2256
- result =
2257
- ((_h = otherMembers[0].user) === null || _h === void 0 ? void 0 : _h.name) || ((_j = otherMembers[0].user) === null || _j === void 0 ? void 0 : _j.name) || '';
2281
+ result = ((_h = otherMembers[0].user) === null || _h === void 0 ? void 0 : _h.name) || ((_j = otherMembers[0].user) === null || _j === void 0 ? void 0 : _j.id) || '';
2258
2282
  }
2259
2283
  else {
2260
2284
  result = '#';
@@ -3738,7 +3762,7 @@
3738
3762
  if (channel.state.members && Object.keys(channel.state.members).length > 0) {
3739
3763
  var members = Object.values(channel.state.members)
3740
3764
  .map(function (m) { return m.user || { id: m.user_id }; })
3741
- .filter(function (m) { return m.id !== currentUser.id; });
3765
+ .filter(function (m) { return m.id !== (currentUser === null || currentUser === void 0 ? void 0 : currentUser.id); });
3742
3766
  return listUsers(members);
3743
3767
  }
3744
3768
  return channel.id;