stream-chat-angular 2.6.0 → 2.6.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 +156 -141
- package/bundles/stream-chat-angular.umd.js.map +1 -1
- package/esm2015/assets/version.js +2 -2
- package/esm2015/lib/channel-preview/channel-preview.component.js +22 -17
- package/esm2015/lib/channel.service.js +92 -83
- package/esm2015/lib/chat-client.service.js +19 -32
- package/fesm2015/stream-chat-angular.js +131 -130
- package/fesm2015/stream-chat-angular.js.map +1 -1
- package/lib/channel-preview/channel-preview.component.d.ts +3 -2
- package/lib/channel.service.d.ts +2 -3
- package/lib/chat-client.service.d.ts +3 -4
- package/package.json +1 -1
- package/src/assets/version.ts +1 -1
|
@@ -6,9 +6,8 @@ import { version } from '../assets/version';
|
|
|
6
6
|
import * as i0 from "@angular/core";
|
|
7
7
|
import * as i1 from "./notification.service";
|
|
8
8
|
export class ChatClientService {
|
|
9
|
-
constructor(ngZone,
|
|
9
|
+
constructor(ngZone, notificationService) {
|
|
10
10
|
this.ngZone = ngZone;
|
|
11
|
-
this.appRef = appRef;
|
|
12
11
|
this.notificationService = notificationService;
|
|
13
12
|
this.notificationSubject = new ReplaySubject(1);
|
|
14
13
|
this.connectionStateSubject = new ReplaySubject(1);
|
|
@@ -23,42 +22,30 @@ export class ChatClientService {
|
|
|
23
22
|
yield this.ngZone.runOutsideAngular(() => __awaiter(this, void 0, void 0, function* () {
|
|
24
23
|
yield this.chatClient.connectUser({ id: userId }, userToken);
|
|
25
24
|
this.chatClient.setUserAgent(`stream-chat-angular-${version}-${this.chatClient.getUserAgent()}`);
|
|
25
|
+
this.chatClient.getAppSettings;
|
|
26
26
|
}));
|
|
27
27
|
this.appSettingsSubject.next(undefined);
|
|
28
|
-
this.chatClient.on(
|
|
28
|
+
this.chatClient.on((e) => {
|
|
29
29
|
this.notificationSubject.next({
|
|
30
|
-
eventType:
|
|
30
|
+
eventType: e.type,
|
|
31
31
|
event: e,
|
|
32
32
|
});
|
|
33
|
-
this.appRef.tick();
|
|
34
|
-
});
|
|
35
|
-
this.chatClient.on('notification.message_new', (e) => {
|
|
36
|
-
this.notificationSubject.next({
|
|
37
|
-
eventType: 'notification.message_new',
|
|
38
|
-
event: e,
|
|
39
|
-
});
|
|
40
|
-
this.appRef.tick();
|
|
41
|
-
});
|
|
42
|
-
this.chatClient.on('notification.removed_from_channel', (e) => {
|
|
43
|
-
this.notificationSubject.next({
|
|
44
|
-
eventType: 'notification.removed_from_channel',
|
|
45
|
-
event: e,
|
|
46
|
-
});
|
|
47
|
-
this.appRef.tick();
|
|
48
33
|
});
|
|
49
34
|
let removeNotification;
|
|
50
35
|
this.chatClient.on('connection.changed', (e) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
removeNotification
|
|
36
|
+
this.ngZone.run(() => {
|
|
37
|
+
const isOnline = e.online;
|
|
38
|
+
if (isOnline) {
|
|
39
|
+
if (removeNotification) {
|
|
40
|
+
removeNotification();
|
|
41
|
+
}
|
|
55
42
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
43
|
+
else {
|
|
44
|
+
removeNotification =
|
|
45
|
+
this.notificationService.addPermanentNotification('streamChat.Connection failure, reconnecting now...');
|
|
46
|
+
}
|
|
47
|
+
this.connectionStateSubject.next(isOnline ? 'online' : 'offline');
|
|
48
|
+
});
|
|
62
49
|
});
|
|
63
50
|
});
|
|
64
51
|
}
|
|
@@ -92,12 +79,12 @@ export class ChatClientService {
|
|
|
92
79
|
});
|
|
93
80
|
}
|
|
94
81
|
}
|
|
95
|
-
ChatClientService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChatClientService, deps: [{ token: i0.NgZone }, { token:
|
|
82
|
+
ChatClientService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChatClientService, deps: [{ token: i0.NgZone }, { token: i1.NotificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
96
83
|
ChatClientService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChatClientService, providedIn: 'root' });
|
|
97
84
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChatClientService, decorators: [{
|
|
98
85
|
type: Injectable,
|
|
99
86
|
args: [{
|
|
100
87
|
providedIn: 'root',
|
|
101
88
|
}]
|
|
102
|
-
}], ctorParameters: function () { return [{ type: i0.NgZone }, { type:
|
|
103
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
89
|
+
}], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i1.NotificationService }]; } });
|
|
90
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhdC1jbGllbnQuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL3N0cmVhbS1jaGF0LWFuZ3VsYXIvc3JjL2xpYi9jaGF0LWNsaWVudC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFVLE1BQU0sZUFBZSxDQUFDO0FBQ25ELE9BQU8sRUFBRSxlQUFlLEVBQWMsYUFBYSxFQUFFLE1BQU0sTUFBTSxDQUFDO0FBQ2xFLE9BQU8sRUFBc0IsVUFBVSxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBQzdELE9BQU8sRUFBRSxPQUFPLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQzs7O0FBVzVDLE1BQU0sT0FBTyxpQkFBaUI7SUFXNUIsWUFDVSxNQUFjLEVBQ2QsbUJBQXdDO1FBRHhDLFd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sdWUoKSkge1xuICAgICAgcmV0dXJuO1xuICAgIH1cbiAgICBjb25zdCBzZXR0aW5ncyA9IGF3YWl0IHRoaXMuY2hhdENsaWVudC5nZXRBcHBTZXR0aW5ncygpO1xuICAgIHRoaXMuYXBwU2V0dGluZ3NTdWJqZWN0Lm5leHQoc2V0dGluZ3MuYXBwIHx8IHt9KTtcbiAgfVxuXG4gIGFzeW5jIGZsYWdNZXNzYWdlKG1lc3NhZ2VJZDogc3RyaW5nKSB7XG4gICAgYXdhaXQgdGhpcy5jaGF0Q2xpZW50LmZsYWdNZXNzYWdlKG1lc3NhZ2VJZCk7XG4gIH1cblxuICBhc3luYyBhdXRvY29tcGxldGVVc2VycyhzZWFyY2hUZXJtOiBzdHJpbmcpIHtcbiAgICBpZiAoIXNlYXJjaFRlcm0pIHtcbiAgICAgIHJldHVybiBbXTtcbiAgICB9XG4gICAgY29uc3QgcmVzdWx0ID0gYXdhaXQgdGhpcy5jaGF0Q2xpZW50LnF1ZXJ5VXNlcnMoe1xuICAgICAgJG9yOiBbXG4gICAgICAgIHsgaWQ6IHsgJGF1dG9jb21wbGV0ZTogc2VhcmNoVGVybSB9IH0sXG4gICAgICAgIHsgbmFtZTogeyAkYXV0b2NvbXBsZXRlOiBzZWFyY2hUZXJtIH0gfSxcbiAgICAgIF0sXG4gICAgICBpZDogeyAkbmU6IHRoaXMuY2hhdENsaWVudC51c2VySUQhIH0sXG4gICAgfSk7XG4gICAgcmV0dXJuIHJlc3VsdC51c2VycztcbiAgfVxufVxuIl19
|
|
@@ -16,7 +16,7 @@ import transliterate from '@stream-io/transliterate';
|
|
|
16
16
|
import * as i5 from 'angular-mentions';
|
|
17
17
|
import { MentionModule } from 'angular-mentions';
|
|
18
18
|
|
|
19
|
-
const version = '2.6.
|
|
19
|
+
const version = '2.6.1';
|
|
20
20
|
|
|
21
21
|
class NotificationService {
|
|
22
22
|
constructor() {
|
|
@@ -61,9 +61,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImpor
|
|
|
61
61
|
}], ctorParameters: function () { return []; } });
|
|
62
62
|
|
|
63
63
|
class ChatClientService {
|
|
64
|
-
constructor(ngZone,
|
|
64
|
+
constructor(ngZone, notificationService) {
|
|
65
65
|
this.ngZone = ngZone;
|
|
66
|
-
this.appRef = appRef;
|
|
67
66
|
this.notificationService = notificationService;
|
|
68
67
|
this.notificationSubject = new ReplaySubject(1);
|
|
69
68
|
this.connectionStateSubject = new ReplaySubject(1);
|
|
@@ -78,42 +77,30 @@ class ChatClientService {
|
|
|
78
77
|
yield this.ngZone.runOutsideAngular(() => __awaiter(this, void 0, void 0, function* () {
|
|
79
78
|
yield this.chatClient.connectUser({ id: userId }, userToken);
|
|
80
79
|
this.chatClient.setUserAgent(`stream-chat-angular-${version}-${this.chatClient.getUserAgent()}`);
|
|
80
|
+
this.chatClient.getAppSettings;
|
|
81
81
|
}));
|
|
82
82
|
this.appSettingsSubject.next(undefined);
|
|
83
|
-
this.chatClient.on(
|
|
83
|
+
this.chatClient.on((e) => {
|
|
84
84
|
this.notificationSubject.next({
|
|
85
|
-
eventType:
|
|
85
|
+
eventType: e.type,
|
|
86
86
|
event: e,
|
|
87
87
|
});
|
|
88
|
-
this.appRef.tick();
|
|
89
|
-
});
|
|
90
|
-
this.chatClient.on('notification.message_new', (e) => {
|
|
91
|
-
this.notificationSubject.next({
|
|
92
|
-
eventType: 'notification.message_new',
|
|
93
|
-
event: e,
|
|
94
|
-
});
|
|
95
|
-
this.appRef.tick();
|
|
96
|
-
});
|
|
97
|
-
this.chatClient.on('notification.removed_from_channel', (e) => {
|
|
98
|
-
this.notificationSubject.next({
|
|
99
|
-
eventType: 'notification.removed_from_channel',
|
|
100
|
-
event: e,
|
|
101
|
-
});
|
|
102
|
-
this.appRef.tick();
|
|
103
88
|
});
|
|
104
89
|
let removeNotification;
|
|
105
90
|
this.chatClient.on('connection.changed', (e) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
if (
|
|
109
|
-
removeNotification
|
|
91
|
+
this.ngZone.run(() => {
|
|
92
|
+
const isOnline = e.online;
|
|
93
|
+
if (isOnline) {
|
|
94
|
+
if (removeNotification) {
|
|
95
|
+
removeNotification();
|
|
96
|
+
}
|
|
110
97
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
98
|
+
else {
|
|
99
|
+
removeNotification =
|
|
100
|
+
this.notificationService.addPermanentNotification('streamChat.Connection failure, reconnecting now...');
|
|
101
|
+
}
|
|
102
|
+
this.connectionStateSubject.next(isOnline ? 'online' : 'offline');
|
|
103
|
+
});
|
|
117
104
|
});
|
|
118
105
|
});
|
|
119
106
|
}
|
|
@@ -147,14 +134,14 @@ class ChatClientService {
|
|
|
147
134
|
});
|
|
148
135
|
}
|
|
149
136
|
}
|
|
150
|
-
ChatClientService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChatClientService, deps: [{ token: i0.NgZone }, { token:
|
|
137
|
+
ChatClientService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChatClientService, deps: [{ token: i0.NgZone }, { token: NotificationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
151
138
|
ChatClientService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChatClientService, providedIn: 'root' });
|
|
152
139
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChatClientService, decorators: [{
|
|
153
140
|
type: Injectable,
|
|
154
141
|
args: [{
|
|
155
142
|
providedIn: 'root',
|
|
156
143
|
}]
|
|
157
|
-
}], ctorParameters: function () { return [{ type: i0.NgZone }, { type:
|
|
144
|
+
}], ctorParameters: function () { return [{ type: i0.NgZone }, { type: NotificationService }]; } });
|
|
158
145
|
|
|
159
146
|
const createMessagePreview = (user, text, attachments, mentionedUsers) => {
|
|
160
147
|
const clientSideId = `${user.id}-${v4()}`;
|
|
@@ -187,9 +174,8 @@ const getReadBy = (message, channel) => {
|
|
|
187
174
|
};
|
|
188
175
|
|
|
189
176
|
class ChannelService {
|
|
190
|
-
constructor(chatClientService,
|
|
177
|
+
constructor(chatClientService, ngZone) {
|
|
191
178
|
this.chatClientService = chatClientService;
|
|
192
|
-
this.appRef = appRef;
|
|
193
179
|
this.ngZone = ngZone;
|
|
194
180
|
this.channelsSubject = new BehaviorSubject(undefined);
|
|
195
181
|
this.activeChannelSubject = new BehaviorSubject(undefined);
|
|
@@ -400,39 +386,43 @@ class ChannelService {
|
|
|
400
386
|
return __awaiter(this, void 0, void 0, function* () {
|
|
401
387
|
switch (notification.eventType) {
|
|
402
388
|
case 'notification.message_new': {
|
|
403
|
-
|
|
404
|
-
this.customNewMessageNotificationHandler
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
389
|
+
yield this.ngZone.run(() => __awaiter(this, void 0, void 0, function* () {
|
|
390
|
+
if (this.customNewMessageNotificationHandler) {
|
|
391
|
+
this.customNewMessageNotificationHandler(notification, this.channelListSetter);
|
|
392
|
+
}
|
|
393
|
+
else {
|
|
394
|
+
yield this.handleNewMessageNotification(notification);
|
|
395
|
+
}
|
|
396
|
+
}));
|
|
409
397
|
break;
|
|
410
398
|
}
|
|
411
399
|
case 'notification.added_to_channel': {
|
|
412
|
-
|
|
413
|
-
this.customAddedToChannelNotificationHandler
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
400
|
+
yield this.ngZone.run(() => __awaiter(this, void 0, void 0, function* () {
|
|
401
|
+
if (this.customAddedToChannelNotificationHandler) {
|
|
402
|
+
this.customAddedToChannelNotificationHandler(notification, this.channelListSetter);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
yield this.handleAddedToChannelNotification(notification);
|
|
406
|
+
}
|
|
407
|
+
}));
|
|
418
408
|
break;
|
|
419
409
|
}
|
|
420
410
|
case 'notification.removed_from_channel': {
|
|
421
|
-
|
|
422
|
-
this.customRemovedFromChannelNotificationHandler
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
411
|
+
this.ngZone.run(() => {
|
|
412
|
+
if (this.customRemovedFromChannelNotificationHandler) {
|
|
413
|
+
this.customRemovedFromChannelNotificationHandler(notification, this.channelListSetter);
|
|
414
|
+
}
|
|
415
|
+
else {
|
|
416
|
+
this.handleRemovedFromChannelNotification(notification);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
427
419
|
}
|
|
428
420
|
}
|
|
429
421
|
});
|
|
430
422
|
}
|
|
431
423
|
handleRemovedFromChannelNotification(notification) {
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
this.removeFromChannelList(channelIdToBeRemoved);
|
|
435
|
-
});
|
|
424
|
+
const channelIdToBeRemoved = notification.event.channel.cid;
|
|
425
|
+
this.removeFromChannelList(channelIdToBeRemoved);
|
|
436
426
|
}
|
|
437
427
|
handleNewMessageNotification(notification) {
|
|
438
428
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -450,12 +440,10 @@ class ChannelService {
|
|
|
450
440
|
const channel = this.chatClientService.chatClient.channel((_a = notification.event.channel) === null || _a === void 0 ? void 0 : _a.type, (_b = notification.event.channel) === null || _b === void 0 ? void 0 : _b.id);
|
|
451
441
|
yield channel.watch();
|
|
452
442
|
this.watchForChannelEvents(channel);
|
|
453
|
-
this.
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
]);
|
|
458
|
-
});
|
|
443
|
+
this.channelsSubject.next([
|
|
444
|
+
channel,
|
|
445
|
+
...(this.channelsSubject.getValue() || []),
|
|
446
|
+
]);
|
|
459
447
|
});
|
|
460
448
|
}
|
|
461
449
|
removeFromChannelList(cid) {
|
|
@@ -484,15 +472,17 @@ class ChannelService {
|
|
|
484
472
|
this.activeChannelSubscriptions.push(channel.on('reaction.deleted', (e) => this.messageReactionEventReceived(e)));
|
|
485
473
|
this.activeChannelSubscriptions.push(channel.on('reaction.updated', (e) => this.messageReactionEventReceived(e)));
|
|
486
474
|
this.activeChannelSubscriptions.push(channel.on('message.read', (e) => {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
475
|
+
this.ngZone.run(() => {
|
|
476
|
+
let latestMessage;
|
|
477
|
+
this.activeChannelMessages$.pipe(first()).subscribe((messages) => {
|
|
478
|
+
latestMessage = messages[messages.length - 1];
|
|
479
|
+
});
|
|
480
|
+
if (!latestMessage || !e.user) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
latestMessage.readBy = getReadBy(latestMessage, channel);
|
|
484
|
+
this.activeChannelMessagesSubject.next(this.activeChannelMessagesSubject.getValue());
|
|
490
485
|
});
|
|
491
|
-
if (!latestMessage || !e.user) {
|
|
492
|
-
return;
|
|
493
|
-
}
|
|
494
|
-
latestMessage.readBy = getReadBy(latestMessage, channel);
|
|
495
|
-
this.activeChannelMessagesSubject.next(this.activeChannelMessagesSubject.getValue());
|
|
496
486
|
}));
|
|
497
487
|
}
|
|
498
488
|
messageUpdated(event) {
|
|
@@ -566,66 +556,72 @@ class ChannelService {
|
|
|
566
556
|
channel.on((event) => {
|
|
567
557
|
switch (event.type) {
|
|
568
558
|
case 'message.new': {
|
|
569
|
-
|
|
570
|
-
this.customNewMessageHandler
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
559
|
+
this.ngZone.run(() => {
|
|
560
|
+
if (this.customNewMessageHandler) {
|
|
561
|
+
this.customNewMessageHandler(event, channel, this.channelListSetter, this.messageListSetter);
|
|
562
|
+
}
|
|
563
|
+
else {
|
|
564
|
+
this.handleNewMessage(event, channel);
|
|
565
|
+
}
|
|
566
|
+
});
|
|
575
567
|
break;
|
|
576
568
|
}
|
|
577
569
|
case 'channel.hidden': {
|
|
578
|
-
|
|
579
|
-
this.customChannelHiddenHandler
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
570
|
+
this.ngZone.run(() => {
|
|
571
|
+
if (this.customChannelHiddenHandler) {
|
|
572
|
+
this.customChannelHiddenHandler(event, channel, this.channelListSetter, this.messageListSetter);
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
this.handleChannelHidden(event);
|
|
576
|
+
}
|
|
577
|
+
});
|
|
585
578
|
break;
|
|
586
579
|
}
|
|
587
580
|
case 'channel.deleted': {
|
|
588
|
-
|
|
589
|
-
this.customChannelDeletedHandler
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
581
|
+
this.ngZone.run(() => {
|
|
582
|
+
if (this.customChannelDeletedHandler) {
|
|
583
|
+
this.customChannelDeletedHandler(event, channel, this.channelListSetter, this.messageListSetter);
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
this.handleChannelDeleted(event);
|
|
587
|
+
}
|
|
588
|
+
});
|
|
595
589
|
break;
|
|
596
590
|
}
|
|
597
591
|
case 'channel.visible': {
|
|
598
|
-
|
|
599
|
-
this.customChannelVisibleHandler
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
592
|
+
this.ngZone.run(() => {
|
|
593
|
+
if (this.customChannelVisibleHandler) {
|
|
594
|
+
this.customChannelVisibleHandler(event, channel, this.channelListSetter, this.messageListSetter);
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
this.handleChannelVisible(event, channel);
|
|
598
|
+
}
|
|
599
|
+
});
|
|
605
600
|
break;
|
|
606
601
|
}
|
|
607
602
|
case 'channel.updated': {
|
|
608
|
-
|
|
609
|
-
this.customChannelUpdatedHandler
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
603
|
+
this.ngZone.run(() => {
|
|
604
|
+
if (this.customChannelUpdatedHandler) {
|
|
605
|
+
this.customChannelUpdatedHandler(event, channel, this.channelListSetter, this.messageListSetter);
|
|
606
|
+
}
|
|
607
|
+
else {
|
|
608
|
+
this.handleChannelUpdate(event);
|
|
609
|
+
}
|
|
610
|
+
});
|
|
615
611
|
break;
|
|
616
612
|
}
|
|
617
613
|
case 'channel.truncated': {
|
|
618
|
-
|
|
619
|
-
this.customChannelTruncatedHandler
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
614
|
+
this.ngZone.run(() => {
|
|
615
|
+
if (this.customChannelTruncatedHandler) {
|
|
616
|
+
this.customChannelTruncatedHandler(event, channel, this.channelListSetter, this.messageListSetter);
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
this.handleChannelTruncate(event);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
625
622
|
break;
|
|
626
623
|
}
|
|
627
624
|
}
|
|
628
|
-
setTimeout(() => this.appRef.tick(), 0);
|
|
629
625
|
});
|
|
630
626
|
}
|
|
631
627
|
handleNewMessage(_, channel) {
|
|
@@ -684,14 +680,14 @@ class ChannelService {
|
|
|
684
680
|
return capabilites.indexOf('read-events') !== -1;
|
|
685
681
|
}
|
|
686
682
|
}
|
|
687
|
-
ChannelService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChannelService, deps: [{ token: ChatClientService }, { token: i0.
|
|
683
|
+
ChannelService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChannelService, deps: [{ token: ChatClientService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
688
684
|
ChannelService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChannelService, providedIn: 'root' });
|
|
689
685
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChannelService, decorators: [{
|
|
690
686
|
type: Injectable,
|
|
691
687
|
args: [{
|
|
692
688
|
providedIn: 'root',
|
|
693
689
|
}]
|
|
694
|
-
}], ctorParameters: function () { return [{ type: ChatClientService }, { type: i0.
|
|
690
|
+
}], ctorParameters: function () { return [{ type: ChatClientService }, { type: i0.NgZone }]; } });
|
|
695
691
|
|
|
696
692
|
class ThemeService {
|
|
697
693
|
constructor() {
|
|
@@ -1847,8 +1843,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImpor
|
|
|
1847
1843
|
}], ctorParameters: function () { return [{ type: ChannelService }, { type: ChannelListToggleService }]; } });
|
|
1848
1844
|
|
|
1849
1845
|
class ChannelPreviewComponent {
|
|
1850
|
-
constructor(channelService) {
|
|
1846
|
+
constructor(channelService, ngZone) {
|
|
1851
1847
|
this.channelService = channelService;
|
|
1848
|
+
this.ngZone = ngZone;
|
|
1852
1849
|
this.isActive = false;
|
|
1853
1850
|
this.isUnread = false;
|
|
1854
1851
|
this.latestMessage = 'Nothing yet...';
|
|
@@ -1869,8 +1866,10 @@ class ChannelPreviewComponent {
|
|
|
1869
1866
|
this.subscriptions.push(this.channel.on('message.updated', this.handleMessageEvent.bind(this)));
|
|
1870
1867
|
this.subscriptions.push(this.channel.on('message.deleted', this.handleMessageEvent.bind(this)));
|
|
1871
1868
|
this.subscriptions.push(this.channel.on('channel.truncated', this.handleMessageEvent.bind(this)));
|
|
1872
|
-
this.subscriptions.push(this.channel.on('message.read', () =>
|
|
1873
|
-
|
|
1869
|
+
this.subscriptions.push(this.channel.on('message.read', () => this.ngZone.run(() => {
|
|
1870
|
+
this.isUnread =
|
|
1871
|
+
!!this.channel.countUnread() && this.canSendReadEvents;
|
|
1872
|
+
})));
|
|
1874
1873
|
}
|
|
1875
1874
|
ngOnDestroy() {
|
|
1876
1875
|
this.subscriptions.forEach((s) => s.unsubscribe());
|
|
@@ -1891,17 +1890,19 @@ class ChannelPreviewComponent {
|
|
|
1891
1890
|
void this.channelService.setAsActiveChannel(this.channel);
|
|
1892
1891
|
}
|
|
1893
1892
|
handleMessageEvent(event) {
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
this.
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1893
|
+
this.ngZone.run(() => {
|
|
1894
|
+
var _a, _b, _c;
|
|
1895
|
+
if (((_a = this.channel) === null || _a === void 0 ? void 0 : _a.state.messages.length) === 0) {
|
|
1896
|
+
this.latestMessage = 'Nothing yet...';
|
|
1897
|
+
return;
|
|
1898
|
+
}
|
|
1899
|
+
if (!event.message ||
|
|
1900
|
+
((_b = this.channel) === null || _b === void 0 ? void 0 : _b.state.messages[((_c = this.channel) === null || _c === void 0 ? void 0 : _c.state.messages.length) - 1].id) !== event.message.id) {
|
|
1901
|
+
return;
|
|
1902
|
+
}
|
|
1903
|
+
this.setLatestMessage(event.message);
|
|
1904
|
+
this.isUnread = !!this.channel.countUnread() && this.canSendReadEvents;
|
|
1905
|
+
});
|
|
1905
1906
|
}
|
|
1906
1907
|
setLatestMessage(message) {
|
|
1907
1908
|
if (message === null || message === void 0 ? void 0 : message.deleted_at) {
|
|
@@ -1915,7 +1916,7 @@ class ChannelPreviewComponent {
|
|
|
1915
1916
|
}
|
|
1916
1917
|
}
|
|
1917
1918
|
}
|
|
1918
|
-
ChannelPreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChannelPreviewComponent, deps: [{ token: ChannelService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1919
|
+
ChannelPreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChannelPreviewComponent, deps: [{ token: ChannelService }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
|
|
1919
1920
|
ChannelPreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.5", type: ChannelPreviewComponent, selector: "stream-channel-preview", inputs: { channel: "channel" }, ngImport: i0, template: "<button\n class=\"str-chat__channel-preview-messenger\"\n [class.str-chat__channel-preview-messenger--active]=\"isActive\"\n [class.str-chat__channel-preview-messenger--unread]=\"isUnread\"\n (click)=\"setAsActiveChannel()\"\n data-testid=\"channel-preview-container\"\n>\n <div class=\"str-chat__channel-preview-messenger--left\">\n <stream-avatar\n imageUrl=\"{{ avatarImage }}\"\n name=\"{{ avatarName }}\"\n [size]=\"40\"\n ></stream-avatar>\n </div>\n <div class=\"str-chat__channel-preview-messenger--right\">\n <div class=\"str-chat__channel-preview-messenger--name\">\n <span data-testid=\"channel-preview-title\">{{ title }}</span>\n </div>\n <div\n data-testid=\"latest-message\"\n class=\"str-chat__channel-preview-messenger--last-message\"\n >\n {{ latestMessage | translate }}\n </div>\n </div>\n</button>\n", components: [{ type: AvatarComponent, selector: "stream-avatar", inputs: ["name", "imageUrl", "size"] }], pipes: { "translate": i10.TranslatePipe } });
|
|
1920
1921
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImport: i0, type: ChannelPreviewComponent, decorators: [{
|
|
1921
1922
|
type: Component,
|
|
@@ -1924,7 +1925,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.5", ngImpor
|
|
|
1924
1925
|
templateUrl: './channel-preview.component.html',
|
|
1925
1926
|
styles: [],
|
|
1926
1927
|
}]
|
|
1927
|
-
}], ctorParameters: function () { return [{ type: ChannelService }]; }, propDecorators: { channel: [{
|
|
1928
|
+
}], ctorParameters: function () { return [{ type: ChannelService }, { type: i0.NgZone }]; }, propDecorators: { channel: [{
|
|
1928
1929
|
type: Input
|
|
1929
1930
|
}] } });
|
|
1930
1931
|
|