Updated notifications to set filter if view query is present on load

• Updated:
- notifications to set filter if view query is present on load
This commit is contained in:
mgabdev
2020-05-21 18:03:35 -04:00
parent 1f84ff8f1a
commit 3c310c457b
4 changed files with 28 additions and 36 deletions

View File

@@ -1,7 +1,7 @@
import { Fragment } from 'react'
import { defineMessages, injectIntl } from 'react-intl'
import queryString from 'query-string'
import { setFilter } from '../actions/notifications'
import { NOTIFICATION_FILTERS } from '../constants'
import PageTitle from '../features/ui/util/page_title'
import LinkFooter from '../components/link_footer'
import WhoToFollowPanel from '../components/panel/who_to_follow_panel'
@@ -9,15 +9,6 @@ import NotificationFilterPanel from '../components/panel/notification_filter_pan
import TrendsPanel from '../components/panel/trends_panel'
import DefaultLayout from '../layouts/default_layout'
const filters = [
'all',
'mention',
'favourite',
'reblog',
'poll',
'follow',
]
const messages = defineMessages({
notifications: { id: 'tabs_bar.notifications', defaultMessage: 'Notifications' },
mention: { id: 'notifications.filter.mentions', defaultMessage: 'Mentions' },
@@ -57,22 +48,6 @@ class NotificationsPage extends PureComponent {
selectedFilter: PropTypes.string.isRequired,
}
UNSAFE_componentWillMount() {
this.checkForQueryStringChange(this.context.router.route.location)
}
checkForQueryStringChange = (location) => {
try {
const qp = queryString.parse(location.search)
const view = `${qp.view}`.toLowerCase()
if (filters.indexOf(view) > -1) {
this.onChangeActiveFilter(view)
}
} catch (error) {
//
}
}
onChangeActiveFilter(notificationType) {
this.props.setFilter(notificationType)
@@ -91,7 +66,7 @@ class NotificationsPage extends PureComponent {
selectedFilter,
} = this.props
const tabs = filters.map((filter) => ({
const tabs = NOTIFICATION_FILTERS.map((filter) => ({
title: intl.formatMessage(messages[filter]),
onClick: () => this.onChangeActiveFilter(filter),
active: selectedFilter.toLowerCase() === filter.toLowerCase(),