Update plugin store after installation

Summary: Address the small regression introduced by D18173166. When closing the plugin manager after installing/removing, the store wasn't updated in between.

Reviewed By: jknoxville

Differential Revision: D18270821

fbshipit-source-id: 4ff54bc7607d06fa423cf8e673f216ae0a5d19da
This commit is contained in:
Pascal Hartig
2019-11-05 05:27:38 -08:00
committed by Facebook Github Bot
parent 432bb1b00a
commit d2dfb924fd
2 changed files with 35 additions and 11 deletions

View File

@@ -20,7 +20,7 @@ import {
export const PLUGIN_DIR = path.join(homedir(), '.flipper', 'thirdparty');
async function getInstalledPlugins(): Promise<PluginMap> {
export async function readInstalledPlugins(): Promise<PluginMap> {
const pluginDirExists = await fs.pathExists(PLUGIN_DIR);
if (!pluginDirExists) {
@@ -50,8 +50,15 @@ async function getInstalledPlugins(): Promise<PluginMap> {
return new Map(plugins.filter(Boolean));
}
export default (store: Store, _logger: Logger) => {
getInstalledPlugins().then(plugins =>
function refreshInstalledPlugins(store: Store) {
readInstalledPlugins().then(plugins =>
store.dispatch(registerInstalledPlugins(plugins)),
);
}
export default (store: Store, _logger: Logger) => {
// This needn't happen immediately and is (light) I/O work.
window.requestIdleCallback(() => {
refreshInstalledPlugins(store);
});
};