feat(Updater): Fixes

This commit is contained in:
thororen 2024-12-06 12:15:02 -05:00
parent d925fe4922
commit bb34833b3c
3 changed files with 17 additions and 9 deletions

View file

@ -100,6 +100,7 @@ async function init() {
if (Settings.autoUpdate) { if (Settings.autoUpdate) {
await update(); await update();
if (Settings.updateRelaunch) return relaunch;
if (Settings.autoUpdateNotification) if (Settings.autoUpdateNotification)
setTimeout(() => showNotification({ setTimeout(() => showNotification({
title: "Equicord has been updated!", title: "Equicord has been updated!",
@ -108,7 +109,6 @@ async function init() {
noPersist: true, noPersist: true,
onClick: relaunch onClick: relaunch
}), 10_000); }), 10_000);
if (Settings.autoUpdateRelaunch) return relaunch;
return; return;
} }

View file

@ -30,7 +30,6 @@ import plugins from "~plugins";
const logger = new Logger("Settings"); const logger = new Logger("Settings");
export interface Settings { export interface Settings {
autoUpdate: boolean; autoUpdate: boolean;
autoUpdateRelaunch: boolean;
autoUpdateNotification: boolean; autoUpdateNotification: boolean;
useQuickCss: boolean; useQuickCss: boolean;
enableReactDevtools: boolean; enableReactDevtools: boolean;
@ -39,6 +38,7 @@ export interface Settings {
enabledThemeLinks: string[]; enabledThemeLinks: string[];
frameless: boolean; frameless: boolean;
transparent: boolean; transparent: boolean;
updateRelaunch: boolean;
winCtrlQ: boolean; winCtrlQ: boolean;
macosVibrancyStyle: macosVibrancyStyle:
| "content" | "content"
@ -88,7 +88,6 @@ export interface Settings {
const DefaultSettings: Settings = { const DefaultSettings: Settings = {
autoUpdate: true, autoUpdate: true,
autoUpdateRelaunch: false,
autoUpdateNotification: true, autoUpdateNotification: true,
useQuickCss: true, useQuickCss: true,
themeLinks: [], themeLinks: [],
@ -100,6 +99,7 @@ const DefaultSettings: Settings = {
winCtrlQ: false, winCtrlQ: false,
macosVibrancyStyle: undefined, macosVibrancyStyle: undefined,
disableMinSize: false, disableMinSize: false,
updateRelaunch: false,
winNativeTitleBar: false, winNativeTitleBar: false,
plugins: {}, plugins: {},

View file

@ -107,6 +107,7 @@ function Updatable(props: CommonProps) {
const [isChecking, setIsChecking] = React.useState(false); const [isChecking, setIsChecking] = React.useState(false);
const [isUpdating, setIsUpdating] = React.useState(false); const [isUpdating, setIsUpdating] = React.useState(false);
const settings = useSettings(["updateRelaunch"]);
const isOutdated = (updates?.length ?? 0) > 0; const isOutdated = (updates?.length ?? 0) > 0;
return ( return (
@ -118,7 +119,8 @@ function Updatable(props: CommonProps) {
onClick={withDispatcher(setIsUpdating, async () => { onClick={withDispatcher(setIsUpdating, async () => {
if (await update()) { if (await update()) {
setUpdates([]); setUpdates([]);
await new Promise<void>(r => { if (settings.updateRelaunch) return relaunch();
return await new Promise<void>(r => {
Alerts.show({ Alerts.show({
title: "Update Success!", title: "Update Success!",
body: "Successfully updated. Restart now to apply the changes?", body: "Successfully updated. Restart now to apply the changes?",
@ -189,7 +191,7 @@ function Newer(props: CommonProps) {
} }
function Updater() { function Updater() {
const settings = useSettings(["autoUpdate", "autoUpdateRelaunch", "autoUpdateNotification"]); const settings = useSettings(["autoUpdate", "updateRelaunch", "autoUpdateNotification"]);
const [repo, err, repoPending] = useAwaiter(getRepo, { fallbackValue: "Loading..." }); const [repo, err, repoPending] = useAwaiter(getRepo, { fallbackValue: "Loading..." });
@ -215,16 +217,22 @@ function Updater() {
</Switch> </Switch>
<Switch <Switch
value={settings.autoUpdateNotification} value={settings.autoUpdateNotification}
onChange={(v: boolean) => settings.autoUpdateNotification = v} onChange={(v: boolean) => {
settings.autoUpdateNotification = v;
settings.updateRelaunch = !v;
}}
note="Shows a notification when Equicord automatically updates" note="Shows a notification when Equicord automatically updates"
disabled={!settings.autoUpdate} disabled={!settings.autoUpdate}
> >
Get notified when an automatic update completes Get notified when an automatic update completes
</Switch> </Switch>
<Switch <Switch
value={settings.autoUpdateRelaunch} value={settings.updateRelaunch}
onChange={(v: boolean) => settings.autoUpdateRelaunch = v} onChange={(v: boolean) => {
note="Relaunches the app after automatically updating with no prompt" settings.updateRelaunch = v;
settings.autoUpdateNotification = !v;
}}
note="Relaunches the app after updating with no prompt"
disabled={!settings.autoUpdate} disabled={!settings.autoUpdate}
> >
Automatically relaunch after updating Automatically relaunch after updating