stream-chat-angular 5.0.0 → 5.1.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.
- package/assets/version.d.ts +1 -1
- package/esm2020/assets/version.mjs +2 -2
- package/esm2020/lib/avatar/avatar.component.mjs +4 -1
- package/esm2020/lib/channel-list/channel-list.component.mjs +2 -2
- package/esm2020/lib/channel.service.mjs +9 -24
- package/esm2020/lib/message-actions.service.mjs +4 -4
- package/esm2020/lib/message-list/message-list.component.mjs +181 -249
- package/esm2020/lib/types.mjs +1 -1
- package/esm2020/lib/virtualized-list.service.mjs +271 -0
- package/esm2020/lib/virtualized-message-list.service.mjs +73 -0
- package/esm2020/lib/voice-recording/voice-recording.component.mjs +2 -2
- package/esm2020/public-api.mjs +3 -1
- package/fesm2015/stream-chat-angular.mjs +548 -284
- package/fesm2015/stream-chat-angular.mjs.map +1 -1
- package/fesm2020/stream-chat-angular.mjs +534 -273
- package/fesm2020/stream-chat-angular.mjs.map +1 -1
- package/lib/avatar/avatar.component.d.ts +3 -2
- package/lib/channel-list/channel-list.component.d.ts +1 -1
- package/lib/channel.service.d.ts +6 -12
- package/lib/message-list/message-list.component.d.ts +12 -18
- package/lib/types.d.ts +7 -0
- package/lib/virtualized-list.service.d.ts +58 -0
- package/lib/virtualized-message-list.service.d.ts +15 -0
- package/package.json +1 -1
- package/public-api.d.ts +2 -0
- package/src/assets/styles/css/index.css +1 -1
- package/src/assets/styles/css/index.layout.css +1 -1
- package/src/assets/styles/scss/LoadingIndicator/LoadingIndicator-layout.scss +16 -0
- package/src/assets/version.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AfterViewInit, ChangeDetectorRef, NgZone, OnChanges, OnInit, SimpleChanges } from '@angular/core';
|
|
1
|
+
import { AfterViewInit, ChangeDetectorRef, NgZone, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
|
|
2
2
|
import { Channel, User } from 'stream-chat';
|
|
3
3
|
import { ChatClientService } from '../chat-client.service';
|
|
4
4
|
import { AvatarLocation, AvatarType, DefaultStreamChatGenerics } from '../types';
|
|
@@ -6,7 +6,7 @@ import * as i0 from "@angular/core";
|
|
|
6
6
|
/**
|
|
7
7
|
* The `Avatar` component displays the provided image, with fallback to the first letter of the optional name input.
|
|
8
8
|
*/
|
|
9
|
-
export declare class AvatarComponent implements OnChanges, OnInit, OnChanges, AfterViewInit {
|
|
9
|
+
export declare class AvatarComponent implements OnChanges, OnInit, OnChanges, AfterViewInit, OnDestroy {
|
|
10
10
|
private chatClientService;
|
|
11
11
|
private ngZone;
|
|
12
12
|
private cdRef;
|
|
@@ -53,6 +53,7 @@ export declare class AvatarComponent implements OnChanges, OnInit, OnChanges, Af
|
|
|
53
53
|
constructor(chatClientService: ChatClientService, ngZone: NgZone, cdRef: ChangeDetectorRef);
|
|
54
54
|
ngOnInit(): void;
|
|
55
55
|
ngOnChanges(changes: SimpleChanges): void;
|
|
56
|
+
ngOnDestroy(): void;
|
|
56
57
|
private setFallbackChannelImage;
|
|
57
58
|
private setInitials;
|
|
58
59
|
private updateIsOnlineSubscription;
|
|
@@ -25,7 +25,7 @@ export declare class ChannelListComponent implements OnDestroy {
|
|
|
25
25
|
constructor(channelService: ChannelService, customTemplatesService: CustomTemplatesService, themeService: ThemeService);
|
|
26
26
|
ngOnDestroy(): void;
|
|
27
27
|
loadMoreChannels(): Promise<void>;
|
|
28
|
-
trackByChannelId(
|
|
28
|
+
trackByChannelId(_: number, item: Channel<DefaultStreamChatGenerics>): string;
|
|
29
29
|
static ɵfac: i0.ɵɵFactoryDeclaration<ChannelListComponent, never>;
|
|
30
30
|
static ɵcmp: i0.ɵɵComponentDeclaration<ChannelListComponent, "stream-channel-list", never, {}, {}, never, ["[channel-list-top]", "[channel-list-bottom]"], false, never>;
|
|
31
31
|
}
|
package/lib/channel.service.d.ts
CHANGED
|
@@ -187,14 +187,11 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
|
|
|
187
187
|
* The provided method will be called before a message is sent to Stream's API for update. You can use this hook to tranfrom or enrich the message being updated.
|
|
188
188
|
*/
|
|
189
189
|
beforeUpdateMessage?: (message: StreamMessage<T>) => StreamMessage<T> | Promise<StreamMessage<T>>;
|
|
190
|
-
/**
|
|
191
|
-
* @internal
|
|
192
|
-
*/
|
|
193
|
-
static readonly MAX_MESSAGE_COUNT_IN_MESSAGE_LIST = 250;
|
|
194
190
|
/**
|
|
195
191
|
* @internal
|
|
196
192
|
*/
|
|
197
193
|
static readonly MAX_MESSAGE_REACTIONS_TO_FETCH = 1200;
|
|
194
|
+
messagePageSize: number;
|
|
198
195
|
private channelsSubject;
|
|
199
196
|
private activeChannelSubject;
|
|
200
197
|
private activeChannelMessagesSubject;
|
|
@@ -206,7 +203,6 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
|
|
|
206
203
|
private activeThreadMessagesSubject;
|
|
207
204
|
private jumpToMessageSubject;
|
|
208
205
|
private latestMessageDateByUserByChannelsSubject;
|
|
209
|
-
private messagePageSize;
|
|
210
206
|
private readonly attachmentMaxSizeFallbackInMB;
|
|
211
207
|
private messageToQuoteSubject;
|
|
212
208
|
private usersTypingInChannelSubject;
|
|
@@ -225,10 +221,6 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
|
|
|
225
221
|
private dismissErrorNotification?;
|
|
226
222
|
private areReadEventsPaused;
|
|
227
223
|
constructor(chatClientService: ChatClientService<T>, ngZone: NgZone, notificationService: NotificationService);
|
|
228
|
-
/**
|
|
229
|
-
* internal
|
|
230
|
-
*/
|
|
231
|
-
removeOldMessageFromMessageList(): void;
|
|
232
224
|
/**
|
|
233
225
|
* If set to false, read events won't be sent as new messages are received. If set to true active channel (if any) will immediately be marked as read.
|
|
234
226
|
*/
|
|
@@ -381,9 +373,7 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
|
|
|
381
373
|
} | null | undefined;
|
|
382
374
|
reply_count?: number | undefined;
|
|
383
375
|
shadowed?: boolean | undefined;
|
|
384
|
-
status?: string | undefined;
|
|
385
|
-
* If set to false, read events won't be sent as new messages are received. If set to true active channel (if any) will immediately be marked as read.
|
|
386
|
-
*/
|
|
376
|
+
status?: string | undefined;
|
|
387
377
|
thread_participants?: UserResponse<T>[] | undefined;
|
|
388
378
|
updated_at?: string | undefined;
|
|
389
379
|
} & {
|
|
@@ -500,6 +490,10 @@ export declare class ChannelService<T extends DefaultStreamChatGenerics = Defaul
|
|
|
500
490
|
* The current active channel messages
|
|
501
491
|
*/
|
|
502
492
|
get activeChannelMessages(): (StreamMessage<T> | MessageResponse<T> | FormatMessageResponse<T>)[];
|
|
493
|
+
/**
|
|
494
|
+
* The current thread replies
|
|
495
|
+
*/
|
|
496
|
+
get activeChannelThreadReplies(): (StreamMessage<T> | MessageResponse<T> | FormatMessageResponse<T>)[];
|
|
503
497
|
/**
|
|
504
498
|
* Get the last 1200 reactions of a message in the current active channel. If you need to fetch more reactions please use the [following endpoint](https://getstream.io/chat/docs/javascript/send_reaction/?language=javascript#paginating-reactions).
|
|
505
499
|
* @param messageId
|
|
@@ -57,10 +57,6 @@ export declare class MessageListComponent implements AfterViewChecked, OnChanges
|
|
|
57
57
|
* You can turn on and off the loading indicator that signals to users that more messages are being loaded to the message list
|
|
58
58
|
*/
|
|
59
59
|
displayLoadingIndicator: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* @internal
|
|
62
|
-
*/
|
|
63
|
-
limitNumberOfMessagesInList: boolean;
|
|
64
60
|
typingIndicatorTemplate: TemplateRef<TypingIndicatorContext> | undefined;
|
|
65
61
|
messageTemplate: TemplateRef<MessageContext> | undefined;
|
|
66
62
|
customDateSeparatorTemplate: TemplateRef<DateSeparatorContext> | undefined;
|
|
@@ -78,7 +74,7 @@ export declare class MessageListComponent implements AfterViewChecked, OnChanges
|
|
|
78
74
|
lastSentMessageId: string | undefined;
|
|
79
75
|
parentMessage: StreamMessage | undefined;
|
|
80
76
|
highlightedMessageId: string | undefined;
|
|
81
|
-
|
|
77
|
+
loadingState: 'idle' | 'loading-top' | 'loading-bottom';
|
|
82
78
|
scrollEndTimeout?: ReturnType<typeof setTimeout>;
|
|
83
79
|
lastReadMessageId?: string;
|
|
84
80
|
isUnreadNotificationVisible: boolean;
|
|
@@ -86,18 +82,13 @@ export declare class MessageListComponent implements AfterViewChecked, OnChanges
|
|
|
86
82
|
unreadCount?: number;
|
|
87
83
|
isJumpingToLatestUnreadMessage: boolean;
|
|
88
84
|
isJumpToLatestButtonVisible: boolean;
|
|
85
|
+
isJumpingToMessage: boolean;
|
|
89
86
|
scroll$: Subject<void>;
|
|
90
87
|
private scrollContainer;
|
|
91
88
|
private parentMessageElement;
|
|
92
|
-
private latestMessage;
|
|
93
|
-
private hasNewMessages;
|
|
94
|
-
private containerHeight;
|
|
95
|
-
private oldestMessage;
|
|
96
|
-
private olderMassagesLoaded;
|
|
97
89
|
private isNewMessageSentByUser;
|
|
98
90
|
private subscriptions;
|
|
99
91
|
private newMessageSubscription;
|
|
100
|
-
private prevScrollTop;
|
|
101
92
|
private usersTypingInChannel$;
|
|
102
93
|
private usersTypingInThread$;
|
|
103
94
|
private isLatestMessageInList;
|
|
@@ -106,11 +97,15 @@ export declare class MessageListComponent implements AfterViewChecked, OnChanges
|
|
|
106
97
|
private isViewInited;
|
|
107
98
|
private checkIfUnreadNotificationIsVisibleTimeout?;
|
|
108
99
|
private jumpToLatestButtonVisibilityTimeout?;
|
|
109
|
-
private messageRemoveTimeout?;
|
|
110
|
-
private removeOldMessagesSubscription?;
|
|
111
100
|
private isSafari;
|
|
112
101
|
private forceRepaintSubject;
|
|
102
|
+
private messageIdToAnchorTo?;
|
|
103
|
+
private anchorMessageTopOffset?;
|
|
113
104
|
private get class();
|
|
105
|
+
private virtualizedList?;
|
|
106
|
+
private scrollPosition$;
|
|
107
|
+
private jumpToItemSubscription?;
|
|
108
|
+
private queryStateSubscription?;
|
|
114
109
|
constructor(channelService: ChannelService, chatClientService: ChatClientService, customTemplatesService: CustomTemplatesService, dateParser: DateParserService, ngZone: NgZone, cdRef: ChangeDetectorRef);
|
|
115
110
|
messageNotificationJumpClicked: () => void;
|
|
116
111
|
messageNotificationDismissClicked: () => void;
|
|
@@ -119,8 +114,8 @@ export declare class MessageListComponent implements AfterViewChecked, OnChanges
|
|
|
119
114
|
ngAfterViewInit(): void;
|
|
120
115
|
ngAfterViewChecked(): void;
|
|
121
116
|
ngOnDestroy(): void;
|
|
122
|
-
trackByMessageId(
|
|
123
|
-
trackByUserId(
|
|
117
|
+
trackByMessageId(_: number, item: StreamMessage): string;
|
|
118
|
+
trackByUserId(_: number, user: UserResponse): string;
|
|
124
119
|
jumpToLatestMessage(): void;
|
|
125
120
|
scrollToBottom(): void;
|
|
126
121
|
scrollToTop(): void;
|
|
@@ -137,14 +132,13 @@ export declare class MessageListComponent implements AfterViewChecked, OnChanges
|
|
|
137
132
|
private preserveScrollbarPosition;
|
|
138
133
|
private forceRepaint;
|
|
139
134
|
private getScrollPosition;
|
|
140
|
-
private shouldLoadMoreMessages;
|
|
141
135
|
private setMessages$;
|
|
142
136
|
private resetScrollState;
|
|
137
|
+
private disposeVirtualizedList;
|
|
143
138
|
private get usersTyping$();
|
|
144
139
|
private scrollMessageIntoView;
|
|
145
|
-
private scrollToLatestMessage;
|
|
146
140
|
private newMessageReceived;
|
|
147
141
|
private checkIfOnSeparateDates;
|
|
148
142
|
static ɵfac: i0.ɵɵFactoryDeclaration<MessageListComponent, never>;
|
|
149
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<MessageListComponent, "stream-message-list", never, { "mode": "mode"; "direction": "direction"; "hideJumpToLatestButtonDuringScroll": "hideJumpToLatestButtonDuringScroll"; "displayDateSeparator": "displayDateSeparator"; "displayUnreadSeparator": "displayUnreadSeparator"; "dateSeparatorTextPos": "dateSeparatorTextPos"; "openMessageListAt": "openMessageListAt"; "hideUnreadCountForNotificationAndIndicator": "hideUnreadCountForNotificationAndIndicator"; "displayLoadingIndicator": "displayLoadingIndicator";
|
|
143
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<MessageListComponent, "stream-message-list", never, { "mode": "mode"; "direction": "direction"; "hideJumpToLatestButtonDuringScroll": "hideJumpToLatestButtonDuringScroll"; "displayDateSeparator": "displayDateSeparator"; "displayUnreadSeparator": "displayUnreadSeparator"; "dateSeparatorTextPos": "dateSeparatorTextPos"; "openMessageListAt": "openMessageListAt"; "hideUnreadCountForNotificationAndIndicator": "hideUnreadCountForNotificationAndIndicator"; "displayLoadingIndicator": "displayLoadingIndicator"; }, {}, never, never, false, never>;
|
|
150
144
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -303,4 +303,11 @@ export declare type ChannelQueryResult<T extends DefaultStreamChatGenerics = Def
|
|
|
303
303
|
channels: Channel<T>[];
|
|
304
304
|
hasMorePage: boolean;
|
|
305
305
|
};
|
|
306
|
+
export declare type VirtualizedListScrollPosition = 'top' | 'bottom' | 'middle';
|
|
307
|
+
export declare type VirtualizedListQueryState = {
|
|
308
|
+
state: 'loading-top' | 'loading-bottom' | 'success' | 'error';
|
|
309
|
+
error?: unknown;
|
|
310
|
+
};
|
|
311
|
+
export declare type VirtualizedListQueryDirection = 'top' | 'bottom';
|
|
312
|
+
export declare type VirtualizedListVerticalItemPosition = 'top' | 'bottom' | 'middle';
|
|
306
313
|
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
|
2
|
+
import { VirtualizedListQueryDirection, VirtualizedListQueryState, VirtualizedListScrollPosition, VirtualizedListVerticalItemPosition } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The `VirtualizedListService` removes items from a list that are not currently displayed. This is a high-level overview of how it works:
|
|
5
|
+
* - Create a new instance for each list that needs virtualization
|
|
6
|
+
* - Input: Provide a reactive stream that emits all items in the list
|
|
7
|
+
* - Input: Provide a reactive stream that emit the current scroll position (top, middle or bottom)
|
|
8
|
+
* - Input: maximum number of items that are allowed in the list (in practice the service can make the virtualized list half this number, you should take this into account when choosing the value)
|
|
9
|
+
* - Output: The service will emit the current list of displayed items via the virtualized items reactive stream
|
|
10
|
+
* - For simplicity, the service won't track the height of the items, nor it needs an exact scroll location -> this is how removing items work:
|
|
11
|
+
* - If scroll location is bottom/top items around the current bottom/top item will be emitted in the virtualized items stream
|
|
12
|
+
* - If scroll location is middle, the service won't remove items, if new items are received, those will be appended to the virtualized list (this means that in theory the list can grow very big if a lot of new items are received while the user is scrolled somewhere, this is a trade-off for the simplicity of no height tracking)
|
|
13
|
+
* - Since there is no height tracking, you should make sure to provide a maximum number that is big enough to fill the biggest expected screen size twice
|
|
14
|
+
* - If the user scrolls to the bottom/top and there are no more local items to show, the service will trigger a query to load more items
|
|
15
|
+
* - Input: you should provide the page size to use, in order for the service to determine if loading is necessary
|
|
16
|
+
*
|
|
17
|
+
* The `VirtualizedMessageListService` provides an implementation for the message list component.
|
|
18
|
+
*/
|
|
19
|
+
export declare abstract class VirtualizedListService<T> {
|
|
20
|
+
private allItems$;
|
|
21
|
+
private scrollPosition$;
|
|
22
|
+
readonly jumpToItem$?: Observable<{
|
|
23
|
+
item: Partial<T> | undefined;
|
|
24
|
+
position?: VirtualizedListVerticalItemPosition | undefined;
|
|
25
|
+
}> | undefined;
|
|
26
|
+
readonly pageSize: number;
|
|
27
|
+
readonly maxItemCount: number;
|
|
28
|
+
/**
|
|
29
|
+
* The items that should be currently displayed, a subset of all items
|
|
30
|
+
*/
|
|
31
|
+
virtualizedItems$: Observable<T[]>;
|
|
32
|
+
/**
|
|
33
|
+
* The result of the last query used to load more items
|
|
34
|
+
*/
|
|
35
|
+
queryState$: Observable<VirtualizedListQueryState>;
|
|
36
|
+
protected queryStateSubject: BehaviorSubject<VirtualizedListQueryState>;
|
|
37
|
+
protected bufferOnTop: number;
|
|
38
|
+
protected bufferOnBottom: number;
|
|
39
|
+
protected loadFromBuffer$: Subject<void>;
|
|
40
|
+
private virtualizedItemsSubject;
|
|
41
|
+
private subscriptions;
|
|
42
|
+
constructor(allItems$: Observable<T[]>, scrollPosition$: Observable<VirtualizedListScrollPosition>, jumpToItem$?: Observable<{
|
|
43
|
+
item: Partial<T> | undefined;
|
|
44
|
+
position?: VirtualizedListVerticalItemPosition | undefined;
|
|
45
|
+
}> | undefined, pageSize?: number, maxItemCount?: number);
|
|
46
|
+
/**
|
|
47
|
+
* The current value of virtualized items
|
|
48
|
+
*/
|
|
49
|
+
get virtualizedItems(): T[];
|
|
50
|
+
/**
|
|
51
|
+
* Remove all subscriptions, call this once you're done using an instance of this service
|
|
52
|
+
*/
|
|
53
|
+
dispose(): void;
|
|
54
|
+
protected loadMoreFromBuffer(_: VirtualizedListQueryDirection): void;
|
|
55
|
+
private loadMore;
|
|
56
|
+
protected abstract isEqual: (t1: T, t2: T) => boolean;
|
|
57
|
+
protected abstract query: (direction: VirtualizedListQueryDirection) => Promise<unknown>;
|
|
58
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChannelService } from './channel.service';
|
|
2
|
+
import { VirtualizedListQueryDirection, VirtualizedListScrollPosition, StreamMessage } from './types';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { VirtualizedListService } from './virtualized-list.service';
|
|
5
|
+
/**
|
|
6
|
+
* The `VirtualizedMessageListService` removes messages from the message list that are currently not in view
|
|
7
|
+
*/
|
|
8
|
+
export declare class VirtualizedMessageListService extends VirtualizedListService<StreamMessage> {
|
|
9
|
+
readonly mode: 'thread' | 'main';
|
|
10
|
+
private channelService;
|
|
11
|
+
constructor(mode: 'thread' | 'main', scrollPosition$: Observable<VirtualizedListScrollPosition>, channelService: ChannelService);
|
|
12
|
+
protected loadMoreFromBuffer(direction: VirtualizedListQueryDirection): void;
|
|
13
|
+
protected isEqual: (t1: StreamMessage, t2: StreamMessage) => boolean;
|
|
14
|
+
protected query: (direction: VirtualizedListQueryDirection) => Promise<void> | Promise<import("stream-chat").QueryChannelAPIResponse<import("./types").DefaultStreamChatGenerics>>;
|
|
15
|
+
}
|
package/package.json
CHANGED
package/public-api.d.ts
CHANGED
|
@@ -59,3 +59,5 @@ export * from './lib/voice-recording/voice-recording-wavebar/voice-recording-wav
|
|
|
59
59
|
export * from './lib/is-on-separate-date';
|
|
60
60
|
export * from './lib/message-reactions-selector/message-reactions-selector.component';
|
|
61
61
|
export * from './lib/channel-query';
|
|
62
|
+
export * from './lib/virtualized-list.service';
|
|
63
|
+
export * from './lib/virtualized-message-list.service';
|