Introduce isPluginAvailable and selectPlugin
Summary: Introduced API to replace the deprecated `selectPlugin` in Sandy. The API can be used to navigate from `device plugin -> device plugin`, or` client plugin -> device / client plugin` Introduced `isPluginAvailable` as well, so that the user interaction an be fine tuned in case the plugin is not disabled. Reviewed By: jknoxville Differential Revision: D25422370 fbshipit-source-id: c6c603f1c68e6291280b3d0883e474448754ded1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
02a56da3f5
commit
52862f6083
@@ -83,6 +83,16 @@ export interface PluginClient<
|
||||
* Checks if a method is available on the client implementation
|
||||
*/
|
||||
supportsMethod(method: keyof Methods): Promise<boolean>;
|
||||
|
||||
/**
|
||||
* Checks if the provided plugin is available for the current device / application
|
||||
*/
|
||||
isPluginAvailable(pluginId: string): boolean;
|
||||
|
||||
/**
|
||||
* opens a different plugin by id, optionally providing a deeplink to bring the plugin to a certain state
|
||||
*/
|
||||
selectPlugin(pluginId: string, deeplinkPayload?: unknown): void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,6 +108,7 @@ export interface RealFlipperClient {
|
||||
device_id: string;
|
||||
};
|
||||
deviceSync: RealFlipperDevice;
|
||||
plugins: string[];
|
||||
isBackgroundPlugin(pluginId: string): boolean;
|
||||
initPlugin(pluginId: string): void;
|
||||
deinitPlugin(pluginId: string): void;
|
||||
@@ -174,6 +185,23 @@ export class SandyPluginInstance extends BasePluginInstance {
|
||||
method as any,
|
||||
);
|
||||
},
|
||||
isPluginAvailable(pluginId: string) {
|
||||
return flipperLib.isPluginAvailable(
|
||||
realClient.deviceSync,
|
||||
realClient,
|
||||
pluginId,
|
||||
);
|
||||
},
|
||||
selectPlugin(pluginId: string, deeplink?: unknown) {
|
||||
if (this.isPluginAvailable(pluginId)) {
|
||||
flipperLib.selectPlugin(
|
||||
realClient.deviceSync,
|
||||
realClient,
|
||||
pluginId,
|
||||
deeplink,
|
||||
);
|
||||
}
|
||||
},
|
||||
};
|
||||
this.initializePlugin(() =>
|
||||
definition.asPluginModule().plugin(this.client),
|
||||
|
||||
Reference in New Issue
Block a user