]> cat aescling's git repositories - mastodon.git/commitdiff
Finalize location on scrollable notifications when unmounting (#6614)
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
Sun, 4 Mar 2018 07:55:15 +0000 (16:55 +0900)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 4 Mar 2018 07:55:15 +0000 (08:55 +0100)
The top of the scrollable notifications will be invisible after unmounting.
The Redux state should be updated accordingly in such a case so that the
unread notification counter will be updated later.

app/javascript/mastodon/features/notifications/index.js

index 35b430bfb518c2ce62cadba66ea1fd10518ba9a5..77abfae25aeae6c9e7af36cfc6687862056708c8 100644 (file)
@@ -50,6 +50,13 @@ export default class Notifications extends React.PureComponent {
     trackScroll: true,
   };
 
+  componentWillUnmount () {
+    this.handleScrollToBottom.cancel();
+    this.handleScrollToTop.cancel();
+    this.handleScroll.cancel();
+    this.props.dispatch(scrollTopNotifications(false));
+  }
+
   handleScrollToBottom = debounce(() => {
     this.props.dispatch(scrollTopNotifications(false));
     this.props.dispatch(expandNotifications());