Correct live refresh routine for notifications
This commit is contained in:
parent
52a6682690
commit
f9c5cded6f
|
@ -49,10 +49,7 @@ export default {
|
||||||
const oldNotifications = stale.results.get('content');
|
const oldNotifications = stale.results.get('content');
|
||||||
const staleIndex = _.findIndex(oldNotifications, {id: lastNotification.id});
|
const staleIndex = _.findIndex(oldNotifications, {id: lastNotification.id});
|
||||||
|
|
||||||
if (staleIndex > -1) {
|
if (staleIndex === -1) {
|
||||||
oldNotifications.splice(staleIndex, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// this gets a bit tricky, uread pms are bumped to front
|
// this gets a bit tricky, uread pms are bumped to front
|
||||||
var insertPosition = 0;
|
var insertPosition = 0;
|
||||||
if (lastNotification.notification_type !== 6) {
|
if (lastNotification.notification_type !== 6) {
|
||||||
|
@ -62,21 +59,25 @@ export default {
|
||||||
insertPosition = insertPosition === -1 ? oldNotifications.length - 1 : insertPosition;
|
insertPosition = insertPosition === -1 ? oldNotifications.length - 1 : insertPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldNotifications.splice(insertPosition, 0, Em.Object.create(lastNotification));
|
oldNotifications.insertAt(insertPosition, Em.Object.create(lastNotification));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var idx=0; idx < data.recent.length; idx++) {
|
||||||
|
var old;
|
||||||
|
while(old = oldNotifications[idx]) {
|
||||||
|
var info = data.recent[idx];
|
||||||
|
|
||||||
var idx=0;
|
|
||||||
data.recent.forEach((info)=> {
|
|
||||||
var old = oldNotifications[idx];
|
|
||||||
if (old) {
|
|
||||||
if (old.get('id') !== info[0]) {
|
if (old.get('id') !== info[0]) {
|
||||||
oldNotifications.splice(idx, 1);
|
oldNotifications.removeAt(idx);
|
||||||
return;
|
} else {
|
||||||
} else if (old.get('read') !== info[1]) {
|
if (old.get('read') !== info[1]) {
|
||||||
old.set('read', info[1]);
|
old.set('read', info[1]);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( !old ) { break; }
|
||||||
}
|
}
|
||||||
idx += 1;
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}, user.notification_channel_position);
|
}, user.notification_channel_position);
|
||||||
|
|
Loading…
Reference in New Issue