From 420131a1adac34f43ff887fcb56a655b0eb95247 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 10 Nov 2019 18:19:00 -0700 Subject: [PATCH] Update CollectionComponent --- .../js/components/CollectionComponent.vue | 59 +++++++++++++++++-- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/resources/assets/js/components/CollectionComponent.vue b/resources/assets/js/components/CollectionComponent.vue index 56dd8318f..bf7c4b58f 100644 --- a/resources/assets/js/components/CollectionComponent.vue +++ b/resources/assets/js/components/CollectionComponent.vue @@ -15,7 +15,14 @@

- +         @@ -62,7 +69,20 @@ - + +

+ +
+
+
+
+
+
+
+
+
+
+
@@ -105,12 +125,15 @@ export default { return { loaded: false, posts: [], + ids: [], currentUser: false, owner: false, title: this.collectionTitle, description: this.collectionDescription, visibility: this.collectionVisibility, - photoId: '' + photoId: '', + postsList: [], + loadingPostList: false } }, @@ -135,6 +158,9 @@ export default { axios.get('/api/local/collection/items/' + this.collectionId) .then(res => { this.posts = res.data; + this.ids = this.posts.map(p => { + return p.id; + }); this.loaded = true; }); }, @@ -149,11 +175,34 @@ export default { }, addToCollection() { - this.$refs.addPhotoModal.show(); + let self = this; + this.loadingPostList = true; + if(this.postsList.length == 0) { + axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/statuses', { + params: { + min_id: 1, + limit: 13 + } + }) + .then(res => { + self.postsList = res.data.filter(l => { + return self.ids.indexOf(l.id) == -1; + }).splice(0,9); + self.loadingPostList = false; + self.$refs.addPhotoModal.show(); + }).catch(err => { + self.loadingPostList = false; + swal('An Error Occured', 'We cannot process your request at this time, please try again later.', 'error'); + }) + } else { + this.$refs.addPhotoModal.show(); + this.loadingPostList = false; + } }, pushId() { let max = 18; + let self = this; if(this.posts.length >= max) { swal('Error', 'You can only add ' + max + ' posts per collection', 'error'); return; @@ -174,7 +223,7 @@ export default { collection_id: this.collectionId, post_id: split[5] }).then(res => { - location.reload(); + self.ids.push(...split[5]); }).catch(err => { swal('Invalid URL', 'The post you entered was invalid', 'error'); this.photoId = '';