mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-09 08:18:44 +01:00
refs #183 Add loading when follow/unfollow
This commit is contained in:
parent
7f97158ffb
commit
d79871ca09
@ -1,5 +1,9 @@
|
||||
<template>
|
||||
<div id="account_profile">
|
||||
<div id="account_profile"
|
||||
v-loading="loading"
|
||||
element-loading-text="Loading..."
|
||||
element-loading-spinner="el-icon-loading"
|
||||
element-loading-background="rgba(0, 0, 0, 0.8)">
|
||||
<div class="header-background" v-bind:style="{ backgroundImage: 'url(' + account.header + ')' }">
|
||||
<div class="header">
|
||||
<div class="follow-follower" v-if="relationship !== null && relationship !== ''">
|
||||
@ -58,7 +62,8 @@ export default {
|
||||
computed: {
|
||||
...mapState({
|
||||
account: state => state.TimelineSpace.Contents.SideBar.AccountProfile.account,
|
||||
relationship: state => state.TimelineSpace.Contents.SideBar.AccountProfile.relationship
|
||||
relationship: state => state.TimelineSpace.Contents.SideBar.AccountProfile.relationship,
|
||||
loading: state => state.TimelineSpace.Contents.SideBar.AccountProfile.loading
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
|
@ -4,7 +4,8 @@ const AccountProfile = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
account: null,
|
||||
relationship: null
|
||||
relationship: null,
|
||||
loading: false
|
||||
},
|
||||
mutations: {
|
||||
changeAccount (state, account) {
|
||||
@ -12,6 +13,9 @@ const AccountProfile = {
|
||||
},
|
||||
changeRelationship (state, relationship) {
|
||||
state.relationship = relationship
|
||||
},
|
||||
changeLoading (state, value) {
|
||||
state.loading = value
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@ -36,12 +40,14 @@ const AccountProfile = {
|
||||
},
|
||||
follow ({ state, commit, rootState }, account) {
|
||||
return new Promise((resolve, reject) => {
|
||||
commit('changeLoading', true)
|
||||
const client = new Mastodon(
|
||||
{
|
||||
access_token: rootState.TimelineSpace.account.accessToken,
|
||||
api_url: rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
})
|
||||
client.post(`/accounts/${account.id}/follow`, {}, (err, data, res) => {
|
||||
commit('changeLoading', false)
|
||||
if (err) return reject(err)
|
||||
commit('changeRelationship', data)
|
||||
resolve(res)
|
||||
@ -50,12 +56,14 @@ const AccountProfile = {
|
||||
},
|
||||
unfollow ({ state, commit, rootState }, account) {
|
||||
return new Promise((resolve, reject) => {
|
||||
commit('changeLoading', true)
|
||||
const client = new Mastodon(
|
||||
{
|
||||
access_token: rootState.TimelineSpace.account.accessToken,
|
||||
api_url: rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
})
|
||||
client.post(`/accounts/${account.id}/unfollow`, {}, (err, data, res) => {
|
||||
commit('changeLoading', false)
|
||||
if (err) return reject(err)
|
||||
commit('changeRelationship', data)
|
||||
resolve(res)
|
||||
|
Loading…
x
Reference in New Issue
Block a user