Wait for client to initliaze on startup deep link
Summary: We were incorrectly assuming a client did not support a plugin because it was not fully initialized. This issue was only apparant on start deep links Reviewed By: mweststrate Differential Revision: D40477503 fbshipit-source-id: 5fd9db765f559b8eb80cc3680ee694dfd2cf9a37
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2bde26391d
commit
c6dbfc87a4
@@ -50,6 +50,7 @@ export type RequestMetadata = {
|
|||||||
|
|
||||||
export interface ClientConnection {
|
export interface ClientConnection {
|
||||||
send(data: any): void;
|
send(data: any): void;
|
||||||
|
|
||||||
sendExpectResponse(data: any): Promise<ClientResponseType>;
|
sendExpectResponse(data: any): Promise<ClientResponseType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +64,6 @@ export default abstract class AbstractClient extends EventEmitter {
|
|||||||
backgroundPlugins: Plugins;
|
backgroundPlugins: Plugins;
|
||||||
connection: ClientConnection | null | undefined;
|
connection: ClientConnection | null | undefined;
|
||||||
activePlugins: Set<string>;
|
activePlugins: Set<string>;
|
||||||
|
|
||||||
device: BaseDevice;
|
device: BaseDevice;
|
||||||
logger: Logger;
|
logger: Logger;
|
||||||
|
|
||||||
@@ -71,6 +71,11 @@ export default abstract class AbstractClient extends EventEmitter {
|
|||||||
private readonly serverAddOnControls: ServerAddOnControls;
|
private readonly serverAddOnControls: ServerAddOnControls;
|
||||||
private readonly flipperServer: FlipperServer;
|
private readonly flipperServer: FlipperServer;
|
||||||
|
|
||||||
|
private resolveInitPromise!: (_: unknown) => void;
|
||||||
|
readonly initializationPromise = new Promise((_resolve) => {
|
||||||
|
this.resolveInitPromise = _resolve;
|
||||||
|
});
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
id: string,
|
id: string,
|
||||||
query: ClientQuery,
|
query: ClientQuery,
|
||||||
@@ -116,6 +121,7 @@ export default abstract class AbstractClient extends EventEmitter {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.emit('plugins-change');
|
this.emit('plugins-change');
|
||||||
|
this.resolveInitPromise?.(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the supported plugins
|
// get the supported plugins
|
||||||
|
|||||||
@@ -143,6 +143,11 @@ export async function handleOpenPluginDeeplink(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.debug('[deeplink] Cleared device plugin support check.');
|
console.debug('[deeplink] Cleared device plugin support check.');
|
||||||
|
|
||||||
|
await client?.initializationPromise;
|
||||||
|
|
||||||
|
console.debug('[deeplink] Client initialized');
|
||||||
|
|
||||||
if (!isDevicePlugin && !client!.plugins.has(params.pluginId)) {
|
if (!isDevicePlugin && !client!.plugins.has(params.pluginId)) {
|
||||||
await Dialog.alert({
|
await Dialog.alert({
|
||||||
title,
|
title,
|
||||||
|
|||||||
Reference in New Issue
Block a user