fix: users/instances statuses api response data
This commit is contained in:
parent
7c59e85e4f
commit
16ab9d234c
4 changed files with 16 additions and 14 deletions
|
@ -30,9 +30,9 @@ export async function fetchStatus(id, authHost, token) {
|
|||
}
|
||||
|
||||
export async function fetchStatusesByInstance({ instance, authHost, token, pageSize, page }) {
|
||||
let data
|
||||
let activities, total
|
||||
if (pageSize === 1) {
|
||||
data = page === 1 || page === 2
|
||||
activities = page === 1 || page === 2
|
||||
? [{
|
||||
'account': {
|
||||
'avatar': 'http://localhost:4000/images/avi.png',
|
||||
|
@ -47,8 +47,9 @@ export async function fetchStatusesByInstance({ instance, authHost, token, pageS
|
|||
'visibility': 'unlisted'
|
||||
}]
|
||||
: []
|
||||
total = 1
|
||||
} else {
|
||||
data = [
|
||||
activities = [
|
||||
{
|
||||
'account': {
|
||||
'avatar': 'http://localhost:4000/images/avi.png',
|
||||
|
@ -75,8 +76,9 @@ export async function fetchStatusesByInstance({ instance, authHost, token, pageS
|
|||
'url': 'http://localhost:4000/objects/449c90fe-c457-4c64-baf2-fe6d0a59ca25',
|
||||
'visibility': 'unlisted'
|
||||
}]
|
||||
total = 2
|
||||
}
|
||||
return Promise.resolve({ data })
|
||||
return Promise.resolve({ data: { activities, total }})
|
||||
}
|
||||
|
||||
export async function fetchStatusesCount(instance, authHost, token) {
|
||||
|
|
|
@ -34,7 +34,7 @@ export async function fetchUsers(filters, actorTypeFilters, authHost, token, pag
|
|||
}
|
||||
|
||||
export async function fetchUserStatuses(id, authHost, godmode, token) {
|
||||
return Promise.resolve({ data: userStatuses })
|
||||
return Promise.resolve({ data: { activities: userStatuses, total: userStatuses.length }})
|
||||
}
|
||||
|
||||
export async function fetchUserChats(id, authHost, godmode, token) {
|
||||
|
|
|
@ -122,7 +122,7 @@ const status = {
|
|||
token: getters.token,
|
||||
pageSize: state.statusesByInstance.pageSize,
|
||||
page: state.statusesByInstance.page
|
||||
})
|
||||
}).then(res => res.data)
|
||||
: await fetchStatusesByInstance(
|
||||
{
|
||||
instance: state.statusesByInstance.selectedInstance,
|
||||
|
@ -130,9 +130,9 @@ const status = {
|
|||
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) {
|
||||
}).then(res => res.data.activities)
|
||||
commit('SET_STATUSES_BY_INSTANCE', statuses)
|
||||
if (statuses.length < state.statusesByInstance.pageSize) {
|
||||
commit('SET_ALL_LOADED', true)
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ const status = {
|
|||
token: getters.token,
|
||||
pageSize: state.statusesByInstance.pageSize,
|
||||
page: state.statusesByInstance.page
|
||||
})
|
||||
}).then(res => res.data)
|
||||
: await fetchStatusesByInstance(
|
||||
{
|
||||
instance: state.statusesByInstance.selectedInstance,
|
||||
|
@ -157,10 +157,10 @@ const status = {
|
|||
token: getters.token,
|
||||
pageSize: state.statusesByInstance.pageSize,
|
||||
page: state.statusesByInstance.page
|
||||
})
|
||||
commit('PUSH_STATUSES', statuses.data)
|
||||
}).then(res => res.data.activities)
|
||||
commit('PUSH_STATUSES', statuses)
|
||||
commit('SET_BUTTON_LOADING', false)
|
||||
if (statuses.data.length < state.statusesByInstance.pageSize) {
|
||||
if (statuses.length < state.statusesByInstance.pageSize) {
|
||||
commit('SET_ALL_LOADED', true)
|
||||
}
|
||||
},
|
||||
|
|
|
@ -48,7 +48,7 @@ const userProfile = {
|
|||
commit('SET_STATUSES_LOADING', true)
|
||||
|
||||
fetchUserStatuses(userId, getters.authHost, godmode, getters.token)
|
||||
.then(statuses => dispatch('SetStatuses', statuses.data))
|
||||
.then(res => dispatch('SetStatuses', res.data.activities))
|
||||
|
||||
commit('SET_STATUSES_LOADING', false)
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue