From c8a7ce5cfbc57ceb5af880adaed5e411e63a4d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Mon, 22 Oct 2018 06:58:02 -0700 Subject: [PATCH] link to hub Summary: Clicking on a notifications links to the Notification Hub highlighting the selected notification. Reviewed By: jknoxville Differential Revision: D10487822 fbshipit-source-id: ed907ec244bef970d1b30ddb719856949229d0c4 --- src/NotificationsHub.js | 20 +++++++++++++++----- src/dispatcher/notifications.js | 6 +++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/NotificationsHub.js b/src/NotificationsHub.js index 77135fef3..eafc75572 100644 --- a/src/NotificationsHub.js +++ b/src/NotificationsHub.js @@ -60,6 +60,8 @@ export default class Notifications extends FlipperDevicePlugin<{}> { return ( ({ @@ -90,6 +92,7 @@ type Props = {| selectedApp: ?string, deepLinkPayload?: ?string, }) => mixed, + selectedID: ?string, |}; type State = {| @@ -128,11 +131,16 @@ const NoContent = styled(FlexColumn)({ }); class NotificationsTable extends Component { - state = { - selectedNotification: null, - }; + static getDerivedStateFromProps(props: Props): State { + return { + selectedNotification: props.selectedID, + }; + } contextMenuItems = [{label: 'Clear all', click: this.props.onClear}]; + state: State = { + selectedNotification: this.props.selectedID, + }; componentDidUpdate(prevProps: Props) { if (this.props.filters.length !== prevProps.filters.length) { @@ -196,7 +204,8 @@ class NotificationsTable extends Component { onHide={() => this.onHide(n.pluginId)} selectPlugin={this.props.selectPlugin} /> - )); + )) + .reverse(); const invalidatedNotifications = this.props.invalidatedNotifications .filter(this.getFilter()) @@ -207,7 +216,8 @@ class NotificationsTable extends Component { onClear={this.props.onClear} inactive /> - )); + )) + .reverse(); return ( diff --git a/src/dispatcher/notifications.js b/src/dispatcher/notifications.js index c01d6ebf3..479f500ef 100644 --- a/src/dispatcher/notifications.js +++ b/src/dispatcher/notifications.js @@ -65,9 +65,9 @@ export default (store: Store, logger: Logger) => { notification.onclick = () => store.dispatch( selectPlugin({ - selectedPlugin: n.pluginId, - selectedApp: n.client, - deepLinkPayload: n.notification.action, + selectedPlugin: 'notifications', + selectedApp: null, + deepLinkPayload: n.notification.id, }), ); knownNotifications.add(n.notification.id);