Update Notification components, fix old notifications with missing attributes
This commit is contained in:
parent
f9516ac316
commit
b6e226aef9
2 changed files with 34 additions and 6 deletions
|
@ -146,6 +146,12 @@ export default {
|
||||||
if(n.type == 'mention' && !n.status) {
|
if(n.type == 'mention' && !n.status) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(n.type == 'favourite' && !n.status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(n.type == 'follow' && !n.account) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
let ids = res.data.map(n => n.id);
|
let ids = res.data.map(n => n.id);
|
||||||
|
@ -168,13 +174,19 @@ export default {
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if(res.data.length) {
|
if(res.data.length) {
|
||||||
let data = res.data.filter(n => {
|
let data = res.data.filter(n => {
|
||||||
if(n.type == 'share' && !status) {
|
if(n.type == 'share' && !n.status) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(n.type == 'comment' && !status) {
|
if(n.type == 'comment' && !n.status) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(n.type == 'mention' && !status) {
|
if(n.type == 'mention' && !n.status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(n.type == 'favourite' && !n.status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(n.type == 'follow' && !n.account) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(_.find(this.notifications, {id: n.id})) {
|
if(_.find(this.notifications, {id: n.id})) {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<div v-if="n.type == 'favourite'">
|
<div v-if="n.type == 'favourite'">
|
||||||
<p class="my-0">
|
<p class="my-0">
|
||||||
<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}}</a> liked your
|
<a :href="getProfileUrl(n.account)" class="font-weight-bold text-dark word-break" :title="n.account.username">{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}}</a> liked your
|
||||||
<span v-if="n.status.hasOwnProperty('media_attachments')">
|
<span v-if="n.status && n.status.hasOwnProperty('media_attachments')">
|
||||||
<a class="font-weight-bold" v-bind:href="getPostUrl(n.status)" :id="'fvn-' + n.id">post</a>.
|
<a class="font-weight-bold" v-bind:href="getPostUrl(n.status)" :id="'fvn-' + n.id">post</a>.
|
||||||
<b-popover :target="'fvn-' + n.id" title="" triggers="hover" placement="top" boundary="window">
|
<b-popover :target="'fvn-' + n.id" title="" triggers="hover" placement="top" boundary="window">
|
||||||
<img :src="notificationPreview(n)" width="100px" height="100px" style="object-fit: cover;">
|
<img :src="notificationPreview(n)" width="100px" height="100px" style="object-fit: cover;">
|
||||||
|
@ -140,6 +140,12 @@
|
||||||
if(n.type == 'mention' && !n.status) {
|
if(n.type == 'mention' && !n.status) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(n.type == 'favourite' && !n.status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(n.type == 'follow' && !n.account) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
let ids = data.map(n => n.id);
|
let ids = data.map(n => n.id);
|
||||||
|
@ -171,6 +177,12 @@
|
||||||
if(n.type == 'mention' && !n.status) {
|
if(n.type == 'mention' && !n.status) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(n.type == 'favourite' && !n.status) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(n.type == 'follow' && !n.account) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if(_.find(this.notifications, {id: n.id})) {
|
if(_.find(this.notifications, {id: n.id})) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +283,7 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
notificationPreview(n) {
|
notificationPreview(n) {
|
||||||
if(!n.status.hasOwnProperty('media_attachments') || !n.status.media_attachments.length) {
|
if(!n.status || !n.status.hasOwnProperty('media_attachments') || !n.status.media_attachments.length) {
|
||||||
return '/storage/no-preview.png';
|
return '/storage/no-preview.png';
|
||||||
}
|
}
|
||||||
return n.status.media_attachments[0].preview_url;
|
return n.status.media_attachments[0].preview_url;
|
||||||
|
@ -286,7 +298,11 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
getPostUrl(status) {
|
getPostUrl(status) {
|
||||||
if(status.local == true) {
|
if(!status) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!status.hasOwnProperty('local') || status.local == true) {
|
||||||
return status.url;
|
return status.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue