Fix refresh plugins not having any effect
Summary: If a plugin was registered beyond the initial start command, this didn't show up in the Flipper UI. The reason for this is that the client map is updated, but since that object is mutable, components won't detect nor reflect the change. This diff changes to make sure a new plugin map is created if it is changed. Reviewed By: passy Differential Revision: D19345464 fbshipit-source-id: 3aa343e1739caf124a015c88680a94973b87f701
This commit is contained in:
committed by
Facebook Github Bot
parent
2599dffe48
commit
40f9b385bb
@@ -143,7 +143,7 @@
|
|||||||
"fb-watchman": "^2.0.0",
|
"fb-watchman": "^2.0.0",
|
||||||
"flipper-doctor": "^0.6.0",
|
"flipper-doctor": "^0.6.0",
|
||||||
"fs-extra": "^8.0.1",
|
"fs-extra": "^8.0.1",
|
||||||
"immer": "^5.0.1",
|
"immer": "^5.2.1",
|
||||||
"immutable": "^4.0.0-rc.12",
|
"immutable": "^4.0.0-rc.12",
|
||||||
"invariant": "^2.2.2",
|
"invariant": "^2.2.2",
|
||||||
"line-replace": "^1.0.2",
|
"line-replace": "^1.0.2",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import {FlipperPlugin, FlipperDevicePlugin} from '../plugin';
|
import {FlipperPlugin, FlipperDevicePlugin} from '../plugin';
|
||||||
import {PluginDefinition} from '../dispatcher/plugins';
|
import {PluginDefinition} from '../dispatcher/plugins';
|
||||||
import {Actions} from '.';
|
import {Actions} from '.';
|
||||||
|
import produce from 'immer';
|
||||||
|
|
||||||
export type State = {
|
export type State = {
|
||||||
devicePlugins: Map<string, typeof FlipperDevicePlugin>;
|
devicePlugins: Map<string, typeof FlipperDevicePlugin>;
|
||||||
@@ -58,8 +59,8 @@ export default function reducer(
|
|||||||
action: Actions,
|
action: Actions,
|
||||||
): State {
|
): State {
|
||||||
if (action.type === 'REGISTER_PLUGINS') {
|
if (action.type === 'REGISTER_PLUGINS') {
|
||||||
const {devicePlugins, clientPlugins} = state;
|
return produce(state, draft => {
|
||||||
|
const {devicePlugins, clientPlugins} = draft;
|
||||||
action.payload.forEach((p: P) => {
|
action.payload.forEach((p: P) => {
|
||||||
if (devicePlugins.has(p.id) || clientPlugins.has(p.id)) {
|
if (devicePlugins.has(p.id) || clientPlugins.has(p.id)) {
|
||||||
return;
|
return;
|
||||||
@@ -73,11 +74,7 @@ export default function reducer(
|
|||||||
clientPlugins.set(p.id, p);
|
clientPlugins.set(p.id, p);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return {
|
});
|
||||||
...state,
|
|
||||||
devicePlugins,
|
|
||||||
clientPlugins,
|
|
||||||
};
|
|
||||||
} else if (action.type === 'GATEKEEPED_PLUGINS') {
|
} else if (action.type === 'GATEKEEPED_PLUGINS') {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|||||||
@@ -4779,10 +4779,10 @@ ignore@^5.1.1:
|
|||||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf"
|
resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.4.tgz#84b7b3dbe64552b6ef0eca99f6743dbec6d97adf"
|
||||||
integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==
|
integrity sha512-MzbUSahkTW1u7JpKKjY7LCARd1fU5W2rLdxlM4kdkayuCwZImjkpluF9CM1aLewYJguPDqewLam18Y6AU69A8A==
|
||||||
|
|
||||||
immer@^5.0.1:
|
immer@^5.2.1:
|
||||||
version "5.0.1"
|
version "5.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/immer/-/immer-5.0.1.tgz#1a1184fa758f68f1b5573db840825fb5164cceca"
|
resolved "https://registry.yarnpkg.com/immer/-/immer-5.2.1.tgz#7d4f74c242178e87151d595f48db1b5c51580485"
|
||||||
integrity sha512-KFHV1ivrBmPCVRhjy9oBooypnPfJ876NTrWXMNoUhXFAaWWAViVqZ4l6HxPST52qcN82qqsR38/pCGYRWP5W7w==
|
integrity sha512-9U1GEbJuH6nVoyuFRgTQDGMzcBuNBPfXM3M7Pp/sdmYKTKYOBUZGgeUb9H57GfLK/xC1DMLarWX2FrhMBfUJ8g==
|
||||||
|
|
||||||
immutable@^4.0.0-rc.12:
|
immutable@^4.0.0-rc.12:
|
||||||
version "4.0.0-rc.12"
|
version "4.0.0-rc.12"
|
||||||
|
|||||||
Reference in New Issue
Block a user