summaryrefslogtreecommitdiffstats
path: root/src/mixins
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-12-03 08:10:43 +0100
committerJulius Härtl <jus@bitgrid.net>2018-12-03 08:10:43 +0100
commit46b05c520029986ee67bcf035abec901729c345f (patch)
tree84fdc7db75b4cb0eb9c935bc3f7e411cfbd3fa76 /src/mixins
parent56fdde1b8b2bb70f8f647a117b19d2c8195ba028 (diff)
Fix following/followers UI bugs
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src/mixins')
-rw-r--r--src/mixins/follow.js40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/mixins/follow.js b/src/mixins/follow.js
index 111ec18e..2a9a3aa9 100644
--- a/src/mixins/follow.js
+++ b/src/mixins/follow.js
@@ -22,13 +22,49 @@
import axios from 'nextcloud-axios'
+class FollowException {
+
+}
+
+class UnfollowException {
+
+}
+
export default {
+ data() {
+ return {
+ followLoading: false
+ }
+ },
methods: {
follow() {
- return axios.put(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + this.item.account))
+ this.followLoading = true
+ return axios.put(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + this.item.account)).then((response) => {
+ this.followLoading = false
+ if (response.data.status === -1) {
+ throw new FollowException()
+ }
+ this.item.details.following = true
+ }).catch((error) => {
+ this.followLoading = false
+ OC.Notification.showTemporary(`Failed to follow user ${this.item.account}`)
+ console.error(`Failed to follow user ${this.item.account}`, error)
+ })
+
},
unfollow() {
- return axios.delete(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + this.item.account))
+ this.followLoading = true
+ return axios.delete(OC.generateUrl('/apps/social/api/v1/current/follow?account=' + this.item.account)).then((response) => {
+ this.followLoading = false
+ if (response.data.status === -1) {
+ throw new UnfollowException()
+ }
+ this.item.details.following = false
+ }).catch((error) => {
+ this.followLoading = false
+ OC.Notification.showTemporary(`Failed to unfollow user ${this.item.account}`)
+ console.error(`Failed to unfollow user ${this.item.account}`, error)
+ })
}
}
}