Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Auto Update Toggle Switch #461

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 53 additions & 50 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
"remark-gfm": "^2.0.0",
"semver": "7.3.5",
"simplebar-react": "^3.2.4",
"source-map": "^0.7.4",
"styled-components": "^5.2.1",
"tabler-icons-react": "~1.33.0",
"tailwind-merge": "^2.2.1",
Expand Down
5 changes: 3 additions & 2 deletions src/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ interface Settings {
useDarkTheme: boolean;
allowSeasonalEffects: boolean;
msfsPackagePath: string;
configDownloadUrl: string;
configDownloadUrl: string,
useAutoUpdate: boolean;
};
cache: {
main: {
Expand Down Expand Up @@ -260,4 +261,4 @@ const store = new Store({ schema, clearInvalidConfig: true });
// Workaround to flush the defaults
store.set('metaInfo.lastLaunch', Date.now());

export default store;
export default store;
7 changes: 7 additions & 0 deletions src/renderer/components/AddonSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ export const AddonSection = (): JSX.Element => {
}
}, [addonDiscovered, hiddenAddon]);

useEffect(() => {
const autoUpdateEnabled = settings.get("mainSettings.useAutoUpdate");
if (autoUpdateEnabled && status === InstallStatus.NeedsUpdate) {
handleInstall();
}
}, [status]);

const { showModal, showModalAsync } = useModals();

const handleTrackSelection = (track: AddonTrack) => {
Expand Down
16 changes: 16 additions & 0 deletions src/renderer/components/SettingsSection/Download.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ const UseCdnSettingItem = ({ value, setValue }: SettingItemProps<boolean>) => {
);
};

const AutoUpdateSettingItem = ({ value, setValue }: SettingItemProps<boolean>) => {
const handleClick = () => {
const newState = !value;
setValue(newState);
settings.set('mainSettings.useAutoUpdate', newState);
};

return (
<SettingsItem name="Auto Update">
<Toggle value={value} onToggle={handleClick} />
</SettingsItem>
);
};

export const DownloadSettings = (): JSX.Element => {
const [communityPath, setCommunityPath] = useSetting<string>('mainSettings.msfsCommunityPath');
const [installPath, setInstallPath] = useSetting<string>('mainSettings.installPath');
Expand All @@ -116,6 +130,7 @@ export const DownloadSettings = (): JSX.Element => {
'mainSettings.disableExperimentalWarning',
);
const [useCdnCache, setUseCdnCache] = useSetting<boolean>('mainSettings.useCdnCache');
const [useAutoUpdate, setUseAutoUpdate] = useSetting<boolean>('mainSettings.useAutoUpdate');

return (
<div>
Expand All @@ -128,6 +143,7 @@ export const DownloadSettings = (): JSX.Element => {
{separateTempLocation && <TempLocationSettingItem value={tempLocation} setValue={setTempLocation} />}
<DisableWarningSettingItem value={disableVersionWarning} setValue={setDisableVersionWarning} />
<UseCdnSettingItem value={useCdnCache} setValue={setUseCdnCache} />
<AutoUpdateSettingItem value={useAutoUpdate} setValue={setUseAutoUpdate} />
</div>
</div>
</div>
Expand Down
Loading