mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Refactor autoInitExtensions
Signed-off-by: Juho Heikka <juho.heikka@gmail.com>
This commit is contained in:
parent
1781a05ea8
commit
1dd462e9b4
@ -313,7 +313,7 @@ export class ExtensionLoader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected autoInitExtensions(register: (ext: LensExtension) => Promise<Disposer[]>) {
|
protected autoInitExtensions(register: (ext: LensExtension) => Promise<Disposer[]>) {
|
||||||
const bundledLoaded: Promise<void>[] = [];
|
const loadingExtensions: { isBundled: boolean, loaded: Promise<void> }[] = [];
|
||||||
|
|
||||||
reaction(() => this.toJSON(), installedExtensions => {
|
reaction(() => this.toJSON(), installedExtensions => {
|
||||||
for (const [extId, extension] of installedExtensions) {
|
for (const [extId, extension] of installedExtensions) {
|
||||||
@ -334,9 +334,10 @@ export class ExtensionLoader {
|
|||||||
logger.error(`${logModule}: failed to enable`, { ext: extension, err });
|
logger.error(`${logModule}: failed to enable`, { ext: extension, err });
|
||||||
});
|
});
|
||||||
|
|
||||||
if (extension.isBundled) {
|
loadingExtensions.push({
|
||||||
bundledLoaded.push(loaded);
|
isBundled: extension.isBundled,
|
||||||
}
|
loaded,
|
||||||
|
});
|
||||||
this.instances.set(extId, instance);
|
this.instances.set(extId, instance);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(`${logModule}: activation extension error`, { ext: extension, err });
|
logger.error(`${logModule}: activation extension error`, { ext: extension, err });
|
||||||
@ -349,7 +350,7 @@ export class ExtensionLoader {
|
|||||||
fireImmediately: true,
|
fireImmediately: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return Promise.all(bundledLoaded);
|
return loadingExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected requireExtension(extension: InstalledExtension): LensExtensionConstructor | null {
|
protected requireExtension(extension: InstalledExtension): LensExtensionConstructor | null {
|
||||||
|
|||||||
@ -56,7 +56,10 @@ export class RootFrame extends React.Component {
|
|||||||
catalogEntityRegistry.init();
|
catalogEntityRegistry.init();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await extensionLoader.loadOnClusterManagerRenderer();
|
const loadingExtensions = extensionLoader.loadOnClusterManagerRenderer();
|
||||||
|
const loadingBundledExtensions = loadingExtensions.filter(e => e.isBundled).map(e => e.loaded);
|
||||||
|
|
||||||
|
await Promise.all(loadingBundledExtensions);
|
||||||
} finally {
|
} finally {
|
||||||
ipcRenderer.send(BundledExtensionsLoaded);
|
ipcRenderer.send(BundledExtensionsLoaded);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user