From b6e226aef98365855379f2a35b7f12a1968d265a Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 25 Jul 2021 02:14:41 -0600 Subject: [PATCH] Update Notification components, fix old notifications with missing attributes --- resources/assets/js/components/Activity.vue | 18 ++++++++++++--- .../assets/js/components/NotificationCard.vue | 22 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/resources/assets/js/components/Activity.vue b/resources/assets/js/components/Activity.vue index 751cab0a..6e03b177 100644 --- a/resources/assets/js/components/Activity.vue +++ b/resources/assets/js/components/Activity.vue @@ -146,6 +146,12 @@ export default { 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 true; }); let ids = res.data.map(n => n.id); @@ -168,13 +174,19 @@ export default { }).then(res => { if(res.data.length) { let data = res.data.filter(n => { - if(n.type == 'share' && !status) { + if(n.type == 'share' && !n.status) { return false; } - if(n.type == 'comment' && !status) { + if(n.type == 'comment' && !n.status) { 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; } if(_.find(this.notifications, {id: n.id})) { diff --git a/resources/assets/js/components/NotificationCard.vue b/resources/assets/js/components/NotificationCard.vue index db4139cc..3648df8d 100644 --- a/resources/assets/js/components/NotificationCard.vue +++ b/resources/assets/js/components/NotificationCard.vue @@ -21,7 +21,7 @@

{{n.account.local == false ? '@':''}}{{truncate(n.account.username)}} liked your - + post. @@ -140,6 +140,12 @@ 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 true; }); let ids = data.map(n => n.id); @@ -171,6 +177,12 @@ if(n.type == 'mention' && !n.status) { 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})) { return false; } @@ -271,7 +283,7 @@ }, 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 n.status.media_attachments[0].preview_url; @@ -286,7 +298,11 @@ }, getPostUrl(status) { - if(status.local == true) { + if(!status) { + return; + } + + if(!status.hasOwnProperty('local') || status.local == true) { return status.url; }