Reload single plugin on auto-update

Summary: Implemented a way for re-loading single plugin on auto-update. This make it possible to apply update without full Flipper restart.

Reviewed By: mweststrate

Differential Revision: D23729972

fbshipit-source-id: ed30f7cde5a0537945db0b5bb6969ae8fde42cb6
This commit is contained in:
Anton Nikolaev
2020-09-28 02:50:10 -07:00
committed by Facebook GitHub Bot
parent 5e979403a0
commit 0982dc06a0
9 changed files with 204 additions and 47 deletions

View File

@@ -16,6 +16,12 @@ export type PluginNotification = {
client: null | string;
};
export type PluginNotificationReference = {
notificationId: string;
pluginId: string;
client: null | string;
};
export type State = {
activeNotifications: Array<PluginNotification>;
invalidatedNotifications: Array<PluginNotification>;
@@ -56,6 +62,10 @@ export type Action =
| {
type: 'ADD_NOTIFICATION';
payload: PluginNotification;
}
| {
type: 'REMOVE_NOTIFICATION';
payload: PluginNotificationReference;
};
const INITIAL_STATE: State = {
@@ -113,6 +123,18 @@ export default function reducer(
action.payload,
],
};
case 'REMOVE_NOTIFICATION':
return {
...state,
activeNotifications: [
...state.activeNotifications.filter(
(notif) =>
notif.client !== action.payload.client ||
notif.pluginId !== action.payload.pluginId ||
notif.notification.id !== action.payload.notificationId,
),
],
};
default:
return state;
}
@@ -166,6 +188,15 @@ export function addNotification(payload: PluginNotification): Action {
};
}
export function removeNotification(
payload: PluginNotificationReference,
): Action {
return {
type: 'REMOVE_NOTIFICATION',
payload,
};
}
export function addErrorNotification(
title: string,
message: string,