Show a message if a background plugin is not starred

Summary:
Since background plugins don't receive data anymore when not starred, we should hint the user about this.

For this diff, I reused the existing statusbar. Although this solution is quite ugly, I think it is better than introducing yet another notification / warning mechanism. Probably we should revisit the layout of this status bar in the future.

Reviewed By: jknoxville

Differential Revision: D19251588

fbshipit-source-id: 1dfd07be383d4ba318f344ebff4b08ed36194c58
This commit is contained in:
Michel Weststrate
2020-01-02 07:12:06 -08:00
committed by Facebook Github Bot
parent 04fcaddded
commit 9acf23596e
5 changed files with 86 additions and 39 deletions

View File

@@ -17,8 +17,7 @@ import {
Message,
} from '../reducers/pluginMessageQueue';
import {Idler, BaseIdler} from './Idler';
import {getPluginKey} from './pluginUtils';
import {deconstructClientId} from './clientUtils';
import {pluginIsStarred, getSelectedPluginKey} from '../reducers/connections';
const MAX_BACKGROUND_TASK_TIME = 25;
@@ -138,14 +137,15 @@ export function processMessageLater(
},
message: {method: string; params?: any},
) {
const isSelected = pluginKey === getSelectedPluginKey(store.getState());
const isSelected =
pluginKey === getSelectedPluginKey(store.getState().connections);
switch (true) {
case isSelected && getPendingMessages(store, pluginKey).length === 0:
processMessageImmediately(store, pluginKey, plugin, message);
break;
case isSelected:
case plugin instanceof FlipperDevicePlugin:
case pluginIsStarred(store.getState(), plugin.id):
case pluginIsStarred(store.getState().connections, plugin.id):
store.dispatch(
queueMessage(
pluginKey,
@@ -158,26 +158,6 @@ export function processMessageLater(
}
}
function getSelectedPluginKey(state: State): string | undefined {
return state.connections.selectedPlugin
? getPluginKey(
state.connections.selectedApp,
state.connections.selectedDevice,
state.connections.selectedPlugin,
)
: undefined;
}
function pluginIsStarred(state: State, pluginId: string): boolean {
const {selectedApp} = state.connections;
if (!selectedApp) {
return false;
}
const appInfo = deconstructClientId(selectedApp);
const starred = state.connections.userStarredPlugins[appInfo.app];
return starred && starred.indexOf(pluginId) > -1;
}
export async function processMessageQueue(
plugin: {
defaultPersistedState: any;