#436: fix notification order, follow type link issue, duplicate key

This commit is contained in:
dave 2019-03-14 07:55:39 -04:00
parent 93a2510ede
commit e5e1d4c643
5 changed files with 15 additions and 10 deletions

View file

@ -30,7 +30,12 @@
<small>{{$t('notifications.followed_you')}}</small>
</span>
</div>
<div class="timeago">
<div class="timeago" v-if="notification.type === 'follow'">
<span class="faint">
<timeago :since="notification.action.created_at" :auto-update="240"></timeago>
</span>
</div>
<div class="timeago" v-else>
<router-link v-if="notification.status" :to="{ name: 'conversation', params: { id: notification.status.id } }" class="faint-link">
<timeago :since="notification.action.created_at" :auto-update="240"></timeago>
</router-link>

View file

@ -13,7 +13,7 @@
<button v-if="notifications.length" @click.prevent="clear" class="read-button">{{$t('notifications.clear')}}</button>
</div>
<div class="panel-body">
<div v-for="notification in visibleNotifications" :key="notification.action.id" class="notification" :class='{"unseen": !notification.seen}'>
<div v-for="notification in visibleNotifications" :key="notification.action.id + notification.id" class="notification" :class='{"unseen": !notification.seen}'>
<div class="notification-overlay"></div>
<notification :notification="notification"></notification>
</div>

View file

@ -269,11 +269,11 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us
}
const addNewNotifications = (state, { dispatch, notifications, older, visibleNotificationTypes }) => {
const allStatuses = state.allStatuses
const allStatusesObject = state.allStatusesObject
// const allStatuses = state.allStatuses
// const allStatusesObject = state.allStatusesObject
each(notifications, (notification) => {
notification.action = mergeOrAdd(allStatuses, allStatusesObject, notification.action).item
notification.status = notification.status && mergeOrAdd(allStatuses, allStatusesObject, notification.status).item
// notification.action = mergeOrAdd(allStatuses, allStatusesObject, notification.action).item
// notification.status = notification.status && mergeOrAdd(allStatuses, allStatusesObject, notification.status).item
// Only add a new notification if we don't have one for the same action
if (!state.notifications.idStore.hasOwnProperty(notification.id)) {

View file

@ -275,7 +275,7 @@ export const parseNotification = (data) => {
output.status = output.type === 'follow'
? parseFollow(data)
: parseStatus(data.status)
if (data.type === 'reblog') {
if (data.type === 'reblog' || data.type === 'favourite') {
output.status.user = parseUser(data.account)
output.status.created_at = new Date(data.created_at)
}

View file

@ -10,8 +10,8 @@ export const visibleTypes = store => ([
].filter(_ => _))
const sortById = (a, b) => {
const seqA = Number(a.action.id)
const seqB = Number(b.action.id)
const seqA = Number(a.id)
const seqB = Number(b.id)
const isSeqA = !Number.isNaN(seqA)
const isSeqB = !Number.isNaN(seqB)
if (isSeqA && isSeqB) {
@ -21,7 +21,7 @@ const sortById = (a, b) => {
} else if (!isSeqA && isSeqB) {
return -1
} else {
return a.action.id > b.action.id ? -1 : 1
return a.id > b.id ? -1 : 1
}
}