Preserve Navigation plugin as background plugin eevn when disabled
Summary: This diff fixes an issue where we don't want to have the Navigation plugin be disabled as background plugins like all other plugins, so that the breadcrumb navigation keeps working. Yet another hack concerning the super useful Navigation plugin. On a positive note, since connection management for background is not entirely managed by the Desktop and not the native said, these kind of exceptions are fairly easy to make :) Reviewed By: passy Differential Revision: D21089537 fbshipit-source-id: 209954ff35c95e066fe688a60ad46ccfc3835c44
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b9c3d99f44
commit
dba480ce74
@@ -24,7 +24,10 @@ import createTableNativePlugin from './plugins/TableNativePlugin';
|
|||||||
import {EventEmitter} from 'events';
|
import {EventEmitter} from 'events';
|
||||||
import invariant from 'invariant';
|
import invariant from 'invariant';
|
||||||
import {flipperRecorderAddEvent} from './utils/pluginStateRecorder';
|
import {flipperRecorderAddEvent} from './utils/pluginStateRecorder';
|
||||||
import {getPluginKey} from './utils/pluginUtils';
|
import {
|
||||||
|
getPluginKey,
|
||||||
|
defaultEnabledBackgroundPlugins,
|
||||||
|
} from './utils/pluginUtils';
|
||||||
import {processMessageLater} from './utils/messageQueue';
|
import {processMessageLater} from './utils/messageQueue';
|
||||||
import {sideEffect} from './utils/sideEffect';
|
import {sideEffect} from './utils/sideEffect';
|
||||||
import {emitBytesReceived} from './dispatcher/tracking';
|
import {emitBytesReceived} from './dispatcher/tracking';
|
||||||
@@ -241,16 +244,21 @@ export default class Client extends EventEmitter {
|
|||||||
return this.backgroundPlugins.includes(pluginId);
|
return this.backgroundPlugins.includes(pluginId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shouldConnectAsBackgroundPlugin(pluginId: string) {
|
||||||
|
return (
|
||||||
|
defaultEnabledBackgroundPlugins.includes(pluginId) ||
|
||||||
|
this.store
|
||||||
|
.getState()
|
||||||
|
.connections.userStarredPlugins[this.query.app]?.includes(pluginId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
this.setMatchingDevice();
|
this.setMatchingDevice();
|
||||||
await this.loadPlugins();
|
await this.loadPlugins();
|
||||||
this.backgroundPlugins = await this.getBackgroundPlugins();
|
this.backgroundPlugins = await this.getBackgroundPlugins();
|
||||||
this.backgroundPlugins.forEach((plugin) => {
|
this.backgroundPlugins.forEach((plugin) => {
|
||||||
if (
|
if (this.shouldConnectAsBackgroundPlugin(plugin)) {
|
||||||
this.store
|
|
||||||
.getState()
|
|
||||||
.connections.userStarredPlugins[this.query.app]?.includes(plugin)
|
|
||||||
) {
|
|
||||||
this.initPlugin(plugin);
|
this.initPlugin(plugin);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -312,9 +320,7 @@ export default class Client extends EventEmitter {
|
|||||||
newBackgroundPlugins.forEach((plugin) => {
|
newBackgroundPlugins.forEach((plugin) => {
|
||||||
if (
|
if (
|
||||||
!oldBackgroundPlugins.includes(plugin) &&
|
!oldBackgroundPlugins.includes(plugin) &&
|
||||||
this.store
|
this.shouldConnectAsBackgroundPlugin(plugin)
|
||||||
.getState()
|
|
||||||
.connections.userStarredPlugins[this.query.app]?.includes(plugin)
|
|
||||||
) {
|
) {
|
||||||
this.initPlugin(plugin);
|
this.initPlugin(plugin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ const WelcomeScreen = isHeadless()
|
|||||||
import NotificationScreen from '../chrome/NotificationScreen';
|
import NotificationScreen from '../chrome/NotificationScreen';
|
||||||
import SupportRequestFormV2 from '../fb-stubs/SupportRequestFormV2';
|
import SupportRequestFormV2 from '../fb-stubs/SupportRequestFormV2';
|
||||||
import SupportRequestDetails from '../fb-stubs/SupportRequestDetails';
|
import SupportRequestDetails from '../fb-stubs/SupportRequestDetails';
|
||||||
import {getPluginKey} from '../utils/pluginUtils';
|
import {
|
||||||
|
getPluginKey,
|
||||||
|
defaultEnabledBackgroundPlugins,
|
||||||
|
} from '../utils/pluginUtils';
|
||||||
import {deconstructClientId} from '../utils/clientUtils';
|
import {deconstructClientId} from '../utils/clientUtils';
|
||||||
import {FlipperDevicePlugin} from '../plugin';
|
import {FlipperDevicePlugin} from '../plugin';
|
||||||
import {RegisterPluginAction} from './plugins';
|
import {RegisterPluginAction} from './plugins';
|
||||||
@@ -288,12 +291,18 @@ const reducer = (state: State = INITAL_STATE, action: Actions): State => {
|
|||||||
const idx = plugins.indexOf(selectedPlugin);
|
const idx = plugins.indexOf(selectedPlugin);
|
||||||
if (idx === -1) {
|
if (idx === -1) {
|
||||||
plugins.push(selectedPlugin);
|
plugins.push(selectedPlugin);
|
||||||
if (client?.isBackgroundPlugin(selectedPlugin)) {
|
if (
|
||||||
|
!defaultEnabledBackgroundPlugins.includes(selectedPlugin) &&
|
||||||
|
client?.isBackgroundPlugin(selectedPlugin)
|
||||||
|
) {
|
||||||
client.initPlugin(selectedPlugin);
|
client.initPlugin(selectedPlugin);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
plugins.splice(idx, 1);
|
plugins.splice(idx, 1);
|
||||||
if (client?.isBackgroundPlugin(selectedPlugin)) {
|
if (
|
||||||
|
!defaultEnabledBackgroundPlugins.includes(selectedPlugin) &&
|
||||||
|
client?.isBackgroundPlugin(selectedPlugin)
|
||||||
|
) {
|
||||||
client.deinitPlugin(selectedPlugin);
|
client.deinitPlugin(selectedPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import {Idler, BaseIdler} from './Idler';
|
|||||||
import {pluginIsStarred, getSelectedPluginKey} from '../reducers/connections';
|
import {pluginIsStarred, getSelectedPluginKey} from '../reducers/connections';
|
||||||
import {deconstructPluginKey} from './clientUtils';
|
import {deconstructPluginKey} from './clientUtils';
|
||||||
import {onBytesReceived} from '../dispatcher/tracking';
|
import {onBytesReceived} from '../dispatcher/tracking';
|
||||||
|
import {defaultEnabledBackgroundPlugins} from './pluginUtils';
|
||||||
|
|
||||||
const MAX_BACKGROUND_TASK_TIME = 25;
|
const MAX_BACKGROUND_TASK_TIME = 25;
|
||||||
|
|
||||||
@@ -223,8 +224,9 @@ export function processMessageLater(
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// In all other cases, messages will be dropped...
|
// In all other cases, messages will be dropped...
|
||||||
console.warn(
|
if (!defaultEnabledBackgroundPlugins.includes(plugin.id))
|
||||||
`Received message for disabled plugin ${plugin.id}: ${message.method}, dropping..`,
|
console.error(
|
||||||
|
`Received message for disabled plugin ${plugin.id}, dropping..`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {FlipperDevicePlugin, FlipperPlugin, FlipperBasePlugin} from '../plugin';
|
import {FlipperDevicePlugin, FlipperPlugin, FlipperBasePlugin} from '../plugin';
|
||||||
import BaseDevice from '../devices/BaseDevice';
|
|
||||||
import {State as PluginStatesState} from '../reducers/pluginStates';
|
import {State as PluginStatesState} from '../reducers/pluginStates';
|
||||||
import {State as PluginsState} from '../reducers/plugins';
|
import {State as PluginsState} from '../reducers/plugins';
|
||||||
import {State as PluginMessageQueueState} from '../reducers/pluginMessageQueue';
|
import {State as PluginMessageQueueState} from '../reducers/pluginMessageQueue';
|
||||||
@@ -17,6 +16,8 @@ import {deconstructPluginKey, deconstructClientId} from './clientUtils';
|
|||||||
|
|
||||||
type Client = import('../Client').default;
|
type Client = import('../Client').default;
|
||||||
|
|
||||||
|
export const defaultEnabledBackgroundPlugins = ['Navigation']; // The navigation plugin is enabled always, to make sure the navigation features works
|
||||||
|
|
||||||
export function pluginsClassMap(
|
export function pluginsClassMap(
|
||||||
plugins: PluginsState,
|
plugins: PluginsState,
|
||||||
): Map<string, typeof FlipperDevicePlugin | typeof FlipperPlugin> {
|
): Map<string, typeof FlipperDevicePlugin | typeof FlipperPlugin> {
|
||||||
|
|||||||
Reference in New Issue
Block a user