diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 18ce71e2d..38e01e151 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -253,6 +253,39 @@ +
+
+
+
+

More posts from {{this.statusUsername}}

+
+ +
+
@@ -676,7 +709,9 @@ export default { ctxEmbedShowLikes: false, ctxEmbedCompactMode: false, layout: this.profileLayout, - canEdit: false + canEdit: false, + showProfileMorePosts: false, + profileMorePosts: [] } }, watch: { @@ -782,6 +817,7 @@ export default { } } this.loaded = true; + this.fetchProfilePosts(); }).catch(error => { swal('Oops!', 'An error occured, please try refreshing the page.', 'error'); }); @@ -1270,7 +1306,50 @@ export default { reply.url : '/i/web/post/_/' + profile.id + '/' + reply.id; } - } + }, + + fetchProfilePosts() { + let self = this; + let apiUrl = '/api/pixelfed/v1/accounts/' + this.statusProfileId + '/statuses'; + axios.get(apiUrl, { + params: { + only_media: true, + min_id: 1, + limit: 9 + } + }) + .then(res => { + let data = res.data.filter(function(status) { + return status.media_attachments.length > 0 && + status.id != self.statusId && + status.sensitive == false + }); + let ids = data.map(status => status.id); + if(data.length >= 3) { + self.showProfileMorePosts = true; + } + self.profileMorePosts = data.slice(0,6); + }) + }, + + previewUrl(status) { + return status.sensitive ? '/storage/no-preview.png?v=' + new Date().getTime() : status.media_attachments[0].preview_url; + }, + + previewBackground(status) { + let preview = this.previewUrl(status); + return 'background-image: url(' + preview + ');'; + }, + + getStatusUrl(status) { + return status.url; + + if(status.local == true) { + return status.url; + } + + return '/i/web/post/_/' + status.account.id + '/' + status.id; + }, }, }