From e4b8bef962cb0f7f2c4aa4d5132d45e5241c6d56 Mon Sep 17 00:00:00 2001 From: automated-signal <37887102+automated-signal@users.noreply.github.com> Date: Sun, 5 Dec 2021 17:27:11 -0800 Subject: [PATCH] Use different z-index for app-loading-screen Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> --- js/modules/indexeddb.js | 17 +++++++++++--- stylesheets/_modules.scss | 9 +++++++ ts/background.ts | 1 + ts/components/ConfirmationDialog.tsx | 35 +++++++++++++++++----------- ts/components/ModalHost.tsx | 26 ++++++++++++++------- ts/shims/showConfirmationDialog.tsx | 2 ++ 6 files changed, 64 insertions(+), 26 deletions(-) diff --git a/js/modules/indexeddb.js b/js/modules/indexeddb.js index b459be287..40242be9e 100644 --- a/js/modules/indexeddb.js +++ b/js/modules/indexeddb.js @@ -1,7 +1,7 @@ // Copyright 2018-2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only -/* global window, Whisper, setTimeout */ +/* global window, Whisper, clearTimeout, setTimeout */ const MESSAGE_MINIMUM_VERSION = 7; @@ -21,15 +21,26 @@ async function doesDatabaseExist() { let existed = true; - setTimeout(() => { + let timer = setTimeout(() => { window.SignalContext.log.warn( 'doesDatabaseExist: Timed out attempting to check IndexedDB status' ); return resolve(false); }, 1000); - req.onerror = reject; + const clearTimer = () => { + if (timer !== undefined) { + clearTimeout(timer); + timer = undefined; + } + }; + + req.onerror = error => { + clearTimer(); + reject(error); + }; req.onsuccess = () => { + clearTimer(); req.result.close(); resolve(existed); }; diff --git a/stylesheets/_modules.scss b/stylesheets/_modules.scss index d0c90b42c..c964e23ac 100644 --- a/stylesheets/_modules.scss +++ b/stylesheets/_modules.scss @@ -7913,6 +7913,15 @@ button.module-image__border-overlay:focus { z-index: $z-index-popup-overlay; } +.module-modal-host--on-top-of-everything { + $loading-screen-modal-overlay: $z-index-on-top-of-everything + 1; + + .module-modal-host__overlay, + .module-modal-host__container { + z-index: $loading-screen-modal-overlay; + } +} + // Module: GroupV2 Join Dialog .module-group-v2-join-dialog { diff --git a/ts/background.ts b/ts/background.ts index 5b2bb5c2d..34f1ddb26 100644 --- a/ts/background.ts +++ b/ts/background.ts @@ -542,6 +542,7 @@ export async function startApp(): Promise { try { await new Promise((resolve, reject) => { window.showConfirmationDialog({ + onTopOfEverything: true, cancelText: window.i18n('quit'), confirmStyle: 'negative', message: window.i18n('deleteOldIndexedDBData'), diff --git a/ts/components/ConfirmationDialog.tsx b/ts/components/ConfirmationDialog.tsx index ab55af9d4..efff8999e 100644 --- a/ts/components/ConfirmationDialog.tsx +++ b/ts/components/ConfirmationDialog.tsx @@ -17,19 +17,20 @@ export type ActionSpec = { style?: 'affirmative' | 'negative'; }; -export type OwnProps = { - readonly moduleClassName?: string; - readonly actions?: Array; - readonly cancelText?: string; - readonly children?: React.ReactNode; - readonly i18n: LocalizerType; - readonly onCancel?: () => unknown; - readonly onClose: () => unknown; - readonly title?: string | React.ReactNode; - readonly theme?: Theme; - readonly hasXButton?: boolean; - readonly cancelButtonVariant?: ButtonVariant; -}; +export type OwnProps = Readonly<{ + moduleClassName?: string; + actions?: Array; + cancelText?: string; + children?: React.ReactNode; + i18n: LocalizerType; + onCancel?: () => unknown; + onClose: () => unknown; + title?: string | React.ReactNode; + theme?: Theme; + hasXButton?: boolean; + cancelButtonVariant?: ButtonVariant; + onTopOfEverything?: boolean; +}>; export type Props = OwnProps; @@ -66,6 +67,7 @@ export const ConfirmationDialog = React.memo( title, hasXButton, cancelButtonVariant, + onTopOfEverything, }: Props) => { const { close, overlayStyles, modalStyles } = useAnimated(onClose, { getFrom: () => ({ opacity: 0, transform: 'scale(0.25)' }), @@ -91,7 +93,12 @@ export const ConfirmationDialog = React.memo( const hasActions = Boolean(actions.length); return ( - + unknown; - readonly onEscape?: () => unknown; - readonly overlayStyles?: SpringValues; - readonly theme?: Theme; -}; +export type PropsType = Readonly<{ + children: React.ReactElement; + noMouseClose?: boolean; + onClose: () => unknown; + onEscape?: () => unknown; + overlayStyles?: SpringValues; + theme?: Theme; + onTopOfEverything?: boolean; +}>; export const ModalHost = React.memo( ({ @@ -29,6 +31,7 @@ export const ModalHost = React.memo( onEscape, theme, overlayStyles, + onTopOfEverything, }: PropsType) => { const [root, setRoot] = React.useState(null); const [isMouseDown, setIsMouseDown] = React.useState(false); @@ -67,6 +70,11 @@ export const ModalHost = React.memo( [onClose, isMouseDown, setIsMouseDown] ); + const className = classNames([ + theme ? themeClassName(theme) : undefined, + onTopOfEverything ? 'module-modal-host--on-top-of-everything' : undefined, + ]); + return root ? createPortal( -
+
tag. type ConfirmationDialogViewProps = { + onTopOfEverything?: boolean; cancelText?: string; confirmStyle?: 'affirmative' | 'negative'; message: string; @@ -50,6 +51,7 @@ function showConfirmationDialog(options: ConfirmationDialogViewProps) { window.ReactDOM.render( // eslint-disable-next-line react/react-in-jsx-scope, react/jsx-no-undef {