Skip to content

Commit 94ea8b0

Browse files
committed
feat: Make it posisble to hide loading indicator in message list
1 parent 38aaedb commit 94ea8b0

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

projects/stream-chat-angular/src/lib/message-list/message-list.component.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
</li>
3131
<stream-loading-indicator
3232
data-testid="top-loading-indicator"
33-
*ngIf="isLoading && direction === 'bottom-to-top'"
33+
*ngIf="
34+
isLoading && direction === 'bottom-to-top' && displayLoadingIndicator
35+
"
3436
></stream-loading-indicator>
3537
<ng-container *ngIf="messages$ | async as messages">
3638
<ng-container
@@ -108,7 +110,9 @@
108110
</ng-container>
109111
<stream-loading-indicator
110112
data-testid="bottom-loading-indicator"
111-
*ngIf="isLoading && direction === 'top-to-bottom'"
113+
*ngIf="
114+
isLoading && direction === 'top-to-bottom' && displayLoadingIndicator
115+
"
112116
></stream-loading-indicator>
113117
</ul>
114118
<ng-template #defaultTypingIndicator let-usersTyping$="usersTyping$">

projects/stream-chat-angular/src/lib/message-list/message-list.component.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ export class MessageListComponent
7777
*/
7878
@Input() openMessageListAt: 'last-message' | 'last-unread-message' =
7979
'last-message';
80+
/**
81+
* You can turn on and off the loading indicator that signals to users that more messages are being loaded to the message list
82+
*/
83+
@Input() displayLoadingIndicator = true;
8084
messageTemplate: TemplateRef<MessageContext> | undefined;
8185
customDateSeparatorTemplate: TemplateRef<DateSeparatorContext> | undefined;
8286
customnewMessagesIndicatorTemplate: TemplateRef<void> | undefined;
@@ -369,7 +373,7 @@ export class MessageListComponent
369373
const scrollPosition = this.getScrollPosition();
370374
this.chatClientService.chatClient?.logger?.(
371375
'info',
372-
`Scrolled - scroll position: ${scrollPosition}`,
376+
`Scrolled - scroll position: ${scrollPosition}, container height: ${this.scrollContainer.nativeElement.scrollHeight}`,
373377
{ tags: `message list ${this.mode}` }
374378
);
375379

@@ -391,6 +395,11 @@ export class MessageListComponent
391395
this.mode === 'main'
392396
? void this.channelService.loadMoreMessages(direction)
393397
: void this.channelService.loadMoreThreadReplies(direction);
398+
this.chatClientService.chatClient?.logger?.(
399+
'info',
400+
`Displaying loading indicator`,
401+
{ tags: `message list ${this.mode}` }
402+
);
394403
this.isLoading = true;
395404
}
396405
this.prevScrollTop = this.scrollContainer.nativeElement.scrollTop;

0 commit comments

Comments
 (0)