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) {
|
if (isFollows) {
|
||||||
let lastUpdated
|
let lastUpdated
|
||||||
|
let isUnread
|
||||||
|
|
||||||
const list = props.notification.get('follow')
|
const list = props.notification.get('follow')
|
||||||
let accounts = ImmutableList()
|
let accounts = ImmutableList()
|
||||||
list.forEach((item) => {
|
list.forEach((item) => {
|
||||||
const account = getAccountFromState(state, item.get('account'))
|
const account = getAccountFromState(state, item.get('account'))
|
||||||
accounts = accounts.set(accounts.size, 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 {
|
return {
|
||||||
type: 'follow',
|
type: 'follow',
|
||||||
accounts: accounts,
|
accounts: accounts,
|
||||||
createdAt: lastUpdated,
|
createdAt: lastUpdated,
|
||||||
isUnread: false,
|
isUnread: isUnread,
|
||||||
statusId: undefined,
|
statusId: undefined,
|
||||||
}
|
}
|
||||||
} else if (isLikes || isReposts) {
|
} else if (isLikes || isReposts) {
|
||||||
const theType = isLikes ? 'like' : 'repost'
|
const theType = isLikes ? 'like' : 'repost'
|
||||||
const list = props.notification.get(theType)
|
const list = props.notification.get(theType)
|
||||||
let lastUpdated = list.get('lastUpdated')
|
let lastUpdated = list.get('lastUpdated')
|
||||||
|
let isUnread = list.get('isUnread')
|
||||||
|
|
||||||
let accounts = ImmutableList()
|
let accounts = ImmutableList()
|
||||||
const accountIdArr = list.get('accounts')
|
const accountIdArr = list.get('accounts')
|
||||||
@ -51,7 +57,7 @@ const makeMapStateToProps = () => {
|
|||||||
type: theType,
|
type: theType,
|
||||||
accounts: accounts,
|
accounts: accounts,
|
||||||
createdAt: lastUpdated,
|
createdAt: lastUpdated,
|
||||||
isUnread: false,
|
isUnread: isUnread,
|
||||||
statusId: list.get('status'),
|
statusId: list.get('status'),
|
||||||
}
|
}
|
||||||
} else if (!isGrouped) {
|
} else if (!isGrouped) {
|
||||||
|
@ -52,6 +52,7 @@ const notificationToMap = (notification) => ImmutableMap({
|
|||||||
const makeSortedNotifications = (state) => {
|
const makeSortedNotifications = (state) => {
|
||||||
let finalSortedItems = ImmutableList()
|
let finalSortedItems = ImmutableList()
|
||||||
const items = state.get('items')
|
const items = state.get('items')
|
||||||
|
const lastReadId = state.get('lastReadId')
|
||||||
|
|
||||||
const chunks = Range(0, items.count(), DEFAULT_NOTIFICATIONS_LIMIT)
|
const chunks = Range(0, items.count(), DEFAULT_NOTIFICATIONS_LIMIT)
|
||||||
.map((chunkStart) => items.slice(chunkStart, chunkStart + DEFAULT_NOTIFICATIONS_LIMIT))
|
.map((chunkStart) => items.slice(chunkStart, chunkStart + DEFAULT_NOTIFICATIONS_LIMIT))
|
||||||
@ -88,6 +89,7 @@ const makeSortedNotifications = (state) => {
|
|||||||
likes[statusId].push({
|
likes[statusId].push({
|
||||||
account: notification.get('account'),
|
account: notification.get('account'),
|
||||||
created_at: notification.get('created_at'),
|
created_at: notification.get('created_at'),
|
||||||
|
id: notification.get('id'),
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -101,6 +103,7 @@ const makeSortedNotifications = (state) => {
|
|||||||
reposts[statusId].push({
|
reposts[statusId].push({
|
||||||
account: notification.get('account'),
|
account: notification.get('account'),
|
||||||
created_at: notification.get('created_at'),
|
created_at: notification.get('created_at'),
|
||||||
|
id: notification.get('id'),
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -121,10 +124,13 @@ const makeSortedNotifications = (state) => {
|
|||||||
const likeArr = likes[statusId]
|
const likeArr = likes[statusId]
|
||||||
const accounts = likeArr.map((l) => l.account)
|
const accounts = likeArr.map((l) => l.account)
|
||||||
const lastUpdated = likeArr[0]['created_at']
|
const lastUpdated = likeArr[0]['created_at']
|
||||||
|
const isUnread = parseInt(likeArr[0]['id']) > lastReadId
|
||||||
|
|
||||||
sortedItems = sortedItems.set(indexesForStatusesForFavorites[statusId], ImmutableMap({
|
sortedItems = sortedItems.set(indexesForStatusesForFavorites[statusId], ImmutableMap({
|
||||||
like: ImmutableMap({
|
like: ImmutableMap({
|
||||||
accounts,
|
accounts,
|
||||||
lastUpdated,
|
lastUpdated,
|
||||||
|
isUnread,
|
||||||
status: statusId,
|
status: statusId,
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
@ -137,10 +143,13 @@ const makeSortedNotifications = (state) => {
|
|||||||
const repostArr = reposts[statusId]
|
const repostArr = reposts[statusId]
|
||||||
const accounts = repostArr.map((l) => l.account)
|
const accounts = repostArr.map((l) => l.account)
|
||||||
const lastUpdated = repostArr[0]['created_at']
|
const lastUpdated = repostArr[0]['created_at']
|
||||||
|
const isUnread = parseInt(repostArr[0]['id']) > lastReadId
|
||||||
|
|
||||||
sortedItems = sortedItems.set(indexesForStatusesForReposts[statusId], ImmutableMap({
|
sortedItems = sortedItems.set(indexesForStatusesForReposts[statusId], ImmutableMap({
|
||||||
repost: ImmutableMap({
|
repost: ImmutableMap({
|
||||||
accounts,
|
accounts,
|
||||||
lastUpdated,
|
lastUpdated,
|
||||||
|
isUnread,
|
||||||
status: statusId,
|
status: statusId,
|
||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user