diff --git a/ts/components/Preferences.stories.tsx b/ts/components/Preferences.stories.tsx index df386ae3c6..4b6d8b6e7b 100644 --- a/ts/components/Preferences.stories.tsx +++ b/ts/components/Preferences.stories.tsx @@ -216,7 +216,6 @@ export default { hasMinimizeToSystemTray: true, hasNotificationAttention: false, hasNotifications: true, - hasPendingUpdate: false, hasReadReceipts: true, hasRelayCalls: false, hasSpellCheck: true, @@ -234,7 +233,6 @@ export default { isContentProtectionSupported: true, isContentProtectionNeeded: true, isMinimizeToAndStartInSystemTraySupported: true, - isUpdateDownloaded: false, lastSyncTime: Date.now(), localeOverride: null, localBackupFolder: undefined, @@ -255,6 +253,7 @@ export default { selectedMicrophone: availableMicrophones[0], selectedSpeaker: availableSpeakers[1], sentMediaQualitySetting: 'standard', + shouldShowUpdateDialog: false, themeSetting: 'system', theme: ThemeType.light, universalExpireTimer: DurationInSeconds.HOUR, @@ -539,14 +538,9 @@ LocalBackupsSetupViewBackupKey.args = { localBackupFolder: '/home/signaluser/Signal Backups/', }; -export const UpdateAvailable = Template.bind({}); -UpdateAvailable.args = { - hasPendingUpdate: true, -}; - -export const UpdateDownloaded = Template.bind({}); -UpdateDownloaded.args = { - isUpdateDownloaded: true, +export const ShowingUpdateDialog = Template.bind({}); +ShowingUpdateDialog.args = { + shouldShowUpdateDialog: true, }; export const NavTabsCollapsed = Template.bind({}); diff --git a/ts/components/Preferences.tsx b/ts/components/Preferences.tsx index d8fcab6cd1..46153d0529 100644 --- a/ts/components/Preferences.tsx +++ b/ts/components/Preferences.tsx @@ -149,16 +149,15 @@ export type PropsDataType = { resolvedLocale: string; // Other props + badge: BadgeType | undefined; hasFailedStorySends: boolean; - hasPendingUpdate: boolean; initialSpellCheckSetting: boolean; - isUpdateDownloaded: boolean; + me: ConversationType; navTabsCollapsed: boolean; otherTabsUnreadStats: UnreadStats; - me: ConversationType; - badge: BadgeType | undefined; - theme: ThemeType; preferredWidthFromStorage: number; + shouldShowUpdateDialog: boolean; + theme: ThemeType; // Limited support features isAutoDownloadUpdatesSupported: boolean; @@ -365,7 +364,6 @@ export function Preferences({ hasMinimizeToSystemTray, hasNotificationAttention, hasNotifications, - hasPendingUpdate, hasReadReceipts, hasRelayCalls, hasSpellCheck, @@ -384,7 +382,6 @@ export function Preferences({ isSystemTraySupported, isMinimizeToAndStartInSystemTraySupported, isInternalUser, - isUpdateDownloaded, lastSyncTime, localBackupFolder, makeSyncRequest, @@ -451,6 +448,7 @@ export function Preferences({ sentMediaQualitySetting, setGlobalDefaultConversationColor, setPage, + shouldShowUpdateDialog, showToast, localeOverride, theme, @@ -500,7 +498,7 @@ export function Preferences({ } let maybeUpdateDialog: JSX.Element | undefined; - if (hasPendingUpdate || isUpdateDownloaded) { + if (shouldShowUpdateDialog) { maybeUpdateDialog = renderUpdateDialog({ containerWidthBreakpoint: WidthBreakpoint.Wide, }); diff --git a/ts/state/smart/Preferences.tsx b/ts/state/smart/Preferences.tsx index c4ce07f63a..a5e1f16dbe 100644 --- a/ts/state/smart/Preferences.tsx +++ b/ts/state/smart/Preferences.tsx @@ -55,10 +55,7 @@ import { sendSyncRequests } from '../../textsecure/syncRequests'; import { SmartUpdateDialog } from './UpdateDialog'; import { Page, Preferences } from '../../components/Preferences'; import { useUpdatesActions } from '../ducks/updates'; -import { - getHasPendingUpdate, - isUpdateDownloaded as getIsUpdateDownloaded, -} from '../selectors/updates'; +import { getUpdateDialogType } from '../selectors/updates'; import { getHasAnyFailedStorySends } from '../selectors/stories'; import { getOtherTabsUnreadStats, getSelectedLocation } from '../selectors/nav'; import { getPreferredBadgeSelector } from '../selectors/badges'; @@ -74,6 +71,7 @@ import { isLocalBackupsEnabledForRedux } from '../../util/isLocalBackupsEnabled' import type { StorageAccessType, ZoomFactorType } from '../../types/Storage'; import type { ThemeType } from '../../util/preload'; import type { WidthBreakpoint } from '../../components/_util'; +import { DialogType } from '../../types/Dialogs'; const DEFAULT_NOTIFICATION_SETTING = 'message'; @@ -150,8 +148,7 @@ export function SmartPreferences(): JSX.Element | null { const i18n = useSelector(getIntl); const items = useSelector(getItems); const hasFailedStorySends = useSelector(getHasAnyFailedStorySends); - const hasPendingUpdate = useSelector(getHasPendingUpdate); - const isUpdateDownloaded = useSelector(getIsUpdateDownloaded); + const dialogType = useSelector(getUpdateDialogType); const me = useSelector(getMe); const navTabsCollapsed = useSelector(getNavTabsCollapsed); const otherTabsUnreadStats = useSelector(getOtherTabsUnreadStats); @@ -159,6 +156,7 @@ export function SmartPreferences(): JSX.Element | null { const theme = useSelector(getTheme); const badge = useSelector(getPreferredBadgeSelector)(me.badges); + const shouldShowUpdateDialog = dialogType !== DialogType.None; // The weird ones @@ -714,7 +712,6 @@ export function SmartPreferences(): JSX.Element | null { hasMinimizeToSystemTray={hasMinimizeToSystemTray} hasNotificationAttention={hasNotificationAttention} hasNotifications={hasNotifications} - hasPendingUpdate={hasPendingUpdate} hasReadReceipts={hasReadReceipts} hasRelayCalls={hasRelayCalls} hasSpellCheck={hasSpellCheck} @@ -735,7 +732,6 @@ export function SmartPreferences(): JSX.Element | null { isSyncSupported={isSyncSupported} isSystemTraySupported={isSystemTraySupported} isInternalUser={isInternalUser} - isUpdateDownloaded={isUpdateDownloaded} lastSyncTime={lastSyncTime} localBackupFolder={localBackupFolder} localeOverride={localeOverride} @@ -798,13 +794,14 @@ export function SmartPreferences(): JSX.Element | null { resetAllChatColors={resetAllChatColors} resetDefaultChatColor={resetDefaultChatColor} resolvedLocale={resolvedLocale} + savePreferredLeftPaneWidth={savePreferredLeftPaneWidth} selectedCamera={selectedCamera} selectedMicrophone={selectedMicrophone} selectedSpeaker={selectedSpeaker} sentMediaQualitySetting={sentMediaQualitySetting} setGlobalDefaultConversationColor={setGlobalDefaultConversationColor} setPage={setPage} - savePreferredLeftPaneWidth={savePreferredLeftPaneWidth} + shouldShowUpdateDialog={shouldShowUpdateDialog} showToast={showToast} theme={theme} themeSetting={themeSetting} diff --git a/ts/state/smart/UpdateDialog.tsx b/ts/state/smart/UpdateDialog.tsx index e30980f4dc..5b120edcf5 100644 --- a/ts/state/smart/UpdateDialog.tsx +++ b/ts/state/smart/UpdateDialog.tsx @@ -13,6 +13,7 @@ import { getUpdateDownloadedSize, getUpdateVersion, } from '../selectors/updates'; +import { DialogType } from '../../types/Dialogs'; type SmartUpdateDialogProps = Readonly<{ containerWidthBreakpoint: WidthBreakpoint; @@ -29,6 +30,14 @@ export const SmartUpdateDialog = memo(function SmartUpdateDialog({ const downloadSize = useSelector(getUpdateDownloadSize); const downloadedSize = useSelector(getUpdateDownloadedSize); const version = useSelector(getUpdateVersion); + + const shouldDisableDismiss = + disableDismiss && + dialogType !== DialogType.Cannot_Update && + dialogType !== DialogType.Cannot_Update_Require_Manual && + dialogType !== DialogType.MacOS_Read_Only && + dialogType !== DialogType.UnsupportedOS; + return (