+2
-2
packages/core-extensions/src/moonbase/webpackModules/crashScreen.tsx
+2
-2
packages/core-extensions/src/moonbase/webpackModules/crashScreen.tsx
···
84
84
}
85
85
86
86
function ExtensionDisableCard({ ext }: { ext: DetectedExtension }) {
87
-
function disableWithDependents() {
87
+
async function disableWithDependents() {
88
88
const disable = new Set<string>();
89
89
disable.add(ext.id);
90
90
for (const [id, dependencies] of moonlightNode.processedExtensions.dependencyGraph) {
···
105
105
msg += "?";
106
106
107
107
if (confirm(msg)) {
108
-
moonlightNode.writeConfig(config);
108
+
await moonlightNode.writeConfig(config);
109
109
window.location.reload();
110
110
}
111
111
}
+2
-2
packages/core-extensions/src/moonbase/webpackModules/settings.tsx
+2
-2
packages/core-extensions/src/moonbase/webpackModules/settings.tsx
+30
-10
packages/core-extensions/src/moonbase/webpackModules/stores.ts
+30
-10
packages/core-extensions/src/moonbase/webpackModules/stores.ts
···
13
13
import { mainRepo } from "@moonlight-mod/types/constants";
14
14
import { checkExtensionCompat, ExtensionCompat } from "@moonlight-mod/core/extension/loader";
15
15
import { CustomComponent } from "@moonlight-mod/types/coreExtensions/moonbase";
16
+
import { NodeEventType } from "@moonlight-mod/types/core/event";
16
17
import { getConfigOption, setConfigOption } from "@moonlight-mod/core/util/config";
17
18
import diff from "microdiff";
18
19
···
78
79
};
79
80
}
80
81
82
+
// This is async but we're calling it without
81
83
this.checkUpdates();
84
+
85
+
// Update our state if another extension edited the config programatically
86
+
moonlightNode.events.addEventListener(NodeEventType.ConfigSaved, (config) => {
87
+
if (!this.submitting) {
88
+
this.config = this.clone(config);
89
+
// NOTE: This is also async but we're calling it without
90
+
this.processConfigChanged();
91
+
}
92
+
});
82
93
}
83
94
84
95
async checkUpdates() {
···
239
250
let val = this.config.extensions[ext.id];
240
251
241
252
if (val == null) {
242
-
this.config.extensions[ext.id] = { enabled };
253
+
this.config.extensions[ext.id] = enabled;
243
254
this.modified = this.isModified();
244
255
this.emitChange();
245
256
return;
···
499
510
return returnedAdvice;
500
511
}
501
512
502
-
writeConfig() {
503
-
this.submitting = true;
504
-
this.restartAdvice = this.#computeRestartAdvice();
505
-
const modifiedRepos = diff(this.savedConfig.repositories, this.config.repositories);
513
+
async writeConfig() {
514
+
try {
515
+
this.submitting = true;
516
+
this.emitChange();
506
517
507
-
moonlightNode.writeConfig(this.config);
508
-
this.savedConfig = this.clone(this.config);
518
+
await moonlightNode.writeConfig(this.config);
519
+
await this.processConfigChanged();
520
+
} finally {
521
+
this.submitting = false;
522
+
this.emitChange();
523
+
}
524
+
}
509
525
510
-
this.submitting = false;
526
+
private async processConfigChanged() {
527
+
this.savedConfig = this.clone(this.config);
528
+
this.restartAdvice = this.#computeRestartAdvice();
511
529
this.modified = false;
512
-
this.emitChange();
513
530
514
-
if (modifiedRepos.length !== 0) this.checkUpdates();
531
+
const modifiedRepos = diff(this.savedConfig.repositories, this.config.repositories);
532
+
if (modifiedRepos.length !== 0) await this.checkUpdates();
533
+
534
+
this.emitChange();
515
535
}
516
536
517
537
reset() {