diff --git a/src/store/modules/status.js b/src/store/modules/status.js index a287f94b..15d1f1f7 100644 --- a/src/store/modules/status.js +++ b/src/store/modules/status.js @@ -2,13 +2,21 @@ import { changeStatusScope, deleteStatus } from '@/api/status' const status = { actions: { - async ChangeStatusScope({ dispatch, getters, state }, { statusId, isSensitive, visibility }) { + async ChangeStatusScope({ dispatch, getters }, { statusId, isSensitive, visibility, reportCurrentPage, userId, godmode }) { await changeStatusScope(statusId, isSensitive, visibility, getters.authHost, getters.token) - dispatch('FetchReports', state.currentPage) + if (reportCurrentPage !== 0) { + dispatch('FetchReports', reportCurrentPage) + } else if (userId.length > 0) { + dispatch('FetchUserStatuses', { userId, godmode }) + } }, - async DeleteStatus({ dispatch, getters, state }, { statusId }) { + async DeleteStatus({ dispatch, getters }, { statusId, reportCurrentPage, userId, godmode }) { await deleteStatus(statusId, getters.authHost, getters.token) - dispatch('FetchReports', state.currentPage) + if (reportCurrentPage !== 0) { + dispatch('FetchReports', reportCurrentPage) + } else if (userId.length > 0) { + dispatch('FetchUserStatuses', { userId, godmode }) + } } } } diff --git a/src/store/modules/userProfile.js b/src/store/modules/userProfile.js index 2dd656e6..5a7e4394 100644 --- a/src/store/modules/userProfile.js +++ b/src/store/modules/userProfile.js @@ -2,33 +2,42 @@ import { fetchUser, fetchUserStatuses } from '@/api/users' const userProfile = { state: { + statuses: [], + statusesLoading: true, user: {}, - loading: true, - statuses: [] + userProfileLoading: true }, mutations: { + SET_STATUSES: (state, statuses) => { + state.statuses = statuses + }, + SET_STATUSES_LOADING: (state, status) => { + state.statusesLoading = status + }, SET_USER: (state, user) => { state.user = user }, - SET_LOADING: (state, status) => { - state.loading = status - }, - SET_STATUSES: (state, statuses) => { - state.statuses = statuses + SET_USER_PROFILE_LOADING: (state, status) => { + state.userProfileLoading = status } }, actions: { - async FetchData({ commit, getters }, { id, godmode }) { - commit('SET_LOADING', true) - - const [userResponse, statusesResponse] = await Promise.all([ - fetchUser(id, getters.authHost, getters.token), - fetchUserStatuses(id, getters.authHost, godmode, getters.token) - ]) + async FetchUserProfile({ commit, dispatch, getters }, { userId, godmode }) { + commit('SET_USER_PROFILE_LOADING', true) + const userResponse = await fetchUser(userId, getters.authHost, getters.token) commit('SET_USER', userResponse.data) - commit('SET_STATUSES', statusesResponse.data) - commit('SET_LOADING', false) + commit('SET_USER_PROFILE_LOADING', false) + + dispatch('FetchUserStatuses', { userId, godmode }) + }, + async FetchUserStatuses({ commit, getters }, { userId, godmode }) { + commit('SET_STATUSES_LOADING', true) + + const statuses = await fetchUserStatuses(userId, getters.authHost, godmode, getters.token) + + commit('SET_STATUSES', statuses.data) + commit('SET_STATUSES_LOADING', false) } } } diff --git a/src/views/reports/components/GroupedReport.vue b/src/views/reports/components/GroupedReport.vue index 43d153f6..dcad3ad9 100644 --- a/src/views/reports/components/GroupedReport.vue +++ b/src/views/reports/components/GroupedReport.vue @@ -41,7 +41,7 @@
{{ $t('reports.reportedStatus') }}: