Add api function and action to fetch statuses

This commit is contained in:
Angelina Filippova 2020-02-27 22:25:50 +03:00
parent 5293260870
commit d611c7d0e5
5 changed files with 28 additions and 9 deletions

View file

@ -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

View file

@ -21,6 +21,15 @@ export async function deleteStatus(id, authHost, token) {
})
}
export async function fetchStatuses({ godmode, localOnly, authHost, token }) {
return await request({
baseURL: baseName(authHost),
url: `/api/pleroma/admin/statuses?godmode=${godmode}&local_only=${localOnly}`,
method: 'get',
headers: authHeaders(token)
})
}
export async function fetchStatusesByInstance({ instance, authHost, token, pageSize, page }) {
return await request({
baseURL: baseName(authHost),

View file

@ -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

View file

@ -1,4 +1,4 @@
import { changeStatusScope, deleteStatus, fetchStatusesByInstance } from '@/api/status'
import { changeStatusScope, deleteStatus, fetchStatuses, fetchStatusesByInstance } from '@/api/status'
const status = {
state: {
@ -48,6 +48,11 @@ const status = {
dispatch('FetchStatusesByInstance')
}
},
async FetchStatuses({ commit, getters }, { godmode, localOnly }) {
commit('SET_LOADING', true)
await fetchStatuses({ godmode, localOnly, authHost: getters.authHost, token: getters.token })
commit('SET_LOADING', false)
},
async FetchStatusesByInstance({ commit, getters, state }) {
commit('SET_LOADING', true)
const statuses = state.statusesByInstance.selectedInstance === ''

View file

@ -36,7 +36,6 @@
</template>
<script>
import { mapGetters } from 'vuex'
import MultipleUsersMenu from '@/views/users/components/MultipleUsersMenu'
import Status from '@/components/Status'
@ -52,10 +51,9 @@ export default {
}
},
computed: {
...mapGetters([
'instances',
'statuses'
]),
instances() {
return ['Local statuses', ...this.$store.state.peers.fetchedPeers]
},
isDesktop() {
return this.$store.state.app.device === 'desktop'
},
@ -75,6 +73,9 @@ export default {
set(instance) {
this.$store.dispatch('HandleFilterChange', instance)
}
},
statuses() {
return this.$store.state.status.fetchedStatuses
}
},
mounted() {