Reload plugins with updated sources
Reviewed By: lblasa Differential Revision: D39540173 fbshipit-source-id: 65f5d0f0a325d6ca3ed5e1213e689490c6b650b2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d3d2e189d0
commit
6b3298a29e
@@ -19,6 +19,7 @@ import pluginMarketplace from './pluginMarketplace';
|
|||||||
import pluginDownloads from './pluginDownloads';
|
import pluginDownloads from './pluginDownloads';
|
||||||
import info from '../utils/info';
|
import info from '../utils/info';
|
||||||
import pluginChangeListener from './pluginsChangeListener';
|
import pluginChangeListener from './pluginsChangeListener';
|
||||||
|
import pluginsSourceUpdateListener from './pluginsSourceUpdateListener';
|
||||||
|
|
||||||
import {Logger} from 'flipper-common';
|
import {Logger} from 'flipper-common';
|
||||||
import {Store} from '../reducers/index';
|
import {Store} from '../reducers/index';
|
||||||
@@ -40,6 +41,7 @@ export default function (store: Store, logger: Logger): () => Promise<void> {
|
|||||||
pluginDownloads,
|
pluginDownloads,
|
||||||
info,
|
info,
|
||||||
pluginChangeListener,
|
pluginChangeListener,
|
||||||
|
pluginsSourceUpdateListener,
|
||||||
].filter(notNull);
|
].filter(notNull);
|
||||||
const globalCleanup = dispatchers
|
const globalCleanup = dispatchers
|
||||||
.map((dispatcher) => dispatcher(store, logger))
|
.map((dispatcher) => dispatcher(store, logger))
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
import {InstalledPluginDetails, Logger} from 'flipper-common';
|
||||||
|
import {Store} from '../reducers';
|
||||||
|
import {loadPlugin} from '../reducers/pluginManager';
|
||||||
|
import {sideEffect} from '../utils/sideEffect';
|
||||||
|
|
||||||
|
export default (store: Store, _logger: Logger) => {
|
||||||
|
sideEffect(
|
||||||
|
store,
|
||||||
|
{
|
||||||
|
name: 'pluginsSourceUpdateListener',
|
||||||
|
throttleMs: 10,
|
||||||
|
fireImmediately: true,
|
||||||
|
},
|
||||||
|
() => undefined,
|
||||||
|
(_state, _store) => {
|
||||||
|
window.addEventListener('message', (event) => {
|
||||||
|
if (
|
||||||
|
typeof event.data === 'object' &&
|
||||||
|
event.data.type === 'plugins-source-updated' &&
|
||||||
|
Array.isArray(event.data.data)
|
||||||
|
) {
|
||||||
|
const changedPlugins = event.data.data as InstalledPluginDetails[];
|
||||||
|
for (const plugin of changedPlugins) {
|
||||||
|
store.dispatch(
|
||||||
|
loadPlugin({
|
||||||
|
plugin,
|
||||||
|
enable: false,
|
||||||
|
notifyIfFailed: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user