...
 
Commits (3)
......@@ -12,6 +12,7 @@ import { List as ImmutableList } from 'immutable';
import { unescapeHTML } from '../utils/html';
import { getFilters, regexFromFilters } from '../selectors';
import { me } from '../initial_state';
import { NOTIFICATION_FILTERS } from '../constants'
export const NOTIFICATIONS_INITIALIZE = 'NOTIFICATIONS_INITIALIZE';
export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
......@@ -157,16 +158,10 @@ export function expandNotifications({ maxId } = {}, done = noOp) {
return;
}
// console.log("activeFilter:", activeFilter)
const params = {
max_id: maxId,
exclude_types: activeFilter === 'all' ? null : excludeTypesFromFilter(activeFilter),
// : todo : ?
// exclude_types: activeFilter === 'all'
// ? excludeTypesFromSettings(getState())
// : excludeTypesFromFilter(activeFilter),
};
}
if (!!onlyVerified) params.only_verified = onlyVerified
if (!!onlyFollowing) params.only_following = onlyFollowing
......@@ -240,7 +235,9 @@ export function scrollTopNotifications(top) {
};
export function setFilter(path, value) {
return dispatch => {
return (dispatch) => {
if (path === 'active' && NOTIFICATION_FILTERS.indexOf(value) === -1) return
dispatch({
type: NOTIFICATIONS_FILTER_SET,
path: path,
......
......@@ -88,4 +88,13 @@ export const THEMES = [
]
export const DEFAULT_THEME = 'light'
export const DEFAULT_FONT_SIZE = 'normal'
\ No newline at end of file
export const DEFAULT_FONT_SIZE = 'normal'
export const NOTIFICATION_FILTERS = [
'all',
'mention',
'favourite',
'reblog',
'poll',
'follow',
]
\ No newline at end of file
......@@ -18,25 +18,31 @@ const makeMapStateToProps = () => {
if (isFollows) {
let lastUpdated
let isUnread
const list = props.notification.get('follow')
let accounts = ImmutableList()
list.forEach((item) => {
const account = getAccountFromState(state, item.get('account'))
accounts = accounts.set(accounts.size, account)
if (!lastUpdated) lastUpdated = item.get('created_at')
if (!lastUpdated) {
isUnread = parseInt(item.get('id')) > parseInt(lastReadId)
lastUpdated = item.get('created_at')
}
})
return {
type: 'follow',
accounts: accounts,
createdAt: lastUpdated,
isUnread: false,
isUnread: isUnread,
statusId: undefined,
}
} else if (isLikes || isReposts) {
const theType = isLikes ? 'like' : 'repost'
const list = props.notification.get(theType)
let lastUpdated = list.get('lastUpdated')
let isUnread = list.get('isUnread')
let accounts = ImmutableList()
const accountIdArr = list.get('accounts')
......@@ -51,7 +57,7 @@ const makeMapStateToProps = () => {
type: theType,
accounts: accounts,
createdAt: lastUpdated,
isUnread: false,
isUnread: isUnread,
statusId: list.get('status'),
}
} else if (!isGrouped) {
......
......@@ -4,12 +4,14 @@ import { HotKeys } from 'react-hotkeys'
import { defineMessages, injectIntl } from 'react-intl'
import { Switch, Redirect, withRouter } from 'react-router-dom'
import debounce from 'lodash.debounce'
import queryString from 'query-string'
import { uploadCompose, resetCompose } from '../../actions/compose'
import { expandHomeTimeline } from '../../actions/timelines'
import { fetchGroups } from '../../actions/groups'
import {
initializeNotifications,
expandNotifications,
setFilter,
} from '../../actions/notifications'
import LoadingBar from '../../components/loading_bar'
import { fetchFilters } from '../../actions/filters'
......@@ -380,6 +382,15 @@ class UI extends PureComponent {
this.setState({ fetchedHome: true })
this.props.dispatch(expandHomeTimeline())
} else if (pathname.startsWith('/notifications')) {
try {
const search = this.context.router.route.location.search
const qp = queryString.parse(search)
const view = `${qp.view}`.toLowerCase()
this.props.dispatch(setFilter('active', view))
} catch (error) {
//
}
this.setState({ fetchedNotifications: true })
this.props.dispatch(expandNotifications())
}
......
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(),
......
......@@ -52,6 +52,7 @@ const notificationToMap = (notification) => ImmutableMap({
const makeSortedNotifications = (state) => {
let finalSortedItems = ImmutableList()
const items = state.get('items')
const lastReadId = state.get('lastReadId')
const chunks = Range(0, items.count(), DEFAULT_NOTIFICATIONS_LIMIT)
.map((chunkStart) => items.slice(chunkStart, chunkStart + DEFAULT_NOTIFICATIONS_LIMIT))
......@@ -88,6 +89,7 @@ const makeSortedNotifications = (state) => {
likes[statusId].push({
account: notification.get('account'),
created_at: notification.get('created_at'),
id: notification.get('id'),
})
break
}
......@@ -101,6 +103,7 @@ const makeSortedNotifications = (state) => {
reposts[statusId].push({
account: notification.get('account'),
created_at: notification.get('created_at'),
id: notification.get('id'),
})
break
}
......@@ -121,10 +124,13 @@ const makeSortedNotifications = (state) => {
const likeArr = likes[statusId]
const accounts = likeArr.map((l) => l.account)
const lastUpdated = likeArr[0]['created_at']
const isUnread = parseInt(likeArr[0]['id']) > lastReadId
sortedItems = sortedItems.set(indexesForStatusesForFavorites[statusId], ImmutableMap({
like: ImmutableMap({
accounts,
lastUpdated,
isUnread,
status: statusId,
})
}))
......@@ -137,10 +143,13 @@ const makeSortedNotifications = (state) => {
const repostArr = reposts[statusId]
const accounts = repostArr.map((l) => l.account)
const lastUpdated = repostArr[0]['created_at']
const isUnread = parseInt(repostArr[0]['id']) > lastReadId
sortedItems = sortedItems.set(indexesForStatusesForReposts[statusId], ImmutableMap({
repost: ImmutableMap({
accounts,
lastUpdated,
isUnread,
status: statusId,
})
}))
......
......@@ -31,7 +31,7 @@
--solid_color_secondary-dark: #d9e0e5;
--solid_color_tertiary: #f5f5f7;
--solid_color_block: #f5f8fa;
--solid_color_highlight: rgba(224, 234, 66, .25);
--solid_color_highlight: rgba(224, 234, 66, .125);
--text_color_primary: #2d3436;
--text_color_secondary: #4b4f55;
......@@ -70,7 +70,6 @@
--solid_color_secondary-dark: #424343 !important;
--solid_color_tertiary: #333 !important;
--solid_color_block: #2d2d2d !important;
--solid_color_highlight: rgba(224, 234, 66, .1) !important;
--text_color_primary: #fff !important;
--text_color_secondary: #7b7b7b !important;
......@@ -93,7 +92,6 @@
--solid_color_secondary-dark: #424343 !important;
--solid_color_tertiary: #000 !important;
--solid_color_block: #202327 !important;
--solid_color_highlight: rgba(224, 234, 66, .1) !important;
--text_color_primary: #cccbcb !important;
--text_color_secondary: #61686E !important;
......