fix(welcome-screen): only scroll to elements not in viewport

e5c14af76d4d4d99638414f7a09ad71587549610

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +3 -1Showing whitespace changes
public/scripts/welcome-screen.js+3 -1
@@ -35,7 +35,7 @@ import { callGenericPopup, POPUP_TYPE } from './popup.js';
35import { getMessageTimeStamp } from './RossAscends-mods.js';35import { getMessageTimeStamp } from './RossAscends-mods.js';
36import { renderTemplateAsync } from './templates.js';36import { renderTemplateAsync } from './templates.js';
37import { accountStorage } from './util/AccountStorage.js';37import { accountStorage } from './util/AccountStorage.js';
38import { flashHighlight, sortMoments, timestampToMoment } from './utils.js';38import { flashHighlight, isElementInViewport, sortMoments, timestampToMoment } from './utils.js';
3939
40const assistantAvatarKey = 'assistant';40const assistantAvatarKey = 'assistant';
41const pinnedChatsKey = 'pinnedChats';41const pinnedChatsKey = 'pinnedChats';
@@ -616,7 +616,9 @@ async function refreshWelcomeScreen({ flashChat = null } = {}) {
616 ((flashChat.is_group && group === flashChat.group) || (!flashChat.is_group && avatar === flashChat.avatar));616 ((flashChat.is_group && group === flashChat.group) || (!flashChat.is_group && avatar === flashChat.avatar));
617 });617 });
618 if (chatToFlash instanceof HTMLElement) {618 if (chatToFlash instanceof HTMLElement) {
619 if (!isElementInViewport(chatToFlash)) {
619 chatElement.scrollTop = chatToFlash.offsetTop - chatElement.offsetTop - (chatToFlash.clientHeight / 2);620 chatElement.scrollTop = chatToFlash.offsetTop - chatElement.offsetTop - (chatToFlash.clientHeight / 2);
621 }
620 flashHighlight($(chatToFlash), 1000);622 flashHighlight($(chatToFlash), 1000);
621 }623 }
622 } else {624 } else {