Persist uninstalled plugins list

Summary: This diff changes uninstallation procedure for plugins. Instead of deleting plugin files immediately we are keeping them, but mark them as "uninstalled". This makes it possible to re-install plugins quickly in case when user clicked "delete" by mistake.

Reviewed By: mweststrate

Differential Revision: D25493479

fbshipit-source-id: 9ff29d717cdd5401c55388f24d479599579c8dd3
This commit is contained in:
Anton Nikolaev
2020-12-15 09:28:58 -08:00
committed by Facebook GitHub Bot
parent df03ccbeab
commit c3d61cc32d
9 changed files with 81 additions and 93 deletions

View File

@@ -67,11 +67,12 @@ import {launcherConfigDir} from '../utils/launcher';
import os from 'os';
import {resolve} from 'path';
import xdg from 'xdg-basedir';
import {persistReducer} from 'redux-persist';
import {createTransform, persistReducer} from 'redux-persist';
import {PersistPartial} from 'redux-persist/es/persistReducer';
import {Store as ReduxStore, MiddlewareAPI as ReduxMiddlewareAPI} from 'redux';
import storage from 'redux-persist/lib/storage';
import {TransformConfig} from 'redux-persist/es/createTransform';
export type Actions =
| ApplicationAction
@@ -101,7 +102,7 @@ export type State = {
settingsState: SettingsState & PersistPartial;
launcherSettingsState: LauncherSettingsState & PersistPartial;
supportForm: SupportFormState;
pluginManager: PluginManagerState;
pluginManager: PluginManagerState & PersistPartial;
healthchecks: HealthcheckState & PersistPartial;
usageTracking: TrackingState;
pluginDownloads: PluginDownloadsState;
@@ -118,6 +119,13 @@ const settingsStorage = new JsonFileStorage(
),
);
const setTransformer = (config: TransformConfig) =>
createTransform(
(set: Set<string>) => Array.from(set),
(arrayString: string[]) => new Set(arrayString),
config,
);
const launcherSettingsStorage = new LauncherSettingsStorage(
resolve(launcherConfigDir(), 'flipper-launcher.toml'),
);
@@ -156,7 +164,15 @@ export default combineReducers<State, Actions>({
plugins,
),
supportForm,
pluginManager,
pluginManager: persistReducer<PluginManagerState, Actions>(
{
key: 'pluginManager',
storage,
whitelist: ['uninstalledPlugins'],
transforms: [setTransformer({whitelist: ['uninstalledPlugins']})],
},
pluginManager,
),
user: persistReducer(
{
key: 'user',