From 6eedb80dbbc02c77a596d78dbbdb42cae89b8549 Mon Sep 17 00:00:00 2001 From: Angelina Filippova Date: Mon, 2 Mar 2020 22:36:54 +0300 Subject: [PATCH] Add success button when all statuses were loaded --- src/store/modules/status.js | 16 +++++++++++++--- src/views/statuses/index.vue | 6 +++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/store/modules/status.js b/src/store/modules/status.js index 7e3663fe..ae0e054c 100644 --- a/src/store/modules/status.js +++ b/src/store/modules/status.js @@ -9,8 +9,9 @@ const status = { showLocal: false, showPrivate: false, page: 1, - pageSize: 30, - buttonLoading: false + pageSize: 1, + buttonLoading: false, + allLoaded: false } }, mutations: { @@ -32,6 +33,9 @@ const status = { PUSH_STATUSES: (state, statuses) => { state.fetchedStatuses = [...state.fetchedStatuses, ...statuses] }, + SET_ALL_LOADED: (state, status) => { + state.statusesByInstance.allLoaded = status + }, SET_BUTTON_LOADING: (state, status) => { state.statusesByInstance.buttonLoading = status }, @@ -82,6 +86,9 @@ const status = { page: state.statusesByInstance.page }) commit('SET_STATUSES_BY_INSTANCE', statuses.data) + if (statuses.data.length < state.statusesByInstance.pageSize) { + commit('SET_ALL_LOADED', true) + } } commit('SET_LOADING', false) }, @@ -95,9 +102,11 @@ const status = { pageSize: state.statusesByInstance.pageSize, page: state.statusesByInstance.page }) - commit('PUSH_STATUSES', statuses.data) commit('SET_BUTTON_LOADING', false) + if (statuses.data.length < state.statusesByInstance.pageSize) { + commit('SET_ALL_LOADED', true) + } }, HandleGodmodeCheckboxChange({ commit, dispatch }, value) { commit('CHANGE_GODMODE_CHECKBOX_VALUE', value) @@ -109,6 +118,7 @@ const status = { }, HandleFilterChange({ commit }, instance) { commit('CHANGE_SELECTED_INSTANCE', instance) + commit('SET_ALL_LOADED', false) }, HandlePageChange({ commit }, page) { commit('CHANGE_PAGE', page) diff --git a/src/views/statuses/index.vue b/src/views/statuses/index.vue index 29187df7..05e4a73f 100644 --- a/src/views/statuses/index.vue +++ b/src/views/statuses/index.vue @@ -39,7 +39,8 @@ @status-selection="handleStatusSelection" />
- {{ $t('statuses.loadMore') }} + {{ $t('statuses.loadMore') }} +
@@ -60,6 +61,9 @@ export default { } }, computed: { + allLoaded() { + return this.$store.state.status.statusesByInstance.allLoaded + }, buttonLoading() { return this.$store.state.status.statusesByInstance.buttonLoading },