Fix NotificationsHub types

Reviewed By: passy

Differential Revision: D17167014

fbshipit-source-id: f7981c75252059c6eaa3518ca0fd9524f5039db6
This commit is contained in:
John Knox
2019-09-04 03:30:16 -07:00
committed by Facebook Github Bot
parent 16457e2adb
commit a04e9aa986

View File

@@ -31,10 +31,11 @@ import {
updateCategoryBlacklist, updateCategoryBlacklist,
} from './reducers/notifications'; } from './reducers/notifications';
import {selectPlugin} from './reducers/connections'; import {selectPlugin} from './reducers/connections';
import {State as Store} from './reducers/index'; import {State as StoreState} from './reducers/index';
import textContent from './utils/textContent'; import textContent from './utils/textContent';
import createPaste from './fb-stubs/createPaste'; import createPaste from './fb-stubs/createPaste';
import {KeyboardActions} from './MenuBar'; import {KeyboardActions} from './MenuBar';
import {Store} from 'redux';
export default class Notifications< export default class Notifications<
S, S,
@@ -61,14 +62,12 @@ export default class Notifications<
}; };
onClear = () => { onClear = () => {
this.context.store.dispatch(clearAllNotifications()); (this.context.store as Store<StoreState>).dispatch(clearAllNotifications());
}; };
render() { render() {
const { const {blacklistedPlugins, blacklistedCategories} = (this.context
blacklistedPlugins, .store as Store<StoreState>).getState().notifications;
blacklistedCategories,
} = this.context.store.getState().notifications;
return ( return (
<ConnectedNotificationsTable <ConnectedNotificationsTable
onClear={this.onClear} onClear={this.onClear}
@@ -114,9 +113,9 @@ type StateFromProps = {
type DispatchFromProps = { type DispatchFromProps = {
selectPlugin: (payload: { selectPlugin: (payload: {
selectedPlugin: string | null | undefined; selectedPlugin: string | null;
selectedApp: string | null | undefined; selectedApp: string | null;
deepLinkPayload: string | null | undefined; deepLinkPayload: string | null;
}) => any; }) => any;
updatePluginBlacklist: (blacklist: Array<string>) => any; updatePluginBlacklist: (blacklist: Array<string>) => any;
updateCategoryBlacklist: (blacklist: Array<string>) => any; updateCategoryBlacklist: (blacklist: Array<string>) => any;
@@ -159,13 +158,13 @@ const NoContent = styled(FlexColumn)({
color: colors.light30, color: colors.light30,
}); });
class NotificationsTable extends Component<Props, State> { class NotificationsTable extends Component<Props & SearchableProps, State> {
contextMenuItems = [{label: 'Clear all', click: this.props.onClear}]; contextMenuItems = [{label: 'Clear all', click: this.props.onClear}];
state: State = { state: State = {
selectedNotification: this.props.selectedID, selectedNotification: this.props.selectedID,
}; };
componentDidUpdate(prevProps: Props) { componentDidUpdate(prevProps: Props & SearchableProps) {
if (this.props.filters.length !== prevProps.filters.length) { if (this.props.filters.length !== prevProps.filters.length) {
this.props.updatePluginBlacklist( this.props.updatePluginBlacklist(
this.props.filters this.props.filters
@@ -330,7 +329,7 @@ const ConnectedNotificationsTable = connect<
StateFromProps, StateFromProps,
DispatchFromProps, DispatchFromProps,
OwnProps, OwnProps,
Store StoreState
>( >(
({ ({
notifications: { notifications: {
@@ -470,9 +469,9 @@ type ItemProps = {
isSelected?: boolean; isSelected?: boolean;
inactive?: boolean; inactive?: boolean;
selectPlugin?: (payload: { selectPlugin?: (payload: {
selectedPlugin: string | null | undefined; selectedPlugin: string | null;
selectedApp: string | null | undefined; selectedApp: string | null;
deepLinkPayload: string | null | undefined; deepLinkPayload: string | null;
}) => any; }) => any;
logger?: Logger; logger?: Logger;
plugin: typeof FlipperBasePlugin | null | undefined; plugin: typeof FlipperBasePlugin | null | undefined;
@@ -510,7 +509,7 @@ class NotificationItem extends Component<
} }
state = {reportedNotHelpful: false}; state = {reportedNotHelpful: false};
contextMenuItems; contextMenuItems: Array<{label: string; click: (() => any) | undefined}>;
deepLinkButton = React.createRef(); deepLinkButton = React.createRef();
createPaste = () => { createPaste = () => {