diff --git a/CHANGELOG.md b/CHANGELOG.md index bfd8927e..bdefcea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## Unreleased + +### Added + +- Ability to see local statuses in Statuses by instance section + ## [2.0] - 2020-02-27 ### Added diff --git a/src/api/status.js b/src/api/status.js index 676cd9dc..37f7e0c2 100644 --- a/src/api/status.js +++ b/src/api/status.js @@ -21,6 +21,15 @@ export async function deleteStatus(id, authHost, token) { }) } +export async function fetchStatuses({ godmode, localOnly, authHost, token, pageSize, page }) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/statuses?godmode=${godmode}&local_only=${localOnly}&page=${page}&page_size=${pageSize}`, + method: 'get', + headers: authHeaders(token) + }) +} + export async function fetchStatusesByInstance({ instance, authHost, token, pageSize, page }) { return await request({ baseURL: baseName(authHost), diff --git a/src/lang/en.js b/src/lang/en.js index 7512ecbf..8b8e9ff7 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -244,7 +244,9 @@ export default { statuses: 'Statuses by instance', instanceFilter: 'Instance filter', loadMore: 'Load more', - noInstances: 'No other instances found' + noInstances: 'No other instances found', + onlyLocalStatuses: 'Show only local statuses', + showPrivateStatuses: 'Show private statuses' }, userProfile: { tags: 'Tags', @@ -255,7 +257,6 @@ export default { localUppercase: 'Local', nickname: 'Nickname', recentStatuses: 'Recent Statuses', - showPrivateStatuses: 'Show private statuses', roles: 'Roles', activeUppercase: 'Active', active: 'active', diff --git a/src/store/getters.js b/src/store/getters.js index d51dbd28..f58f0c6b 100644 --- a/src/store/getters.js +++ b/src/store/getters.js @@ -17,8 +17,6 @@ const getters = { errorLogs: state => state.errorLog.logs, users: state => state.users.fetchedUsers, authHost: state => state.user.authHost, - settings: state => state.settings, - instances: state => state.peers.fetchedPeers, - statuses: state => state.status.fetchedStatuses + settings: state => state.settings } export default getters diff --git a/src/store/modules/status.js b/src/store/modules/status.js index 81e86dba..e0cc5d97 100644 --- a/src/store/modules/status.js +++ b/src/store/modules/status.js @@ -1,4 +1,4 @@ -import { changeStatusScope, deleteStatus, fetchStatusesByInstance } from '@/api/status' +import { changeStatusScope, deleteStatus, fetchStatuses, fetchStatusesByInstance } from '@/api/status' const status = { state: { @@ -6,11 +6,21 @@ const status = { loading: false, statusesByInstance: { selectedInstance: '', + showLocal: false, + showPrivate: false, page: 1, - pageSize: 30 + pageSize: 20, + buttonLoading: false, + allLoaded: false } }, mutations: { + CHANGE_GODMODE_CHECKBOX_VALUE: (state, value) => { + state.statusesByInstance.showPrivate = value + }, + CHANGE_LOCAL_CHECKBOX_VALUE: (state, value) => { + state.statusesByInstance.showLocal = value + }, CHANGE_PAGE: (state, page) => { state.statusesByInstance.page = page }, @@ -23,6 +33,12 @@ 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 + }, SET_LOADING: (state, status) => { state.loading = status } @@ -48,10 +64,48 @@ const status = { dispatch('FetchStatusesByInstance') } }, - async FetchStatusesByInstance({ commit, getters, state }) { + async FetchStatusesByInstance({ commit, getters, state, rootState }) { commit('SET_LOADING', true) - const statuses = state.statusesByInstance.selectedInstance === '' - ? { data: [] } + if (state.statusesByInstance.selectedInstance === '') { + commit('SET_STATUSES_BY_INSTANCE', []) + } else { + const statuses = state.statusesByInstance.selectedInstance === rootState.user.authHost + ? await fetchStatuses( + { + godmode: state.statusesByInstance.showPrivate, + localOnly: state.statusesByInstance.showLocal, + authHost: getters.authHost, + token: getters.token, + pageSize: state.statusesByInstance.pageSize, + page: state.statusesByInstance.page + }) + : 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 (statuses.data.length < state.statusesByInstance.pageSize) { + commit('SET_ALL_LOADED', true) + } + } + commit('SET_LOADING', false) + }, + async FetchStatusesPageByInstance({ commit, getters, rootState, state }) { + commit('SET_BUTTON_LOADING', true) + const statuses = state.statusesByInstance.selectedInstance === rootState.user.authHost + ? await fetchStatuses( + { + godmode: state.statusesByInstance.showPrivate, + localOnly: state.statusesByInstance.showLocal, + authHost: getters.authHost, + token: getters.token, + pageSize: state.statusesByInstance.pageSize, + page: state.statusesByInstance.page + }) : await fetchStatusesByInstance( { instance: state.statusesByInstance.selectedInstance, @@ -60,26 +114,29 @@ const status = { pageSize: state.statusesByInstance.pageSize, page: state.statusesByInstance.page }) - - commit('SET_STATUSES_BY_INSTANCE', statuses.data) - commit('SET_LOADING', false) - }, - async FetchStatusesPageByInstance({ commit, getters, state }) { - commit('SET_LOADING', true) - const statuses = await fetchStatusesByInstance( - { - instance: state.statusesByInstance.selectedInstance, - authHost: getters.authHost, - token: getters.token, - pageSize: state.statusesByInstance.pageSize, - page: state.statusesByInstance.page - }) - commit('PUSH_STATUSES', statuses.data) - commit('SET_LOADING', false) + commit('SET_BUTTON_LOADING', false) + if (statuses.data.length < state.statusesByInstance.pageSize) { + commit('SET_ALL_LOADED', true) + } + }, + HandleGodmodeCheckboxChange({ commit, dispatch }, value) { + dispatch('HandlePageChange', 1) + commit('SET_ALL_LOADED', false) + + commit('CHANGE_GODMODE_CHECKBOX_VALUE', value) + dispatch('FetchStatusesByInstance') + }, + HandleLocalCheckboxChange({ commit, dispatch }, value) { + dispatch('HandlePageChange', 1) + commit('SET_ALL_LOADED', false) + + commit('CHANGE_LOCAL_CHECKBOX_VALUE', value) + dispatch('FetchStatusesByInstance') }, 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 b6fd2019..74e3f55b 100644 --- a/src/views/statuses/index.vue +++ b/src/views/statuses/index.vue @@ -22,6 +22,15 @@ :selected-users="selectedUsers" @apply-action="clearSelection"/> +
+ + {{ $t('statuses.onlyLocalStatuses') }} + + + {{ $t('statuses.showPrivateStatuses') }} + +
+

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

- {{ $t('statuses.loadMore') }} + {{ $t('statuses.loadMore') }} +