Fix the broken notification click

Summary:
This diff fixes the broken deeplink to the notifications hub when one clicks on the macos native notification. See the bug reported [here](https://fb.workplace.com/groups/220760072184928/permalink/532998544294411/)

This [post](https://fb.workplace.com/groups/220760072184928/permalink/532998544294411/) reports the bug.

Reviewed By: passy

Differential Revision: D20089749

fbshipit-source-id: 8061ae07c450fd674795af4c5be53ce77402c063
This commit is contained in:
Pritesh Nandgaonkar
2020-02-25 08:08:12 -08:00
committed by Facebook Github Bot
parent 2ee9778a8e
commit abb2dc72ee
3 changed files with 18 additions and 5 deletions

View File

@@ -12,7 +12,7 @@ import {Logger} from '../fb-interfaces/Logger';
import {PluginNotification} from '../reducers/notifications';
import {FlipperPlugin, FlipperDevicePlugin} from '../plugin';
import isHeadless from '../utils/isHeadless';
import {setStaticView} from '../reducers/connections';
import {setStaticView, setDeeplinkPayload} from '../reducers/connections';
import {ipcRenderer, IpcRendererEvent} from 'electron';
import {
setActiveNotifications,
@@ -41,12 +41,14 @@ export default (store: Store, logger: Logger) => {
'notificationEvent',
(
_event: IpcRendererEvent,
_e: Error,
eventName: NotificationEvents,
pluginNotification: PluginNotification,
arg: null | string | number,
) => {
if (eventName === 'click' || (eventName === 'action' && arg === 0)) {
store.dispatch(
setDeeplinkPayload(pluginNotification.notification.action ?? null),
);
store.dispatch(setStaticView(NotificationScreen));
} else if (eventName === 'action') {
if (arg === 1 && pluginNotification.notification.category) {

View File

@@ -61,7 +61,7 @@ export type State = {
deviceId?: string;
errorMessage?: string;
}>;
deepLinkPayload: null | string;
deepLinkPayload: string | null;
staticView: StaticView;
};
@@ -143,6 +143,10 @@ export type Action =
type: 'SELECT_CLIENT';
payload: string;
}
| {
type: 'SET_DEEPLINK_PAYLOAD';
payload: null | string;
}
| RegisterPluginAction;
const DEFAULT_PLUGIN = 'DeviceLogs';
@@ -382,7 +386,9 @@ const reducer = (state: State = INITAL_STATE, action: Actions): State => {
errors,
};
}
case 'SET_DEEPLINK_PAYLOAD': {
return {...state, deepLinkPayload: action.payload};
}
case 'REGISTER_PLUGINS': {
// plugins are registered after creating the base devices, so update them
const plugins = action.payload;
@@ -499,6 +505,11 @@ export const selectClient = (clientId: string): Action => ({
payload: clientId,
});
export const setDeeplinkPayload = (payload: string | null): Action => ({
type: 'SET_DEEPLINK_PAYLOAD',
payload,
});
export function getAvailableClients(
device: null | undefined | BaseDevice,
clients: Client[],

View File

@@ -260,7 +260,7 @@ const Searchable = (
prevProps.defaultSearchTerm !== this.props.defaultSearchTerm ||
prevProps.defaultFilters !== this.props.defaultFilters
) {
newSearchTerm = this.props.defaultSearchTerm;
newSearchTerm = this.props.defaultSearchTerm ?? '';
}
this.setState({
filters: mergedFilters,