From 15c7ff1ebaa08098ce69d4dda49e78a0a01a207f Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Wed, 15 Jul 2020 23:01:49 -0500 Subject: [PATCH] Fixed issue with loading in Notifications MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fixed: - issue with loading in Notifications --- .../gabsocial/features/notifications.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/javascript/gabsocial/features/notifications.js b/app/javascript/gabsocial/features/notifications.js index ec9baae5..916b9233 100644 --- a/app/javascript/gabsocial/features/notifications.js +++ b/app/javascript/gabsocial/features/notifications.js @@ -57,6 +57,10 @@ class Notifications extends ImmutablePureComponent { selectedFilter: PropTypes.string.isRequired, } + state = { + changedTabs: false, + } + componentWillUnmount() { this.handleLoadOlder.cancel() this.handleScrollToTop.cancel() @@ -69,13 +73,21 @@ class Notifications extends ImmutablePureComponent { this.props.onScrollTopNotifications(true) } - componentDidUpdate (prevProps) { + componentDidUpdate (prevProps, prevState) { //Check if clicked on "notifications" button, if so, reload if (prevProps.location.key !== this.props.location.key && prevProps.location.pathname === '/notifications' && this.props.location.pathname === '/notifications') { this.handleReload() } + + if (prevProps.selectedFilter !== this.props.selectedFilter) { + this.setState({ changedTabs: true }) + } + + if (prevProps.selectedFilter === this.props.selectedFilter && prevState.changedTabs) { + this.setState({ changedTabs: false }) + } } handleReload = throttle(() => { @@ -107,8 +119,9 @@ class Notifications extends ImmutablePureComponent { totalQueuedNotificationsCount, selectedFilter, } = this.props + const { changedTabs } = this.state - if (isLoading) { + if (isLoading && changedTabs) { return }