Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Communication: Remeber last scroll position when switching tabs #9614

Open
wants to merge 22 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0ad2e22
Add scroll position memorization
cremertim Oct 28, 2024
28a0dc6
Reduced timeout
cremertim Oct 28, 2024
a76e349
performance
cremertim Oct 28, 2024
9726517
Default scroll to bottom of the messages if you create a new message
cremertim Oct 29, 2024
9979342
Added test cases
cremertim Oct 29, 2024
d9b1024
First implementation via ID
cremertim Oct 29, 2024
21c0c1b
Merge branch 'develop' into bugfix/communication/adjust-channel-jumping
cremertim Oct 29, 2024
870d20f
optimization from coderabit
cremertim Oct 29, 2024
82aff7f
Merge remote-tracking branch 'origin/bugfix/communication/adjust-chan…
cremertim Oct 29, 2024
1b5de0b
Added integration Test for search
cremertim Oct 30, 2024
4ad6553
variable readonly
cremertim Oct 30, 2024
c98aef2
Added tests
cremertim Oct 30, 2024
7398ef2
Merge branch 'develop' into bugfix/communication/adjust-channel-jumping
cremertim Oct 30, 2024
674e3b5
Merge branch 'develop' into bugfix/communication/adjust-channel-jumping
cremertim Oct 30, 2024
3fb2349
Merge remote-tracking branch 'origin/develop' into bugfix/communicati…
Pablosanqt Oct 31, 2024
7d7ad2c
Small bugfix
Pablosanqt Oct 31, 2024
94e18ab
Fix for change between modules
Pablosanqt Oct 31, 2024
355a91c
Fix tests
Pablosanqt Oct 31, 2024
41d9509
Merge remote-tracking branch 'origin/develop' into bugfix/communicati…
PaRangger Nov 3, 2024
095f321
Fix for proper scroll position on load and on new message
PaRangger Nov 4, 2024
8fe911b
Merge remote-tracking branch 'origin/develop' into bugfix/communicati…
PaRangger Nov 8, 2024
b4da15b
Fix merge conflict issues
PaRangger Nov 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import { CustomBreakpointNames } from 'app/shared/breakpoints/breakpoints.servic
})
export class ConversationMessagesComponent implements OnInit, AfterViewInit, OnDestroy {
private ngUnsubscribe = new Subject<void>();
private sessionStorageKey = 'conversationId.scrollPosition.';

readonly PageType = PageType;
readonly ButtonType = ButtonType;

Expand Down Expand Up @@ -137,11 +139,13 @@ export class ConversationMessagesComponent implements OnInit, AfterViewInit, OnD

ngAfterViewInit() {
this.messages.changes.pipe(takeUntil(this.ngUnsubscribe)).subscribe(this.handleScrollOnNewMessage);
this.content.nativeElement.addEventListener('scroll', this.saveScrollPosition);
cremertim marked this conversation as resolved.
Show resolved Hide resolved
}

ngOnDestroy(): void {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
this.content.nativeElement.removeEventListener('scroll', this.saveScrollPosition);
cremertim marked this conversation as resolved.
Show resolved Hide resolved
}

private onActiveConversationChange() {
Expand Down Expand Up @@ -246,8 +250,13 @@ export class ConversationMessagesComponent implements OnInit, AfterViewInit, OnD
scrollToBottomOfMessages() {
// Use setTimeout to ensure the scroll happens after the new message is rendered
setTimeout(() => {
this.content.nativeElement.scrollTop = this.content.nativeElement.scrollHeight;
}, 0);
const savedScrollPosition = sessionStorage.getItem(this.sessionStorageKey + this._activeConversation?.id);
if (savedScrollPosition) {
this.content.nativeElement.scrollTop = parseInt(savedScrollPosition, 10);
} else {
this.content.nativeElement.scrollTop = this.content.nativeElement.scrollHeight;
}
cremertim marked this conversation as resolved.
Show resolved Hide resolved
}, 30);
}

onSearchQueryInput($event: Event) {
Expand All @@ -261,4 +270,9 @@ export class ConversationMessagesComponent implements OnInit, AfterViewInit, OnD
this.searchInput.nativeElement.dispatchEvent(new Event('input'));
}
}

private saveScrollPosition = () => {
const scrollTop = this.content.nativeElement.scrollTop;
sessionStorage.setItem(this.sessionStorageKey + this._activeConversation?.id, scrollTop.toString());
};
cremertim marked this conversation as resolved.
Show resolved Hide resolved
}
Loading