Skip to content

Commit

Permalink
fix: thread small UI fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Jun 27, 2024
1 parent df933fe commit 7717df8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Let's start with the thread component:
width: 100%;
height: 100%;
position: fixed;
z-index: 2;
z-index: 3;
}

@media screen and (min-width: 768px) {
Expand Down Expand Up @@ -176,7 +176,7 @@ Provide the layout based on the menu state and hide the menu on bigger screens:
width: 100%;
height: 100%;
position: fixed;
z-index: 2;
z-index: 3;
}

@media screen and (min-width: 768px) {
Expand Down
2 changes: 1 addition & 1 deletion projects/sample-app/src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ body {
width: 100%;
height: 100%;
position: fixed;
z-index: 2;
z-index: 3;
}

@media screen and (min-width: 768px) {
Expand Down
25 changes: 14 additions & 11 deletions projects/stream-chat-angular/src/lib/channel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,26 +715,29 @@ export class ChannelService<
* Loads the next page of messages of the active thread. The page size can be set in the [query option](https://getstream.io/chat/docs/javascript/query_channels/?language=javascript#query-options) object.
* @param direction
*/
async loadMoreThreadReplies(direction: 'older' | 'newer' = 'older') {
loadMoreThreadReplies(direction: 'older' | 'newer' = 'older') {
if (direction === 'newer') {
// Thread replies aren't broke into different message sets, activeThreadMessages$ will be refreshed by WS events, no need for a request
return;
return false;
}
const activeChnannel = this.activeChannelSubject.getValue();
const parentMessageId = this.activeParentMessageIdSubject.getValue();
if (!parentMessageId) {
return;
if (!parentMessageId || !activeChnannel) {
return false;
}
const threadMessages = this.activeThreadMessagesSubject.getValue();
const lastMessageId =
threadMessages[direction === 'older' ? 0 : threadMessages.length - 1]?.id;
await activeChnannel?.getReplies(parentMessageId, {
limit: this.messagePageSize,
[direction === 'older' ? 'id_lt' : 'id_gt']: lastMessageId,
});
this.activeThreadMessagesSubject.next(
activeChnannel?.state.threads[parentMessageId] || []
);
return activeChnannel
.getReplies(parentMessageId, {
limit: this.messagePageSize,
[direction === 'older' ? 'id_lt' : 'id_gt']: lastMessageId,
})
.then(() => {
this.activeThreadMessagesSubject.next(
activeChnannel?.state.threads[parentMessageId] || []
);
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,11 @@ export class MessageListComponent
this.scrollContainer.nativeElement.scrollHeight ===
this.scrollContainer.nativeElement.clientHeight
) {
if (this.isJumpToLatestButtonVisible) {
this.isJumpToLatestButtonVisible = false;
this.newMessageCountWhileBeingScrolled = 0;
this.cdRef.detectChanges();
}
return;
}
this.scroll$.next();
Expand Down Expand Up @@ -738,7 +743,9 @@ export class MessageListComponent
: this.channelService.activeThreadMessages$
).pipe(
tap((messages) => {
this.isLoading = false;
if (this.isLoading) {
this.isLoading = false;
}
if (messages.length === 0) {
this.chatClientService.chatClient?.logger?.(
'info',
Expand Down

0 comments on commit 7717df8

Please sign in to comment.