From 890a7cdb0c1d5146d45a0b1ab985bc29beaa3986 Mon Sep 17 00:00:00 2001 From: AkiraFukushima Date: Tue, 2 Oct 2018 20:49:37 +0900 Subject: [PATCH] refs #360 Update too max characters if the API responds toot_max_chars --- src/renderer/components/TimelineSpace.vue | 1 + .../components/TimelineSpace/Modals/NewToot.vue | 5 ++++- src/renderer/store/TimelineSpace.js | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/TimelineSpace.vue b/src/renderer/components/TimelineSpace.vue index c3d38367..61d4bf17 100644 --- a/src/renderer/components/TimelineSpace.vue +++ b/src/renderer/components/TimelineSpace.vue @@ -129,6 +129,7 @@ export default { }) this.$store.dispatch('TimelineSpace/startLocalStreaming', account) this.$store.dispatch('TimelineSpace/fetchEmojis', account) + this.$store.dispatch('TimelineSpace/fetchInstance', account) }, handleDrop (e) { e.preventDefault() diff --git a/src/renderer/components/TimelineSpace/Modals/NewToot.vue b/src/renderer/components/TimelineSpace/Modals/NewToot.vue index 7148d413..c11ee779 100644 --- a/src/renderer/components/TimelineSpace/Modals/NewToot.vue +++ b/src/renderer/components/TimelineSpace/Modals/NewToot.vue @@ -71,7 +71,7 @@ - {{ 500 - status.length }} + {{ tootMax - status.length }} {{ $t('modals.new_toot.cancel') }} {{ $t('modals.new_toot.toot') }}
@@ -125,6 +125,9 @@ export default { } } }), + ...mapState('TimelineSpace', { + tootMax: state => state.tootMax + }), ...mapGetters('TimelineSpace/Modals/NewToot', [ 'hashtagInserting' ]), diff --git a/src/renderer/store/TimelineSpace.js b/src/renderer/store/TimelineSpace.js index f50b208c..bd007b2c 100644 --- a/src/renderer/store/TimelineSpace.js +++ b/src/renderer/store/TimelineSpace.js @@ -21,7 +21,8 @@ const TimelineSpace = { username: '' }, loading: false, - emojis: [] + emojis: [], + tootMax: 500 }, mutations: { updateAccount (state, account) { @@ -37,6 +38,13 @@ const TimelineSpace = { image: e.url } }) + }, + updateTootMax (state, value) { + if (value) { + state.tootMax = value + } else { + state.tootMax = 500 + } } }, actions: { @@ -168,6 +176,11 @@ const TimelineSpace = { const data = await Mastodon.get('/custom_emojis', {}, account.baseURL + '/api/v1') commit('updateEmojis', data) return data + }, + async fetchInstance ({ commit }, account) { + const data = await Mastodon.get('/instance', {}, account.baseURL + '/api/v1') + commit('updateTootMax', data.max_toot_chars) + return data } } }