From 2c50d0f744bd395fbaf509dfad7ab83b609e837d Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Wed, 7 Aug 2019 22:14:37 +0900
Subject: [PATCH] refs #985 Move account suggest logic to vuex
---
.../components/TimelineSpace/Modals/NewToot/Status.vue | 6 +-----
.../store/TimelineSpace/Modals/NewToot/Status.ts | 9 ++++++++-
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/renderer/components/TimelineSpace/Modals/NewToot/Status.vue b/src/renderer/components/TimelineSpace/Modals/NewToot/Status.vue
index 551d8b3f..160e8c08 100644
--- a/src/renderer/components/TimelineSpace/Modals/NewToot/Status.vue
+++ b/src/renderer/components/TimelineSpace/Modals/NewToot/Status.vue
@@ -162,11 +162,7 @@ export default {
},
async suggestAccount(start, word) {
try {
- await this.$store.dispatch('TimelineSpace/Modals/NewToot/Status/searchAccount', word)
- this.$store.commit('TimelineSpace/Modals/NewToot/Status/changeOpenSuggest', true)
- this.$store.commit('TimelineSpace/Modals/NewToot/Status/changeStartIndex', start)
- this.$store.commit('TimelineSpace/Modals/NewToot/Status/changeMatchWord', word)
- this.$store.commit('TimelineSpace/Modasl/NewToot/Status/filteredSuggestionFromAccounts')
+ await this.$store.dispatch('TimelineSpace/Modals/NewToot/Status/suggestAccount', { word: word, start: start })
return true
} catch (err) {
console.log(err)
diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts
index d74ac798..75475122 100644
--- a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts
+++ b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts
@@ -94,11 +94,18 @@ type WordStart = {
}
const actions: ActionTree = {
- searchAccount: async ({ commit, rootState }, word: string) => {
+ suggestAccount: async ({ commit, rootState }, wordStart: WordStart) => {
+ commit(MUTATION_TYPES.CLEAR_FILTERED_ACCOUNTS)
+ commit(MUTATION_TYPES.FILTERED_SUGGESTION_FROM_ACCOUNTS)
+ const { word, start } = wordStart
const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response = await client.get('/search', { q: word, resolve: false })
commit(MUTATION_TYPES.UPDATE_FILTERED_ACCOUNTS, res.data.accounts)
if (res.data.accounts.length === 0) throw new Error('Empty')
+ commit(MUTATION_TYPES.CHANGE_OPEN_SUGGEST, true)
+ commit(MUTATION_TYPES.CHANGE_START_INDEX, start)
+ commit(MUTATION_TYPES.CHANGE_MATCH_WORD, word)
+ commit(MUTATION_TYPES.FILTERED_SUGGESTION_FROM_ACCOUNTS)
return res.data.accounts
},
suggestHashtag: async ({ commit, rootState }, wordStart: WordStart) => {