Skip to content

Commit

Permalink
chore
Browse files Browse the repository at this point in the history
  • Loading branch information
Delusoire committed Aug 8, 2024
1 parent 08e252d commit fa1af7e
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,10 @@ export class Module extends ModuleBase<Module, ModuleInstance> {
const enabledInstance = this.getEnabledInstance();
await enabledInstance?.transition.block();

if (instance.isEnabled() || (enabledInstance && !this.canDisable(enabledInstance))) {
if (
instance.isEnabled() ||
(enabledInstance && !this.canDisable(enabledInstance))
) {
return false;
}

Expand Down Expand Up @@ -373,7 +376,7 @@ export abstract class ModuleInstanceBase<
public metadata: Metadata | null,
public artifacts: Array<string>,
public checksum: string,
) { }
) {}

// ?
public updateMetadata(metadata: Metadata) {
Expand Down Expand Up @@ -784,9 +787,7 @@ export class ModuleInstance extends ModuleInstanceBase<Module>
public async onEnable() {
if (this.installed) {
await this.loadProviders();
const storeUrl = this.getMetadataURL()!;
const metadata = await fetchJson<Metadata>(storeUrl);
this.updateMetadata(metadata);
await this.ensureMetadata();
}
}

Expand Down Expand Up @@ -925,6 +926,20 @@ export class ModuleInstance extends ModuleInstanceBase<Module>
this.module.parent = null;
}
}
public async ensureMetadata() {
if (!this.metadata) {
try {
const storeUrl = this.getMetadataURL()!;
const metadata = await fetchJson<Metadata>(storeUrl);
this.updateMetadata(metadata);
} catch (e) {
throw new Error(
`couldn't load metadata for module '${this.getIdentifier()}'`,
{ cause: e },
);
}
}
}
}

export const INTERNAL_MIXIN_LOADER: MixinLoader = {
Expand Down

0 comments on commit fa1af7e

Please sign in to comment.