this repo has no description

moonbase: Installation fixes (closes #146)

- Now full restarts the client
- Auto enable extensions after downloading
- Fix warning showing when updates were staged but not committed

Changed files
+26 -10
packages
core-extensions
src
moonbase
webpackModules
ui
extensions
+10
packages/core-extensions/src/moonbase/webpackModules/stores.ts
···
return this.submitting || this.installing;
}
showNotice() {
return this.modified;
}
···
this.modified = false;
this.config = this.clone(this.origConfig);
this.emitChange();
}
// Required because electron likes to make it immutable sometimes.
···
return this.submitting || this.installing;
}
+
// Required for the settings store contract
showNotice() {
return this.modified;
}
···
this.modified = false;
this.config = this.clone(this.origConfig);
this.emitChange();
+
}
+
+
restartDiscord() {
+
if (moonlightNode.isBrowser) {
+
window.location.reload();
+
} else {
+
// @ts-expect-error TODO: DiscordNative
+
window.DiscordNative.app.relaunch();
+
}
}
// Required because electron likes to make it immutable sometimes.
+13 -9
packages/core-extensions/src/moonbase/webpackModules/ui/extensions/card.tsx
···
const [tab, setTab] = React.useState(ExtensionPage.Info);
const [restartNeeded, setRestartNeeded] = React.useState(false);
-
const { ext, enabled, busy, update, conflicting } = useStateFromStores([MoonbaseSettingsStore], () => {
return {
ext: MoonbaseSettingsStore.getExtension(uniqueId),
enabled: MoonbaseSettingsStore.getExtensionEnabled(uniqueId),
busy: MoonbaseSettingsStore.busy,
update: MoonbaseSettingsStore.getExtensionUpdate(uniqueId),
conflicting: MoonbaseSettingsStore.getExtensionConflicting(uniqueId)
};
···
/>
)}
{ext.state === ExtensionState.NotDownloaded ? (
<Tooltip text={COMPAT_TEXT_MAP[ext.compat]} shouldShow={ext.compat !== ExtensionCompat.Compatible}>
{(props: any) => (
···
if (deps != null) {
await doMissingExtensionPopup(deps);
}
}}
>
Install
···
tooltipText="Delete"
onClick={() => {
MoonbaseSettingsStore.deleteExtension(uniqueId);
}}
/>
)}
···
MoonbaseSettingsStore.installExtension(uniqueId);
setRestartNeeded(true);
}}
-
/>
-
)}
-
-
{restartNeeded && (
-
<PanelButton
-
icon={() => <CircleWarningIcon color={Components.tokens.colors.STATUS_DANGER} />}
-
onClick={() => window.location.reload()}
-
tooltipText="You will need to reload/restart your client for this extension to work properly."
/>
)}
···
const [tab, setTab] = React.useState(ExtensionPage.Info);
const [restartNeeded, setRestartNeeded] = React.useState(false);
+
const { ext, enabled, busy, update, conflicting, showingNotice } = useStateFromStores([MoonbaseSettingsStore], () => {
return {
ext: MoonbaseSettingsStore.getExtension(uniqueId),
enabled: MoonbaseSettingsStore.getExtensionEnabled(uniqueId),
busy: MoonbaseSettingsStore.busy,
+
showingNotice: MoonbaseSettingsStore.showNotice(),
update: MoonbaseSettingsStore.getExtensionUpdate(uniqueId),
conflicting: MoonbaseSettingsStore.getExtensionConflicting(uniqueId)
};
···
/>
)}
+
{restartNeeded && !showingNotice && (
+
<PanelButton
+
icon={() => <CircleWarningIcon color={Components.tokens.colors.STATUS_DANGER} />}
+
onClick={() => MoonbaseSettingsStore.restartDiscord()}
+
tooltipText="You will need to reload/restart your client for this extension to work properly."
+
/>
+
)}
+
{ext.state === ExtensionState.NotDownloaded ? (
<Tooltip text={COMPAT_TEXT_MAP[ext.compat]} shouldShow={ext.compat !== ExtensionCompat.Compatible}>
{(props: any) => (
···
if (deps != null) {
await doMissingExtensionPopup(deps);
}
+
MoonbaseSettingsStore.setExtensionEnabled(uniqueId, true);
+
setRestartNeeded(true);
}}
>
Install
···
tooltipText="Delete"
onClick={() => {
MoonbaseSettingsStore.deleteExtension(uniqueId);
+
setRestartNeeded(true);
}}
/>
)}
···
MoonbaseSettingsStore.installExtension(uniqueId);
setRestartNeeded(true);
}}
/>
)}
+3 -1
packages/core-extensions/src/moonbase/webpackModules/ui/update.tsx
···
look={Button.Looks.OUTLINED}
color={Button.Colors.CUSTOM}
size={Button.Sizes.TINY}
-
onClick={() => window.location.reload()}
>
Restart Discord
</Button>
···
look={Button.Looks.OUTLINED}
color={Button.Colors.CUSTOM}
size={Button.Sizes.TINY}
+
onClick={() => {
+
MoonbaseSettingsStore.restartDiscord();
+
}}
>
Restart Discord
</Button>