tangled
alpha
login
or
join now
notnite.com
/
moonlight
3
fork
atom
this repo has no description
3
fork
atom
overview
issues
pulls
pipelines
moonbase: Process config changes from other extensions
notnite.com
11 months ago
54273de3
6287e82e
+29
-13
3 changed files
expand all
collapse all
unified
split
packages
core-extensions
src
moonbase
webpackModules
crashScreen.tsx
settings.tsx
stores.ts
+2
-2
packages/core-extensions/src/moonbase/webpackModules/crashScreen.tsx
···
84
84
}
85
85
86
86
function ExtensionDisableCard({ ext }: { ext: DetectedExtension }) {
87
87
-
function disableWithDependents() {
87
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
108
-
moonlightNode.writeConfig(config);
108
108
+
await moonlightNode.writeConfig(config);
109
109
window.location.reload();
110
110
}
111
111
}
+2
-2
packages/core-extensions/src/moonbase/webpackModules/settings.tsx
···
19
19
onReset={() => {
20
20
MoonbaseSettingsStore.reset();
21
21
}}
22
22
-
onSave={() => {
23
23
-
MoonbaseSettingsStore.writeConfig();
22
22
+
onSave={async () => {
23
23
+
await MoonbaseSettingsStore.writeConfig();
24
24
}}
25
25
/>
26
26
);
+25
-9
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
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
82
+
// This is async but we're calling it without
81
83
this.checkUpdates();
84
84
+
85
85
+
// Update our state if another extension edited the config programatically
86
86
+
moonlightNode.events.addEventListener(NodeEventType.ConfigSaved, async (config) => {
87
87
+
if (!this.submitting) {
88
88
+
this.config = this.clone(config);
89
89
+
await this.processConfigChanged();
90
90
+
this.emitChange();
91
91
+
}
92
92
+
});
82
93
}
83
94
84
95
async checkUpdates() {
···
499
510
return returnedAdvice;
500
511
}
501
512
502
502
-
writeConfig() {
503
503
-
this.submitting = true;
504
504
-
this.restartAdvice = this.#computeRestartAdvice();
505
505
-
const modifiedRepos = diff(this.savedConfig.repositories, this.config.repositories);
513
513
+
async writeConfig() {
514
514
+
try {
515
515
+
this.submitting = true;
516
516
+
await moonlightNode.writeConfig(this.config);
517
517
+
await this.processConfigChanged();
518
518
+
} finally {
519
519
+
this.submitting = false;
520
520
+
this.emitChange();
521
521
+
}
522
522
+
}
506
523
507
507
-
moonlightNode.writeConfig(this.config);
524
524
+
private async processConfigChanged() {
508
525
this.savedConfig = this.clone(this.config);
509
509
-
510
510
-
this.submitting = false;
526
526
+
this.restartAdvice = this.#computeRestartAdvice();
511
527
this.modified = false;
512
512
-
this.emitChange();
513
528
514
514
-
if (modifiedRepos.length !== 0) this.checkUpdates();
529
529
+
const modifiedRepos = diff(this.savedConfig.repositories, this.config.repositories);
530
530
+
if (modifiedRepos.length !== 0) await this.checkUpdates();
515
531
}
516
532
517
533
reset() {