Implemented local users filtration in fetch and search requests
This commit is contained in:
parent
de13254f0a
commit
7652bfcd58
2 changed files with 11 additions and 24 deletions
|
@ -1,8 +1,8 @@
|
||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
export async function fetchUsers(page = 1) {
|
export async function fetchUsers(page = 1, showLocalUsers) {
|
||||||
return await request({
|
return await request({
|
||||||
url: `/api/pleroma/admin/users?page=${page}`,
|
url: `/api/pleroma/admin/users?page=${page}&local_only=${showLocalUsers}`,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,9 @@ export async function toggleUserActivation(nickname) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function searchUsers(query, page = 1) {
|
export async function searchUsers(query, page = 1, showLocalUsers) {
|
||||||
return await request({
|
return await request({
|
||||||
url: `/api/pleroma/admin/users?query=${query}&page=${page}`,
|
url: `/api/pleroma/admin/users?query=${query}&page=${page}&local_only=${showLocalUsers}`,
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function fetchLocalUsers(page = 1) {
|
|
||||||
return await request({
|
|
||||||
url: `/api/pleroma/admin/users?page=${page}&local_only=true`,
|
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { fetchUsers, toggleUserActivation, searchUsers, fetchLocalUsers } from '@/api/users'
|
import { fetchUsers, toggleUserActivation, searchUsers } from '@/api/users'
|
||||||
|
|
||||||
const user = {
|
const user = {
|
||||||
state: {
|
state: {
|
||||||
|
@ -42,8 +42,8 @@ const user = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
async FetchUsers({ commit }, { page }) {
|
async FetchUsers({ commit, state }, { page }) {
|
||||||
const response = await fetchUsers(page)
|
const response = await fetchUsers(page, state.showLocalUsers)
|
||||||
|
|
||||||
commit('SET_LOADING', true)
|
commit('SET_LOADING', true)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ const user = {
|
||||||
|
|
||||||
commit('SWAP_USER', response.data)
|
commit('SWAP_USER', response.data)
|
||||||
},
|
},
|
||||||
async SearchUsers({ commit, dispatch }, { query, page }) {
|
async SearchUsers({ commit, dispatch, state }, { query, page }) {
|
||||||
if (query.length === 0) {
|
if (query.length === 0) {
|
||||||
commit('SET_SEARCH_QUERY', query)
|
commit('SET_SEARCH_QUERY', query)
|
||||||
dispatch('FetchUsers', page)
|
dispatch('FetchUsers', page)
|
||||||
|
@ -62,20 +62,14 @@ const user = {
|
||||||
commit('SET_LOADING', true)
|
commit('SET_LOADING', true)
|
||||||
commit('SET_SEARCH_QUERY', query)
|
commit('SET_SEARCH_QUERY', query)
|
||||||
|
|
||||||
const response = await searchUsers(query, page)
|
const response = await searchUsers(query, page, state.showLocalUsers)
|
||||||
|
|
||||||
loadUsers(commit, page, response.data)
|
loadUsers(commit, page, response.data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async ToggleLocalUsersFilter({ commit, dispatch }, value) {
|
async ToggleLocalUsersFilter({ commit, dispatch, state }, value) {
|
||||||
commit('SET_LOCAL_USERS_FILTER', value)
|
commit('SET_LOCAL_USERS_FILTER', value)
|
||||||
|
dispatch('SearchUsers', { query: state.searchQuery, page: 1 })
|
||||||
if (value) {
|
|
||||||
const response = await fetchLocalUsers()
|
|
||||||
loadUsers(commit, 1, response.data)
|
|
||||||
} else {
|
|
||||||
dispatch('FetchUsers', 1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue