From 3e4de3327d72aa39dcdaa534fd95931fe0cd2de3 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Fri, 30 Mar 2018 20:01:32 +0900 Subject: [PATCH] refs #120 Add follow/unfollow icon and update following status --- src/renderer/App.vue | 8 ++++-- .../Contents/SideBar/AccountProfile.vue | 25 +++++++++++++++++- .../TimelineSpace/Contents/Favourites.js | 1 + .../Contents/SideBar/AccountProfile.js | 26 +++++++++++++++++-- 4 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 6c0d055e..7b405fa4 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -10,6 +10,10 @@ } - diff --git a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue index 4cefad92..a541f680 100644 --- a/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue +++ b/src/renderer/components/TimelineSpace/Contents/SideBar/AccountProfile.vue @@ -2,6 +2,15 @@
+
@@ -42,7 +51,8 @@ export default { name: 'account-profile', computed: { ...mapState({ - account: state => state.TimelineSpace.Contents.SideBar.AccountProfile.account + account: state => state.TimelineSpace.Contents.SideBar.AccountProfile.account, + relationship: state => state.TimelineSpace.Contents.SideBar.AccountProfile.relationship }) }, methods: { @@ -90,6 +100,19 @@ function findLink (target) { word-wrap: break-word; font-size: 14px; + .follow-follower { + .follower-status { + float: left; + } + .follow-status { + float: right; + + .unfollow { + color: #409eff; + } + } + } + .icon { padding: 12px; diff --git a/src/renderer/store/TimelineSpace/Contents/Favourites.js b/src/renderer/store/TimelineSpace/Contents/Favourites.js index 5a695dcc..83469895 100644 --- a/src/renderer/store/TimelineSpace/Contents/Favourites.js +++ b/src/renderer/store/TimelineSpace/Contents/Favourites.js @@ -67,6 +67,7 @@ const Favourites = { if (err) return reject(err) commit('insertFavourites', data) commit('changeLazyLoading', false) + resolve(res) }) }) } diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js index db88fef2..a838b3ac 100644 --- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js +++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.js @@ -1,16 +1,38 @@ +import Mastodon from 'mastodon-api' + const AccountProfile = { namespaced: true, state: { - account: null + account: null, + relationship: null }, mutations: { changeAccount (state, account) { state.account = account + }, + changeRelationship (state, relationship) { + state.relationship = relationship } }, actions: { - changeAccount ({ commit }, account) { + changeAccount ({ commit, dispatch }, account) { + dispatch('fetchRelationship', account) commit('changeAccount', account) + }, + fetchRelationship ({ state, commit, rootState }, account) { + return new Promise((resolve, reject) => { + commit('changeRelationship', null) + const client = new Mastodon( + { + access_token: rootState.TimelineSpace.account.accessToken, + api_url: rootState.TimelineSpace.account.baseURL + '/api/v1' + }) + client.get('/accounts/relationships', { id: [account.id] }, (err, data, res) => { + if (err) return reject(err) + commit('changeRelationship', data[0]) + resolve(res) + }) + }) } } }