Commit e1e6e07e authored by mgabdev's avatar mgabdev

TESTING - Notification logs - 3

TESTING - Notification logs - 3
parent 087ad23b
......@@ -69,96 +69,98 @@ const makeSortedNotifications = (state) => {
let indexesForStatusesForFavorites = {}
chunk.forEach((notification) => {
const statusId = notification.get('status')
const type = notification.get('type')
switch (type) {
case 'follow': {
if (followIndex === -1) followIndex = sortedItems.size
sortedItems = sortedItems.set(followIndex, ImmutableMap())
follows = follows.set(follows.size, notification)
break
}
case 'favourite': {
if (likes[statusId] === undefined) {
let size = sortedItems.size
sortedItems = sortedItems.set(size, ImmutableMap())
indexesForStatusesForFavorites[statusId] = size
likes[statusId] = []
if (!!notification) {
const statusId = notification.get('status')
const type = notification.get('type')
switch (type) {
case 'follow': {
if (followIndex === -1) followIndex = sortedItems.size
sortedItems = sortedItems.set(followIndex, ImmutableMap())
follows = follows.set(follows.size, notification)
break
}
likes[statusId].push({
account: notification.get('account'),
created_at: notification.get('created_at'),
id: notification.get('id'),
})
break
}
case 'reblog': {
if (reposts[statusId] === undefined) {
let size = sortedItems.size
sortedItems = sortedItems.set(size, ImmutableMap())
indexesForStatusesForReposts[statusId] = size
reposts[statusId] = []
case 'favourite': {
if (likes[statusId] === undefined) {
let size = sortedItems.size
sortedItems = sortedItems.set(size, ImmutableMap())
indexesForStatusesForFavorites[statusId] = size
likes[statusId] = []
}
likes[statusId].push({
account: notification.get('account'),
created_at: notification.get('created_at'),
id: notification.get('id'),
})
break
}
case 'reblog': {
if (reposts[statusId] === undefined) {
let size = sortedItems.size
sortedItems = sortedItems.set(size, ImmutableMap())
indexesForStatusesForReposts[statusId] = size
reposts[statusId] = []
}
reposts[statusId].push({
account: notification.get('account'),
created_at: notification.get('created_at'),
id: notification.get('id'),
})
break
}
default: {
sortedItems = sortedItems.set(sortedItems.size, notification)
break
}
reposts[statusId].push({
account: notification.get('account'),
created_at: notification.get('created_at'),
id: notification.get('id'),
})
break
}
default: {
sortedItems = sortedItems.set(sortedItems.size, notification)
break
}
}
if (follows.size > 0) {
sortedItems = sortedItems.set(followIndex, ImmutableMap({
follow: follows,
}))
}
if (Object.keys(likes).length > 0) {
for (const statusId in likes) {
if (likes.hasOwnProperty(statusId)) {
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,
})
}))
if (follows.size > 0) {
sortedItems = sortedItems.set(followIndex, ImmutableMap({
follow: follows,
}))
}
if (Object.keys(likes).length > 0) {
for (const statusId in likes) {
if (likes.hasOwnProperty(statusId)) {
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,
})
}))
}
}
}
}
if (Object.keys(reposts).length > 0) {
for (const statusId in reposts) {
if (reposts.hasOwnProperty(statusId)) {
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,
})
}))
if (Object.keys(reposts).length > 0) {
for (const statusId in reposts) {
if (reposts.hasOwnProperty(statusId)) {
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,
})
}))
}
}
}
}
})
finalSortedItems = finalSortedItems.concat(sortedItems)
if (sortedItems.size > 0) finalSortedItems = finalSortedItems.concat(sortedItems)
})
return state.set('sortedItems', finalSortedItems)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment