Merge pull request #636 from h3poteto/iss-360

closes #360 Update too max characters if the API responds toot_max_chars
This commit is contained in:
AkiraFukushima 2018-10-02 23:17:47 +09:00 committed by GitHub
commit 6b2efa97d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -129,6 +129,7 @@ export default {
}) })
this.$store.dispatch('TimelineSpace/startLocalStreaming', account) this.$store.dispatch('TimelineSpace/startLocalStreaming', account)
this.$store.dispatch('TimelineSpace/fetchEmojis', account) this.$store.dispatch('TimelineSpace/fetchEmojis', account)
this.$store.dispatch('TimelineSpace/fetchInstance', account)
}, },
handleDrop (e) { handleDrop (e) {
e.preventDefault() e.preventDefault()

View File

@ -71,7 +71,7 @@
<icon name="hashtag"></icon> <icon name="hashtag"></icon>
</el-button> </el-button>
</div> </div>
<span class="text-count">{{ 500 - status.length }}</span> <span class="text-count">{{ tootMax - status.length }}</span>
<el-button @click="closeConfirm(close)">{{ $t('modals.new_toot.cancel') }}</el-button> <el-button @click="closeConfirm(close)">{{ $t('modals.new_toot.cancel') }}</el-button>
<el-button type="primary" @click="toot" v-loading="blockSubmit">{{ $t('modals.new_toot.toot') }}</el-button> <el-button type="primary" @click="toot" v-loading="blockSubmit">{{ $t('modals.new_toot.toot') }}</el-button>
<div class="clearfix"></div> <div class="clearfix"></div>
@ -125,6 +125,9 @@ export default {
} }
} }
}), }),
...mapState('TimelineSpace', {
tootMax: state => state.tootMax
}),
...mapGetters('TimelineSpace/Modals/NewToot', [ ...mapGetters('TimelineSpace/Modals/NewToot', [
'hashtagInserting' 'hashtagInserting'
]), ]),

View File

@ -21,7 +21,8 @@ const TimelineSpace = {
username: '' username: ''
}, },
loading: false, loading: false,
emojis: [] emojis: [],
tootMax: 500
}, },
mutations: { mutations: {
updateAccount (state, account) { updateAccount (state, account) {
@ -37,6 +38,13 @@ const TimelineSpace = {
image: e.url image: e.url
} }
}) })
},
updateTootMax (state, value) {
if (value) {
state.tootMax = value
} else {
state.tootMax = 500
}
} }
}, },
actions: { actions: {
@ -168,6 +176,11 @@ const TimelineSpace = {
const data = await Mastodon.get('/custom_emojis', {}, account.baseURL + '/api/v1') const data = await Mastodon.get('/custom_emojis', {}, account.baseURL + '/api/v1')
commit('updateEmojis', data) commit('updateEmojis', data)
return 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
} }
} }
} }