mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Show splash window until bundled extensions have been loaded (#4570)
* Show splash window until bundled extensions have been loaded Signed-off-by: Juho Heikka <juho.heikka@gmail.com> * Remove unnecessary variable. Signed-off-by: Juho Heikka <juho.heikka@gmail.com> * Refactor autoInitExtensions Signed-off-by: Juho Heikka <juho.heikka@gmail.com> * Add timeout to waiting for bundled extensions to load Signed-off-by: Juho Heikka <juho.heikka@gmail.com>
This commit is contained in:
1 parent
43277d2af6
commit
9284741df5
5 files changed
+55
-7
No files matched your search
@@ -255,7 +255,8 @@ export class ExtensionLoader {
|
||||
|
||||
loadOnClusterManagerRenderer() {
|
||||
logger.debug(`${logModule}: load on main renderer (cluster manager)`);
|
||||
this.autoInitExtensions(async (extension: LensRendererExtension) => {
|
||||
|
||||
return this.autoInitExtensions(async (extension: LensRendererExtension) => {
|
||||
const removeItems = [
|
||||
registries.GlobalPageRegistry.getInstance().add(extension.globalPages, extension),
|
||||
registries.AppPreferenceRegistry.getInstance().add(extension.appPreferences),
|
||||
@@ -311,7 +312,9 @@ export class ExtensionLoader {
|
||||
}
|
||||
|
||||
protected autoInitExtensions(register: (ext: LensExtension) => Promise<Disposer[]>) {
|
||||
return reaction(() => this.toJSON(), installedExtensions => {
|
||||
const loadingExtensions: { isBundled: boolean, loaded: Promise<void> }[] = [];
|
||||
|
||||
reaction(() => this.toJSON(), installedExtensions => {
|
||||
for (const [extId, extension] of installedExtensions) {
|
||||
const alreadyInit = this.instances.has(extId) || this.nonInstancesByName.has(extension.manifest.name);
|
||||
|
||||
@@ -326,7 +329,14 @@ export class ExtensionLoader {
|
||||
|
||||
const instance = new LensExtensionClass(extension);
|
||||
|
||||
instance.enable(register);
|
||||
const loaded = instance.enable(register).catch((err) => {
|
||||
logger.error(`${logModule}: failed to enable`, { ext: extension, err });
|
||||
});
|
||||
|
||||
loadingExtensions.push({
|
||||
isBundled: extension.isBundled,
|
||||
loaded,
|
||||
});
|
||||
this.instances.set(extId, instance);
|
||||
} catch (err) {
|
||||
logger.error(`${logModule}: activation extension error`, { ext: extension, err });
|
||||
@@ -338,6 +348,8 @@ export class ExtensionLoader {
|
||||
}, {
|
||||
fireImmediately: true,
|
||||
});
|
||||
|
||||
return loadingExtensions;
|
||||
}
|
||||
|
||||
protected requireExtension(extension: InstalledExtension): LensExtensionConstructor | null {
|
||||
|
||||
Reference in new issue
Block a user