Fix bug with plugin re-installation after uninstallation

Summary:
Fixed a bug when plugin installation status wouldn't be saved between sessions when plugin uninstalled and then re-installed again. Before the fix, after Flipper restart, such plugin was uninstalled again because its package name was not removed from "uninstalledPlugins" state. This was because plugin id was used by mistake instead of name in few places.

To try avoiding this issue in future I've also renamed "uninstalledPlugins" to "uninstalledPluginNames" to make it more clear than package name should be used there rather than ID. As this field is persisted, I also added migration which moves data to the renamed field.

Reviewed By: passy

Differential Revision: D28314447

fbshipit-source-id: fbe3edc258b78fe7fbb0d966f93aabcdf3b66d4b
This commit is contained in:
Anton Nikolaev
2021-05-11 17:02:24 -07:00
committed by Facebook GitHub Bot
parent 22974130c8
commit 00851c6b5d
8 changed files with 48 additions and 23 deletions

View File

@@ -85,14 +85,15 @@ export default async (store: Store, logger: Logger) => {
),
);
const uninstalledPlugins = store.getState().plugins.uninstalledPlugins;
const uninstalledPluginNames =
store.getState().plugins.uninstalledPluginNames;
const bundledPlugins = getBundledPlugins();
const loadedPlugins = filterNewestVersionOfEachPlugin(
bundledPlugins,
await getDynamicPlugins(),
).filter((p) => !uninstalledPlugins.has(p.name));
).filter((p) => !uninstalledPluginNames.has(p.name));
const initialPlugins: PluginDefinition[] = loadedPlugins
.map(reportVersion)