From 566d0fef5fdb64a2a247cee63fcedb91525bffd3 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Fri, 28 Feb 2020 23:42:16 +0300 Subject: [PATCH] Show current instance's statuses --- src/store/modules/status.js | 38 +++++++++++++++++++++++------------- src/views/statuses/index.vue | 3 ++- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/store/modules/status.js b/src/store/modules/status.js index 7f547d34..0760f87d 100644 --- a/src/store/modules/status.js +++ b/src/store/modules/status.js @@ -50,23 +50,33 @@ const status = { }, async FetchStatuses({ commit, getters }, { godmode, localOnly }) { commit('SET_LOADING', true) - await fetchStatuses({ godmode, localOnly, authHost: getters.authHost, token: getters.token }) + const statuses = await fetchStatuses({ godmode, localOnly, authHost: getters.authHost, token: getters.token }) + commit('SET_STATUSES_BY_INSTANCE', statuses.data) commit('SET_LOADING', false) }, - async FetchStatusesByInstance({ commit, getters, state }) { + async FetchStatusesByInstance({ commit, getters, state, rootState }) { commit('SET_LOADING', true) - const statuses = state.statusesByInstance.selectedInstance === '' - ? { data: [] } - : await fetchStatusesByInstance( - { - instance: state.statusesByInstance.selectedInstance, - authHost: getters.authHost, - token: getters.token, - pageSize: state.statusesByInstance.pageSize, - page: state.statusesByInstance.page - }) - - commit('SET_STATUSES_BY_INSTANCE', statuses.data) + if (state.statusesByInstance.selectedInstance === '') { + commit('SET_STATUSES_BY_INSTANCE', []) + } else { + const statuses = state.statusesByInstance.selectedInstance === rootState.user.authHost + ? await fetchStatuses( + { + godmode: false, + localOnly: false, + authHost: getters.authHost, + token: getters.token + }) + : await fetchStatusesByInstance( + { + instance: state.statusesByInstance.selectedInstance, + authHost: getters.authHost, + token: getters.token, + pageSize: state.statusesByInstance.pageSize, + page: state.statusesByInstance.page + }) + commit('SET_STATUSES_BY_INSTANCE', statuses.data) + } commit('SET_LOADING', false) }, async FetchStatusesPageByInstance({ commit, getters, state }) { diff --git a/src/views/statuses/index.vue b/src/views/statuses/index.vue index 7ecd649f..fe9d9345 100644 --- a/src/views/statuses/index.vue +++ b/src/views/statuses/index.vue @@ -22,6 +22,7 @@ :selected-users="selectedUsers" @apply-action="clearSelection"/> +

{{ $t('userProfile.noStatuses') }}