A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.
perf(app): load the keyboard mode intro modal only when it is shown (#1880)
Hampus9b3dc190370b
diff --git a/fluxer_app/src/features/app/components/layout/KeyboardModeListener.ts b/fluxer_app/src/features/app/components/layout/KeyboardModeListener.tsindex b2914ffaf..18528b236 100644--- a/fluxer_app/src/features/app/components/layout/KeyboardModeListener.ts+++ b/fluxer_app/src/features/app/components/layout/KeyboardModeListener.ts@@ -52,7 +52,7 @@ export const KeyboardModeListener = observer(() => {useEffect(() => {let lastWindowFocusTime = document.hasFocus() ? 0 : -Infinity;const REFOCUS_THRESHOLD_MS = 100;- const handleWindowFocus = () => {+ const handleWindowFocused = () => {lastWindowFocusTime = performance.now();};const handleKeyDown = (event: KeyboardEvent) => {@@ -75,12 +75,12 @@ export const KeyboardModeListener = observer(() => {KeyboardMode.exitKeyboardMode();}};- window.addEventListener('focus', handleWindowFocus);+ window.addEventListener('focus', handleWindowFocused);window.addEventListener('keydown', handleKeyDown, true);window.addEventListener('mousedown', handlePointer, true);window.addEventListener('pointerdown', handlePointer, true);return () => {- window.removeEventListener('focus', handleWindowFocus);+ window.removeEventListener('focus', handleWindowFocused);window.removeEventListener('keydown', handleKeyDown, true);window.removeEventListener('mousedown', handlePointer, true);window.removeEventListener('pointerdown', handlePointer, true);diff --git a/fluxer_app/src/features/ui/state/KeyboardMode.tsx b/fluxer_app/src/features/ui/state/KeyboardMode.tsxindex 2080680b5..22e2ebe4d 100644--- a/fluxer_app/src/features/ui/state/KeyboardMode.tsx+++ b/fluxer_app/src/features/ui/state/KeyboardMode.tsx@@ -1,6 +1,5 @@// SPDX-License-Identifier: AGPL-3.0-or-later-import {KeyboardModeIntroModal} from '@app/features/input/components/modals/KeyboardModeIntroModal';import {Logger} from '@app/features/platform/utils/AppLogger';import {registerKeyboardModeRestoreCallback, registerKeyboardModeStateResolver} from '@app/features/ui/state/Modal';import {makeSyncedField} from '@app/features/user/state/SyncedField';@@ -35,7 +34,10 @@ class KeyboardMode {});if (showIntro && !this.introSeen) {this.introSeen = true;- void import('@app/features/ui/commands/ModalCommands').then(({modal, push}) => {+ void Promise.all([+ import('@app/features/ui/commands/ModalCommands'),+ import('@app/features/input/components/modals/KeyboardModeIntroModal'),+ ]).then(([{modal, push}, {KeyboardModeIntroModal}]) => {push(modal(() => <KeyboardModeIntroModal data-flx="ui.keyboard-mode.keyboard-mode-intro-modal" />));});}