mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
feat(desktop): add a setting and flag to disable updates (#3483)
This commit is contained in:
1 parent
3a74a6f97a
commit
674b4d26d1
58 files changed
+1477
-42
No files matched your search
@@ -39,6 +39,7 @@ import {
|
||||
} from '@app/features/user/components/modals/tabs/advanced_settings_tab/AdvancedChatControls';
|
||||
import {DeveloperModeControl} from '@app/features/user/components/modals/tabs/advanced_settings_tab/AdvancedClientDeveloperControls';
|
||||
import {
|
||||
AutomaticUpdatesControl,
|
||||
HardwareAccelerationControl,
|
||||
NativeTitleBarControl,
|
||||
SourceMapsControl,
|
||||
@@ -105,6 +106,7 @@ export const DIRECT_CONTROL_ITEM_IDS = new Set([
|
||||
'accessibility-stay-interactive-unfocused',
|
||||
'advanced-native-title-bar',
|
||||
'advanced-hardware-acceleration',
|
||||
'advanced-automatic-updates',
|
||||
'desktop-source-maps',
|
||||
]);
|
||||
|
||||
@@ -146,6 +148,7 @@ export const COMPACT_SWITCH_CONTROL_ITEM_IDS = new Set([
|
||||
'accessibility-stay-interactive-unfocused',
|
||||
'advanced-native-title-bar',
|
||||
'advanced-hardware-acceleration',
|
||||
'advanced-automatic-updates',
|
||||
'desktop-source-maps',
|
||||
]);
|
||||
|
||||
@@ -351,6 +354,10 @@ export const AdvancedSettingControl = observer(({item}: {item: SearchableSetting
|
||||
return (
|
||||
<HardwareAccelerationControl data-flx="user.advanced-setting-direct-controls.advanced-setting-control.hardware-acceleration-control" />
|
||||
);
|
||||
case 'advanced-automatic-updates':
|
||||
return (
|
||||
<AutomaticUpdatesControl data-flx="user.advanced-setting-direct-controls.advanced-setting-control.automatic-updates-control" />
|
||||
);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
+66
@@ -6,6 +6,7 @@ import {
|
||||
getCachedDesktopTroubleshootingSettings,
|
||||
getDesktopTroubleshootingSettings,
|
||||
setDesktopDisableHardwareAcceleration,
|
||||
setDesktopDisableModuleUpdates,
|
||||
} from '@app/features/devtools/utils/DesktopTroubleshootingUtils';
|
||||
import {CANCEL_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors';
|
||||
import SourceMaps from '@app/features/platform/state/SourceMaps';
|
||||
@@ -21,6 +22,7 @@ import {
|
||||
} from '@app/features/ui/utils/DesktopWindowBehaviorUtils';
|
||||
import {getElectronAPI} from '@app/features/ui/utils/NativeUtils';
|
||||
import {
|
||||
DISABLE_AUTOMATIC_UPDATES_DESCRIPTOR,
|
||||
DOWNLOAD_SOURCE_MAPS_DESCRIPTOR,
|
||||
LATER_DESCRIPTOR,
|
||||
RESTART_NOW_DESCRIPTOR,
|
||||
@@ -61,6 +63,14 @@ const DISABLE_HARDWARE_ACCELERATION_DESCRIPTOR = msg({
|
||||
message: 'Disable hardware acceleration?',
|
||||
comment: 'Confirmation prompt in advanced settings.',
|
||||
});
|
||||
const ENABLE_AUTOMATIC_UPDATES_PROMPT_DESCRIPTOR = msg({
|
||||
message: 'Enable automatic updates?',
|
||||
comment: 'Confirmation prompt in advanced settings.',
|
||||
});
|
||||
const DISABLE_AUTOMATIC_UPDATES_PROMPT_DESCRIPTOR = msg({
|
||||
message: 'Disable automatic updates?',
|
||||
comment: 'Confirmation prompt in advanced settings.',
|
||||
});
|
||||
|
||||
export function useDesktopWindowBehaviorSettings() {
|
||||
const cachedDesktopWindowBehavior = getCachedDesktopWindowBehaviorSettings();
|
||||
@@ -238,3 +248,59 @@ export const HardwareAccelerationControl = observer(() => {
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
export const AutomaticUpdatesControl = observer(() => {
|
||||
const {i18n} = useLingui();
|
||||
const {desktopTroubleshooting, desktopTroubleshootingBusy, setDesktopTroubleshooting, setDesktopTroubleshootingBusy} =
|
||||
useDesktopTroubleshootingSettings();
|
||||
const handleChange = useCallback(
|
||||
(value: boolean) => {
|
||||
ModalCommands.push(
|
||||
modal(() => (
|
||||
<ConfirmModal
|
||||
title={
|
||||
value
|
||||
? i18n._(DISABLE_AUTOMATIC_UPDATES_PROMPT_DESCRIPTOR)
|
||||
: i18n._(ENABLE_AUTOMATIC_UPDATES_PROMPT_DESCRIPTOR)
|
||||
}
|
||||
description={
|
||||
value ? (
|
||||
<Trans>
|
||||
{ph({PRODUCT_NAME: RuntimeConfig.productName})} needs to restart to stop downloading updates. It can
|
||||
fall behind and stop working with the service until you turn updates back on.
|
||||
</Trans>
|
||||
) : (
|
||||
<Trans>
|
||||
{ph({PRODUCT_NAME: RuntimeConfig.productName})} needs to restart to start downloading updates again.
|
||||
</Trans>
|
||||
)
|
||||
}
|
||||
primaryText={i18n._(RESTART_NOW_DESCRIPTOR)}
|
||||
primaryVariant="primary"
|
||||
secondaryText={i18n._(CANCEL_DESCRIPTOR)}
|
||||
onPrimary={async () => {
|
||||
setDesktopTroubleshootingBusy(true);
|
||||
const next = await setDesktopDisableModuleUpdates(value);
|
||||
if (next) {
|
||||
setDesktopTroubleshooting(next);
|
||||
}
|
||||
setDesktopTroubleshootingBusy(false);
|
||||
}}
|
||||
data-flx="user.advanced-settings-tab.automatic-updates.confirm-modal"
|
||||
/>
|
||||
)),
|
||||
);
|
||||
},
|
||||
[i18n, setDesktopTroubleshooting, setDesktopTroubleshootingBusy],
|
||||
);
|
||||
return (
|
||||
<Switch
|
||||
ariaLabel={i18n._(DISABLE_AUTOMATIC_UPDATES_DESCRIPTOR)}
|
||||
value={desktopTroubleshooting?.disableModuleUpdates ?? false}
|
||||
disabled={desktopTroubleshootingBusy || desktopTroubleshooting === null}
|
||||
onChange={handleChange}
|
||||
compact
|
||||
data-flx="user.advanced-settings-tab.switch.automatic-updates"
|
||||
/>
|
||||
);
|
||||
});
|
||||
+20
@@ -14,6 +14,7 @@ import {
|
||||
TITLE_BAR_DESCRIPTOR as TITLEBAR_DESCRIPTOR,
|
||||
} from '@app/features/user/components/settings_utils/section_registry/SharedDescriptors';
|
||||
import {
|
||||
DISABLE_AUTOMATIC_UPDATES_DESCRIPTOR,
|
||||
DOWNLOAD_SOURCE_MAPS_DESCRIPTOR,
|
||||
LAUNCH_AT_LOGIN_DESCRIPTOR,
|
||||
USE_NATIVE_TITLE_BAR_DESCRIPTOR,
|
||||
@@ -70,6 +71,16 @@ const TOGGLE_HARDWARE_ACCELERATION_DESCRIPTOR = msg({
|
||||
comment: 'Settings search entry description. One-line summary of what the settings search entry controls.',
|
||||
});
|
||||
|
||||
const UPDATES_DESCRIPTOR = msg({
|
||||
message: 'Updates',
|
||||
comment: 'Settings search synonym. Used to match this term when the user types it in the settings search bar.',
|
||||
});
|
||||
const STOP_DOWNLOADING_UPDATES_DESCRIPTOR = msg({
|
||||
message:
|
||||
'{productName} stops downloading updates. It can fall behind and stop working with the service until updates are turned back on. Takes effect the next time {productName} starts.',
|
||||
comment: 'Settings search entry description. One-line summary of what the settings search entry controls.',
|
||||
});
|
||||
|
||||
const AUTOMATIC_START_DESCRIPTOR = msg({
|
||||
message: 'Automatic start',
|
||||
comment: 'Settings search synonym. Used to match this term when the user types it in the settings search bar.',
|
||||
@@ -247,6 +258,15 @@ export const desktopSettingsIndex: Array<SearchableSettingDescriptor> = [
|
||||
tags: ['desktop'],
|
||||
isVisible: () => isDesktop() && getElectronAPI()?.platform !== 'darwin',
|
||||
},
|
||||
{
|
||||
id: 'advanced-automatic-updates',
|
||||
tabType: 'desktop_settings',
|
||||
label: DISABLE_AUTOMATIC_UPDATES_DESCRIPTOR,
|
||||
keywords: [UPDATES_DESCRIPTOR],
|
||||
description: {...STOP_DOWNLOADING_UPDATES_DESCRIPTOR, values: {productName: PRODUCT_NAME}},
|
||||
tags: ['desktop'],
|
||||
isVisible: () => isDesktop() && getElectronAPI()?.setDesktopDisableModuleUpdates != null,
|
||||
},
|
||||
{
|
||||
id: 'advanced-autostart',
|
||||
tabType: 'desktop_settings',
|
||||
|
||||
Reference in new issue
Block a user