Replace all manual pluginKey parsing with a utility
Summary: Ok this diff got a bit bigger than expected, but I think it makes it easier to understand what "plugin keys" are, and makes them less prone to error. Previously pluginKeys were composed of: clientId#pluginName, where clientId was itself: app#os#device#device_id But also, there were some plugin keys where the clientId was a device_id. Now you deconstruct a plugin key, and will get a tagged object with type: 'device' or 'client', and the properties that they each have. There is now no custom parsing of these afaik, let's keep it that way. Since it took me a while to figure out what all these IDs are, I've documented it a bit in clientUtils. Reviewed By: passy Differential Revision: D18811848 fbshipit-source-id: eed2e2b5eedafb9e27900dbcf79a389fcaffae95
This commit is contained in:
committed by
Facebook Github Bot
parent
2a1e939a0b
commit
0bf905e02f
@@ -21,6 +21,7 @@ import {
|
||||
} from '../reducers/notifications';
|
||||
import {textContent} from '../utils/index';
|
||||
import GK from '../fb-stubs/GK';
|
||||
import {deconstructPluginKey} from '../utils/clientUtils';
|
||||
|
||||
type NotificationEvents = 'show' | 'click' | 'close' | 'reply' | 'action';
|
||||
const NOTIFICATION_THROTTLE = 5 * 1000; // in milliseconds
|
||||
@@ -106,18 +107,18 @@ export default (store: Store, logger: Logger) => {
|
||||
Object.keys(pluginStates).forEach(key => {
|
||||
if (knownPluginStates.get(key) !== pluginStates[key]) {
|
||||
knownPluginStates.set(key, pluginStates[key]);
|
||||
const split = key.split('#');
|
||||
const pluginId = split.pop();
|
||||
const client = split.join('#');
|
||||
const plugin = deconstructPluginKey(key);
|
||||
const pluginName = plugin.pluginName;
|
||||
const client = plugin.client;
|
||||
|
||||
if (!pluginId) {
|
||||
if (!pluginName) {
|
||||
return;
|
||||
}
|
||||
|
||||
const persistingPlugin:
|
||||
| undefined
|
||||
| typeof FlipperPlugin
|
||||
| typeof FlipperDevicePlugin = pluginMap.get(pluginId);
|
||||
| typeof FlipperDevicePlugin = pluginMap.get(pluginName);
|
||||
if (persistingPlugin && persistingPlugin.getActiveNotifications) {
|
||||
store.dispatch(
|
||||
setActiveNotifications({
|
||||
@@ -125,7 +126,7 @@ export default (store: Store, logger: Logger) => {
|
||||
pluginStates[key],
|
||||
),
|
||||
client,
|
||||
pluginId,
|
||||
pluginId: pluginName,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user