refs #921 Change loading only modal is opened in new toot

This commit is contained in:
AkiraFukushima 2019-06-27 23:14:31 +09:00
parent c4055095c7
commit c602bd87a4
1 changed files with 13 additions and 3 deletions

View File

@ -141,15 +141,25 @@ const mutations: MutationTree<NewTootState> = {
}
const actions: ActionTree<NewTootState, RootState> = {
setupLoading: ({ commit }) => {
setupLoading: ({ dispatch }) => {
const axiosLoading = new AxiosLoading()
axiosLoading.on('start', (_: number) => {
commit(MUTATION_TYPES.CHANGE_LOADING, true)
dispatch('startLoading')
})
axiosLoading.on('done', () => {
commit(MUTATION_TYPES.CHANGE_LOADING, false)
dispatch('stopLoading')
})
},
startLoading: ({ commit, state }) => {
if (state.modalOpen && !state.loading) {
commit(MUTATION_TYPES.CHANGE_LOADING, true)
}
},
stopLoading: ({ commit, state }) => {
if (state.modalOpen && state.loading) {
commit(MUTATION_TYPES.CHANGE_LOADING, false)
}
},
updateMedia: async ({ rootState }, mediaDescription: MediaDescription) => {
if (rootState.TimelineSpace.account.accessToken === undefined || rootState.TimelineSpace.account.accessToken === null) {
throw new AuthenticationError()