From 86e2682f917ddd14f8e160bcd9976448a8304b46 Mon Sep 17 00:00:00 2001 From: morethanwords Date: Sat, 25 Sep 2021 16:18:12 +0400 Subject: [PATCH] Fix blinking chat in Firefox Replaced description in delete messages popup --- src/components/popups/deleteMessages.ts | 7 ++++++- src/components/transition.ts | 10 +++++++++- src/index.ts | 4 ++++ src/lib/appManagers/appImManager.ts | 7 ++++--- src/scss/partials/_chat.scss | 4 ++-- src/scss/partials/_chatBubble.scss | 2 +- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/components/popups/deleteMessages.ts b/src/components/popups/deleteMessages.ts index b2139f76..f340fd82 100644 --- a/src/components/popups/deleteMessages.ts +++ b/src/components/popups/deleteMessages.ts @@ -12,6 +12,7 @@ import PopupPeer, { PopupPeerButtonCallbackCheckboxes, PopupPeerOptions } from " import { ChatType } from "../chat/chat"; import { i18n, LangPackKey } from "../../lib/langPack"; import PeerTitle from "../peerTitle"; +import appPeersManager from "../../lib/appManagers/appPeersManager"; export default class PopupDeleteMessages { constructor(peerId: number, mids: number[], type: ChatType, onConfirm?: () => void) { @@ -35,7 +36,11 @@ export default class PopupDeleteMessages { titleArgs = [i18n('messages', [mids.length])]; } - description = mids.length === 1 ? 'AreYouSureDeleteSingleMessage' : 'AreYouSureDeleteFewMessages'; + if(appPeersManager.isMegagroup(peerId)) { + description = mids.length === 1 ? 'AreYouSureDeleteSingleMessageMega' : 'AreYouSureDeleteFewMessagesMega'; + } else { + description = mids.length === 1 ? 'AreYouSureDeleteSingleMessage' : 'AreYouSureDeleteFewMessages'; + } buttons = [{ langKey: 'Delete', diff --git a/src/components/transition.ts b/src/components/transition.ts index 5d777ba6..91489ce8 100644 --- a/src/components/transition.ts +++ b/src/components/transition.ts @@ -193,7 +193,14 @@ const Transition = ( } if(!animate) { - if(from) from.classList.remove('active', 'to', 'from'); + if(from) from.classList.remove('active', 'to', 'from'); + else if(to) { // fix instant opening back from closed slider (e.g. instant closening and opening right sidebar) + const callback = onTransitionEndCallbacks.get(to); + if(callback) { + callback(); + } + } + if(to) { to.classList.remove('to', 'from'); to.classList.add('active'); @@ -264,6 +271,7 @@ const Transition = ( const timeout = window.setTimeout(callback, transitionTime); onTransitionEndCallbacks.set(_from, () => { clearTimeout(timeout); + onTransitionEndCallbacks.delete(_from); }); } diff --git a/src/index.ts b/src/index.ts index 1e9a9a3a..0fbe0a6b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -164,6 +164,10 @@ console.timeEnd('get storage1'); */ } }); + if(userAgent.isFirefox) { + document.documentElement.classList.add('is-firefox'); + } + if(userAgent.isApple) { if(userAgent.isSafari) { document.documentElement.classList.add('is-safari'); diff --git a/src/lib/appManagers/appImManager.ts b/src/lib/appManagers/appImManager.ts index b72ba4c7..5b5af8fc 100644 --- a/src/lib/appManagers/appImManager.ts +++ b/src/lib/appManagers/appImManager.ts @@ -1040,16 +1040,17 @@ export class AppImManager { this.log('selectTab', id, prevTabId); - let animationPromise: Promise = doubleRaf(); + let animationPromise: Promise = rootScope.settings.animationsEnabled ? doubleRaf() : Promise.resolve(); if(prevTabId !== -1 && prevTabId !== id && rootScope.settings.animationsEnabled && animate !== false) { const transitionTime = (mediaSizes.isMobile ? 250 : 200) + 100; // * cause transition time could be > 250ms animationPromise = pause(transitionTime); dispatchHeavyAnimationEvent(animationPromise, transitionTime); - this.columnEl.classList.add('disable-hover'); + // ! it's very heavy operation. will blink in firefox + /* this.columnEl.classList.add('disable-hover'); animationPromise.finally(() => { this.columnEl.classList.remove('disable-hover'); - }); + }); */ } this.tabId = id; diff --git a/src/scss/partials/_chat.scss b/src/scss/partials/_chat.scss index 55192876..fee4a169 100644 --- a/src/scss/partials/_chat.scss +++ b/src/scss/partials/_chat.scss @@ -28,7 +28,7 @@ $chat-helper-size: 36px; flex: 0 0 auto; position: relative; transition: transform var(--transition-standard-out); - transform: translateY(var(--translateY)); + transform: translate3d(0, var(--translateY), 0); /* body.is-keyboard-opened & { --bottom: var(--padding-bottom); @@ -1001,7 +1001,7 @@ $chat-helper-size: 36px; flex: 1 1 auto; position: relative; - transform: translateY(var(--translateY)); + transform: translate3d(0, var(--translateY), 0); transition: transform var(--transition-standard-out); @include animation-level(0) { diff --git a/src/scss/partials/_chatBubble.scss b/src/scss/partials/_chatBubble.scss index 4c794ac0..6e5e3055 100644 --- a/src/scss/partials/_chatBubble.scss +++ b/src/scss/partials/_chatBubble.scss @@ -2036,7 +2036,7 @@ $bubble-margin: .25rem; color: var(--message-out-primary-color); } - &-wrapper { + /* html:not(.is-firefox) */ &-wrapper { @include respond-to(medium-screens) { transform: scale(1) translateX(calc((var(--chat-input-size) + #{$btn-send-margin}) * -1));