mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix circular dependency. Fix waiting for instance enabled.
Signed-off-by: Panu Horsmalahti <phorsmalahti@mirantis.com>
This commit is contained in:
parent
28b49cc8f2
commit
7052475703
@ -301,8 +301,18 @@ export class ExtensionLoader {
|
||||
return this.extensions.get(extId);
|
||||
}
|
||||
|
||||
public async instanceToBeEnabled(extId: LensExtensionId): Promise<void> {
|
||||
return when(() => this.instances.get(extId)?.isEnabled);
|
||||
public async waitForEnabled(name: string): Promise<void> {
|
||||
return when(() => {
|
||||
for (const instanceEntry of this.instances) {
|
||||
const [, extension ] = instanceEntry;
|
||||
|
||||
if (extension.manifest.name === name) {
|
||||
return extension.isEnabled;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -4,8 +4,6 @@ import { match, matchPath } from "react-router";
|
||||
import { pathToRegexp } from "path-to-regexp";
|
||||
import { subscribeToBroadcast } from "../../common/ipc";
|
||||
import logger from "../logger";
|
||||
import { extensionLoader } from "../../extensions/extension-loader";
|
||||
import { sanitizeExtensionName } from "../../extensions/lens-extension";
|
||||
|
||||
export enum RoutingErrorType {
|
||||
INVALID_PROTOCOL = "invalid-protocol",
|
||||
@ -119,13 +117,11 @@ export class LensProtocolRouter extends Singleton {
|
||||
|
||||
if (!routes) {
|
||||
if (this.missingExtensionHandler) {
|
||||
const enabledPromise = extensionLoader.instanceToBeEnabled(sanitizeExtensionName(name));
|
||||
|
||||
if (!await this.missingExtensionHandler(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
await enabledPromise;
|
||||
routes = this.extentionRoutes.get(name);
|
||||
|
||||
if (!routes) {
|
||||
|
||||
@ -21,7 +21,6 @@ import protocolEndpoints from "./api/protocol-endpoints";
|
||||
import { LensProtocolRouter } from "../main/protocol-handler";
|
||||
import logger from "../main/logger";
|
||||
import { installFromNpm } from "./components/+extensions";
|
||||
|
||||
type AppComponent = React.ComponentType & {
|
||||
init?(): Promise<void>;
|
||||
};
|
||||
@ -47,7 +46,9 @@ export async function bootstrap(App: AppComponent) {
|
||||
if (!extensionLoader.isInstalled(name)) {
|
||||
logger.info(`[PROTOCOL ROUTER]: Extension ${name} not installed, installing..`);
|
||||
|
||||
await installFromNpm(name);
|
||||
await Promise.all([installFromNpm(name), extensionLoader.waitForEnabled(name)]);
|
||||
|
||||
logger.info(`[PROTOCOL ROUTER]: Extension ${name} installed and enabled.`);
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user