From 3c306c5e179d35dbe19a6a1bd9533350e4b96524 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 15 Sep 2019 18:06:04 -0600 Subject: [PATCH] Update vue components, namespace v1 api --- resources/assets/js/components/Activity.vue | 4 +- .../js/components/CollectionComponent.vue | 2 +- .../js/components/CollectionCompose.vue | 2 +- .../assets/js/components/ComposeClassic.vue | 6 +- .../assets/js/components/ComposeModal.vue | 6 +- .../assets/js/components/NotificationCard.vue | 6 +- .../assets/js/components/PostComponent.vue | 2 +- resources/assets/js/components/Profile.vue | 18 ++-- resources/assets/js/components/Timeline.vue | 94 +++---------------- 9 files changed, 38 insertions(+), 102 deletions(-) diff --git a/resources/assets/js/components/Activity.vue b/resources/assets/js/components/Activity.vue index 8cc8f586c..654e67ebf 100644 --- a/resources/assets/js/components/Activity.vue +++ b/resources/assets/js/components/Activity.vue @@ -115,7 +115,7 @@ export default { methods: { fetchNotifications() { - axios.get('/api/v1/notifications') + axios.get('/api/pixelfed/v1/notifications') .then(res => { let data = res.data.filter(n => { if(n.type == 'share' && !status) { @@ -136,7 +136,7 @@ export default { $state.complete(); return; } - axios.get('/api/v1/notifications', { + axios.get('/api/pixelfed/v1/notifications', { params: { page: this.notificationCursor } diff --git a/resources/assets/js/components/CollectionComponent.vue b/resources/assets/js/components/CollectionComponent.vue index 733601ba0..56dd8318f 100644 --- a/resources/assets/js/components/CollectionComponent.vue +++ b/resources/assets/js/components/CollectionComponent.vue @@ -125,7 +125,7 @@ export default { methods: { fetchCurrentUser() { if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) { - axios.get('/api/v1/accounts/verify_credentials').then(res => { + axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => { this.currentUser = res.data; this.owner = this.currentUser.id == this.profileId; }); diff --git a/resources/assets/js/components/CollectionCompose.vue b/resources/assets/js/components/CollectionCompose.vue index 9ae7de01e..7ba4cb1d3 100644 --- a/resources/assets/js/components/CollectionCompose.vue +++ b/resources/assets/js/components/CollectionCompose.vue @@ -201,7 +201,7 @@ export default { }, fetchRecentPosts() { - axios.get('/api/v1/accounts/' + this.profileId + '/statuses', { + axios.get('/api/local/accounts/' + this.profileId + '/statuses', { params: { only_media: true, min_id: 1, diff --git a/resources/assets/js/components/ComposeClassic.vue b/resources/assets/js/components/ComposeClassic.vue index df751cb71..24f49ea8c 100644 --- a/resources/assets/js/components/ComposeClassic.vue +++ b/resources/assets/js/components/ComposeClassic.vue @@ -295,7 +295,7 @@ export default { methods: { fetchProfile() { - axios.get('/api/v1/accounts/verify_credentials').then(res => { + axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => { this.profile = res.data; if(res.data.locked == true) { this.visibility = 'private'; @@ -341,7 +341,7 @@ export default { } }; - axios.post('/api/v1/media', form, xhrConfig) + axios.post('/api/pixelfed/v1/media', form, xhrConfig) .then(function(e) { self.uploadProgress = 100; self.ids.push(e.data.id); @@ -373,7 +373,7 @@ export default { return; } let id = this.media[this.carouselCursor].id; - axios.delete('/api/v1/media', { + axios.delete('/api/pixelfed/v1/media', { params: { id: id } diff --git a/resources/assets/js/components/ComposeModal.vue b/resources/assets/js/components/ComposeModal.vue index 99c3df1b1..5ee92427b 100644 --- a/resources/assets/js/components/ComposeModal.vue +++ b/resources/assets/js/components/ComposeModal.vue @@ -400,7 +400,7 @@ export default { methods: { fetchProfile() { - axios.get('/api/v1/accounts/verify_credentials').then(res => { + axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => { this.profile = res.data; window.pixelfed.currentUser = res.data; if(res.data.locked == true) { @@ -454,7 +454,7 @@ export default { } }; - axios.post('/api/v1/media', form, xhrConfig) + axios.post('/api/pixelfed/v1/media', form, xhrConfig) .then(function(e) { self.uploadProgress = 100; self.ids.push(e.data.id); @@ -516,7 +516,7 @@ export default { return; } let id = this.media[this.carouselCursor].id; - axios.delete('/api/v1/media', { + axios.delete('/api/pixelfed/v1/media', { params: { id: id } diff --git a/resources/assets/js/components/NotificationCard.vue b/resources/assets/js/components/NotificationCard.vue index 8dc685a16..de90195e2 100644 --- a/resources/assets/js/components/NotificationCard.vue +++ b/resources/assets/js/components/NotificationCard.vue @@ -81,7 +81,7 @@ methods: { fetchNotifications() { - axios.get('/api/v1/notifications') + axios.get('/api/pixelfed/v1/notifications') .then(res => { let data = res.data.filter(n => { if(n.type == 'share' && !status) { @@ -103,7 +103,7 @@ $state.complete(); return; } - axios.get('/api/v1/notifications', { + axios.get('/api/pixelfed/v1/notifications', { params: { page: this.notificationCursor } @@ -171,7 +171,7 @@ let interval = this.notifications.length > 5 ? 15000 : 120000; let self = this; setInterval(function() { - axios.get('/api/v1/notifications') + axios.get('/api/pixelfed/v1/notifications') .then(res => { let data = res.data.filter(n => { if(n.type == 'share' || self.notificationMaxId >= n.id) { diff --git a/resources/assets/js/components/PostComponent.vue b/resources/assets/js/components/PostComponent.vue index 5c2cd222b..403c775bb 100644 --- a/resources/assets/js/components/PostComponent.vue +++ b/resources/assets/js/components/PostComponent.vue @@ -1106,7 +1106,7 @@ export default { this.fetchData(); return; } else { - axios.get('/api/v1/accounts/relationships', { + axios.get('/api/pixelfed/v1/accounts/relationships', { params: { 'id[]': this.statusProfileId } diff --git a/resources/assets/js/components/Profile.vue b/resources/assets/js/components/Profile.vue index 7b33a0b1d..d129156ed 100644 --- a/resources/assets/js/components/Profile.vue +++ b/resources/assets/js/components/Profile.vue @@ -583,7 +583,7 @@ this.followingModal(); } if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == true) { - axios.get('/api/v1/accounts/verify_credentials').then(res => { + axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => { this.user = res.data; }); } @@ -595,7 +595,7 @@ methods: { fetchProfile() { - axios.get('/api/v1/accounts/' + this.profileId).then(res => { + axios.get('/api/pixelfed/v1/accounts/' + this.profileId).then(res => { this.profile = res.data; }).then(res => { this.fetchPosts(); @@ -603,7 +603,7 @@ }, fetchPosts() { - let apiUrl = '/api/v1/accounts/' + this.profileId + '/statuses'; + let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses'; axios.get(apiUrl, { params: { only_media: true, @@ -641,7 +641,7 @@ $state.complete(); return; } - let apiUrl = '/api/v1/accounts/' + this.profileId + '/statuses'; + let apiUrl = '/api/pixelfed/v1/accounts/' + this.profileId + '/statuses'; axios.get(apiUrl, { params: { only_media: true, @@ -800,7 +800,7 @@ if(document.querySelectorAll('body')[0].classList.contains('loggedIn') == false) { return; } - axios.get('/api/v1/accounts/relationships', { + axios.get('/api/pixelfed/v1/accounts/relationships', { params: { 'id[]': this.profileId } @@ -935,7 +935,7 @@ this.$refs.followingModal.show(); return; } else { - axios.get('/api/v1/accounts/'+this.profileId+'/following', { + axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/following', { params: { page: this.followingCursor } @@ -964,7 +964,7 @@ this.$refs.followerModal.show(); return; } else { - axios.get('/api/v1/accounts/'+this.profileId+'/followers', { + axios.get('/api/pixelfed/v1/accounts/'+this.profileId+'/followers', { params: { page: this.followerCursor } @@ -986,7 +986,7 @@ window.location.href = encodeURI('/login?next=/' + this.profile.username + '/'); return; } - axios.get('/api/v1/accounts/'+this.profile.id+'/following', { + axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', { params: { page: this.followingCursor } @@ -1007,7 +1007,7 @@ if($('body').hasClass('loggedIn') == false) { return; } - axios.get('/api/v1/accounts/'+this.profile.id+'/followers', { + axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', { params: { page: this.followerCursor } diff --git a/resources/assets/js/components/Timeline.vue b/resources/assets/js/components/Timeline.vue index da3d38c7e..2e90770e9 100644 --- a/resources/assets/js/components/Timeline.vue +++ b/resources/assets/js/components/Timeline.vue @@ -343,7 +343,7 @@ Language Terms Privacy - API + Places

Powered by Pixelfed @@ -353,70 +353,6 @@ - { + axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => { this.profile = res.data; if(this.profile.is_admin == true) { this.modes.mod = true; @@ -652,15 +588,15 @@ let apiUrl = false; switch(this.scope) { case 'home': - apiUrl = '/api/v1/timelines/home'; + apiUrl = '/api/pixelfed/v1/timelines/home'; break; case 'local': - apiUrl = '/api/v1/timelines/public'; + apiUrl = '/api/pixelfed/v1/timelines/public'; break; case 'network': - apiUrl = '/api/v1/timelines/network'; + apiUrl = '/api/pixelfed/v1/timelines/network'; break; } axios.get(apiUrl, { @@ -695,15 +631,15 @@ let apiUrl = false; switch(this.scope) { case 'home': - apiUrl = '/api/v1/timelines/home'; + apiUrl = '/api/pixelfed/v1/timelines/home'; break; case 'local': - apiUrl = '/api/v1/timelines/public'; + apiUrl = '/api/pixelfed/v1/timelines/public'; break; case 'network': - apiUrl = '/api/v1/timelines/network'; + apiUrl = '/api/pixelfed/v1/timelines/network'; break; } axios.get(apiUrl, { @@ -736,8 +672,8 @@ }, loadMore(event) { - let homeTimeline = '/api/v1/timelines/home'; - let localTimeline = '/api/v1/timelines/public'; + let homeTimeline = '/api/pixelfed/v1/timelines/home'; + let localTimeline = '/api/pixelfed/v1/timelines/public'; let apiUrl = this.scope == 'home' ? homeTimeline : localTimeline; event.target.innerText = 'Loading...'; axios.get(apiUrl, { @@ -1068,7 +1004,7 @@ this.$refs.followingModal.show(); return; } - axios.get('/api/v1/accounts/'+this.profile.id+'/following', { + axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', { params: { page: this.followingCursor } @@ -1088,7 +1024,7 @@ this.$refs.followerModal.show(); return; } - axios.get('/api/v1/accounts/'+this.profile.id+'/followers', { + axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', { params: { page: this.followerCursor } @@ -1104,7 +1040,7 @@ }, followingLoadMore() { - axios.get('/api/v1/accounts/'+this.profile.id+'/following', { + axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/following', { params: { page: this.followingCursor } @@ -1121,7 +1057,7 @@ }, followersLoadMore() { - axios.get('/api/v1/accounts/'+this.profile.id+'/followers', { + axios.get('/api/pixelfed/v1/accounts/'+this.profile.id+'/followers', { params: { page: this.followerCursor } @@ -1297,7 +1233,7 @@ if(status.account.id == this.profile.id) { this.$refs.ctxModal.show(); } else { - axios.get('/api/v1/accounts/relationships', { + axios.get('/api/pixelfed/v1/accounts/relationships', { params: { 'id[]': status.account.id }