Added isUnread to grouped follows, likes, reposts notifications
• Added: - isUnread to grouped follows, likes, reposts notifications
This commit is contained in:
parent
3a09bc2160
commit
1f84ff8f1a
@ -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) {
|
||||
|
@ -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,
|
||||
})
|
||||
}))
|
||||
|
Loading…
x
Reference in New Issue
Block a user