stream-chat-angular 3.7.3 → 3.8.1
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.
- package/assets/version.d.ts +1 -1
- package/bundles/stream-chat-angular.umd.js +56 -26
- package/bundles/stream-chat-angular.umd.js.map +1 -1
- package/esm2015/assets/version.js +2 -2
- package/esm2015/lib/channel.service.js +32 -22
- package/esm2015/lib/chat-client.service.js +6 -3
- package/fesm2015/stream-chat-angular.js +37 -24
- package/fesm2015/stream-chat-angular.js.map +1 -1
- package/lib/chat-client.service.d.ts +2 -2
- package/package.json +1 -1
- package/src/assets/version.ts +1 -1
package/assets/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "3.
|
|
1
|
+
export declare const version = "3.8.1";
|
|
@@ -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.
|
|
357
|
+
var version = '3.8.1';
|
|
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.
|
|
@@ -461,7 +461,7 @@
|
|
|
461
461
|
* Creates a [`StreamChat`](https://github.com/GetStream/stream-chat-js/blob/668b3e5521339f4e14fc657834531b4c8bf8176b/src/client.ts#L124) instance using the provided `apiKey`, and connects a user with the given meta data and token. More info about [connecting users](https://getstream.io/chat/docs/javascript/init_and_users/?language=javascript) can be found in the platform documentation.
|
|
462
462
|
* @param apiKey
|
|
463
463
|
* @param userOrId
|
|
464
|
-
* @param userTokenOrProvider
|
|
464
|
+
* @param userTokenOrProvider You can provide a token, or the keyword 'guest' to connect as [guest user](https://getstream.io/chat/docs/javascript/authless_users/?language=javascript#guest-users)
|
|
465
465
|
*/
|
|
466
466
|
ChatClientService.prototype.init = function (apiKey, userOrId, userTokenOrProvider) {
|
|
467
467
|
var _a;
|
|
@@ -474,14 +474,22 @@
|
|
|
474
474
|
this.chatClient = streamChat.StreamChat.getInstance(apiKey);
|
|
475
475
|
this.chatClient.devToken;
|
|
476
476
|
return [4 /*yield*/, this.ngZone.runOutsideAngular(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
477
|
-
var user;
|
|
478
|
-
return __generator(this, function (
|
|
479
|
-
switch (
|
|
477
|
+
var user, _d;
|
|
478
|
+
return __generator(this, function (_e) {
|
|
479
|
+
switch (_e.label) {
|
|
480
480
|
case 0:
|
|
481
481
|
user = typeof userOrId === 'string' ? { id: userOrId } : userOrId;
|
|
482
|
-
return [
|
|
482
|
+
if (!(userTokenOrProvider === 'guest')) return [3 /*break*/, 2];
|
|
483
|
+
return [4 /*yield*/, this.chatClient.setGuestUser(user)];
|
|
483
484
|
case 1:
|
|
484
|
-
|
|
485
|
+
_d = _e.sent();
|
|
486
|
+
return [3 /*break*/, 4];
|
|
487
|
+
case 2: return [4 /*yield*/, this.chatClient.connectUser(user, userTokenOrProvider)];
|
|
488
|
+
case 3:
|
|
489
|
+
_d = _e.sent();
|
|
490
|
+
_e.label = 4;
|
|
491
|
+
case 4:
|
|
492
|
+
result = _d;
|
|
485
493
|
this.userSubject.next(this.chatClient.user);
|
|
486
494
|
this.chatClient.setUserAgent("stream-chat-angular-" + version + "-" + this.chatClient.getUserAgent());
|
|
487
495
|
return [2 /*return*/];
|
|
@@ -683,11 +691,8 @@
|
|
|
683
691
|
var currentChannels = _this.channelsSubject.getValue() || [];
|
|
684
692
|
var newChannels = channels.filter(function (c) { return !currentChannels.find(function (channel) { return channel.cid === c.cid; }); });
|
|
685
693
|
var deletedChannels = currentChannels.filter(function (c) { return !(channels === null || channels === void 0 ? void 0 : channels.find(function (channel) { return channel.cid === c.cid; })); });
|
|
686
|
-
_this.addChannelsFromNotification(newChannels);
|
|
694
|
+
void _this.addChannelsFromNotification(newChannels);
|
|
687
695
|
_this.removeChannelsFromChannelList(deletedChannels.map(function (c) { return c.cid; }));
|
|
688
|
-
if (!newChannels.length && !deletedChannels.length) {
|
|
689
|
-
_this.channelsSubject.next(channels);
|
|
690
|
-
}
|
|
691
696
|
};
|
|
692
697
|
this.messageListSetter = function (messages) {
|
|
693
698
|
_this.activeChannelMessagesSubject.next(messages);
|
|
@@ -1326,24 +1331,41 @@
|
|
|
1326
1331
|
};
|
|
1327
1332
|
ChannelService.prototype.handleNewMessageNotification = function (clientEvent) {
|
|
1328
1333
|
if (clientEvent.event.channel) {
|
|
1329
|
-
this.addChannelsFromNotification([clientEvent.event.channel]);
|
|
1334
|
+
void this.addChannelsFromNotification([clientEvent.event.channel]);
|
|
1330
1335
|
}
|
|
1331
1336
|
};
|
|
1332
1337
|
ChannelService.prototype.handleAddedToChannelNotification = function (clientEvent) {
|
|
1333
1338
|
if (clientEvent.event.channel) {
|
|
1334
|
-
this.addChannelsFromNotification([clientEvent.event.channel]);
|
|
1339
|
+
void this.addChannelsFromNotification([clientEvent.event.channel]);
|
|
1335
1340
|
}
|
|
1336
1341
|
};
|
|
1337
1342
|
ChannelService.prototype.addChannelsFromNotification = function (channelResponses) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1343
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1344
|
+
var newChannels, watchRequests, currentChannels;
|
|
1345
|
+
var _this = this;
|
|
1346
|
+
return __generator(this, function (_h) {
|
|
1347
|
+
switch (_h.label) {
|
|
1348
|
+
case 0:
|
|
1349
|
+
newChannels = [];
|
|
1350
|
+
watchRequests = [];
|
|
1351
|
+
channelResponses.forEach(function (channelResponse) {
|
|
1352
|
+
var channel = _this.chatClientService.chatClient.channel(channelResponse.type, channelResponse.id);
|
|
1353
|
+
watchRequests.push(channel.watch());
|
|
1354
|
+
newChannels.push(channel);
|
|
1355
|
+
});
|
|
1356
|
+
return [4 /*yield*/, Promise.all(watchRequests)];
|
|
1357
|
+
case 1:
|
|
1358
|
+
_h.sent();
|
|
1359
|
+
currentChannels = this.channelsSubject.getValue() || [];
|
|
1360
|
+
newChannels = newChannels.filter(function (newChannel) { return !currentChannels.find(function (c) { return c.cid === newChannel.cid; }); });
|
|
1361
|
+
if (newChannels.length > 0) {
|
|
1362
|
+
newChannels.forEach(function (c) { return _this.watchForChannelEvents(c); });
|
|
1363
|
+
this.channelsSubject.next(__spreadArray(__spreadArray([], __read(newChannels)), __read(currentChannels)));
|
|
1364
|
+
}
|
|
1365
|
+
return [2 /*return*/];
|
|
1366
|
+
}
|
|
1367
|
+
});
|
|
1345
1368
|
});
|
|
1346
|
-
this.channelsSubject.next(__spreadArray(__spreadArray([], __read(newChannels)), __read((this.channelsSubject.getValue() || []))));
|
|
1347
1369
|
};
|
|
1348
1370
|
ChannelService.prototype.removeChannelsFromChannelList = function (cids) {
|
|
1349
1371
|
var _a;
|
|
@@ -1437,13 +1459,21 @@
|
|
|
1437
1459
|
ChannelService.prototype.messageUpdated = function (event) {
|
|
1438
1460
|
var _this = this;
|
|
1439
1461
|
this.ngZone.run(function () {
|
|
1462
|
+
var _a;
|
|
1440
1463
|
var isThreadReply = event.message && event.message.parent_id;
|
|
1464
|
+
var channel = _this.activeChannelSubject.getValue();
|
|
1465
|
+
if (!channel) {
|
|
1466
|
+
return;
|
|
1467
|
+
}
|
|
1468
|
+
// Get messages from state as message order could change, and message could've been deleted
|
|
1441
1469
|
var messages = isThreadReply
|
|
1442
|
-
?
|
|
1443
|
-
:
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1470
|
+
? channel.state.threads[((_a = event === null || event === void 0 ? void 0 : event.message) === null || _a === void 0 ? void 0 : _a.parent_id) || '']
|
|
1471
|
+
: channel.state.messages;
|
|
1472
|
+
if (!messages) {
|
|
1473
|
+
return;
|
|
1474
|
+
}
|
|
1475
|
+
var messageIndex = messages.findIndex(function (m) { var _a; return m.id === ((_a = event === null || event === void 0 ? void 0 : event.message) === null || _a === void 0 ? void 0 : _a.id); });
|
|
1476
|
+
if (messageIndex !== -1) {
|
|
1447
1477
|
isThreadReply
|
|
1448
1478
|
? _this.activeThreadMessagesSubject.next(__spreadArray([], __read(messages)))
|
|
1449
1479
|
: _this.activeChannelMessagesSubject.next(__spreadArray([], __read(messages)));
|