diff --git a/src/config.ts b/src/config.ts index 32345f013..98319574f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -33,11 +33,6 @@ export const CUSTOM_BG_CACHE_NAME = 'tt-custom-bg'; export const LANG_CACHE_NAME = 'tt-lang-packs-v5'; export const ASSET_CACHE_NAME = 'tt-assets'; -export const API_UPDATE_THROTTLE = 300; -export const API_THROTTLE_RESET_UPDATES = new Set([ - 'newMessage', 'newScheduledMessage', 'deleteMessages', 'deleteScheduledMessages', 'deleteHistory', -]); - export const DOWNLOAD_WORKERS = 16; export const UPLOAD_WORKERS = 16; @@ -97,6 +92,12 @@ export const FAST_SMOOTH_MIN_DURATION = 250; export const FAST_SMOOTH_MAX_DURATION = 600; export const FAST_SMOOTH_SHORT_TRANSITION_MAX_DISTANCE = 500; // px +// Average duration of message sending animation +export const API_UPDATE_THROTTLE = Math.round((FAST_SMOOTH_MIN_DURATION + FAST_SMOOTH_MAX_DURATION) / 2); +export const API_THROTTLE_RESET_UPDATES = new Set([ + 'newMessage', 'newScheduledMessage', 'deleteMessages', 'deleteScheduledMessages', 'deleteHistory', +]); + export const STICKER_SIZE_INLINE_DESKTOP_FACTOR = 13; export const STICKER_SIZE_INLINE_MOBILE_FACTOR = 11; export const STICKER_SIZE_AUTH = 160; diff --git a/src/util/fastSmoothScroll.ts b/src/util/fastSmoothScroll.ts index b5d94db43..6d0a7770f 100644 --- a/src/util/fastSmoothScroll.ts +++ b/src/util/fastSmoothScroll.ts @@ -108,6 +108,12 @@ function scrollWithJs( path = Math.min(path, remainingPath); } + if (path === 0) { + isAnimating = false; + + return; + } + const target = container.scrollTop + path; if (forceDuration === 0) { diff --git a/src/util/fastSmoothScrollHorizontal.ts b/src/util/fastSmoothScrollHorizontal.ts index e8a87dc1a..de8598003 100644 --- a/src/util/fastSmoothScrollHorizontal.ts +++ b/src/util/fastSmoothScrollHorizontal.ts @@ -37,6 +37,10 @@ function scrollWithJs(container: HTMLElement, left: number, duration: number) { path = Math.min(path, remainingPath); } + if (path === 0) { + return; + } + const target = container.scrollLeft + path; if (duration === 0) {