diff --git a/src/api/users.js b/src/api/users.js index 9084c566..1d9c5551 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -22,6 +22,15 @@ export async function addRight(nicknames, right, authHost, token) { }) } +export async function fetchUserChats(id, authHost, token) { + return await request({ + baseURL: baseName(authHost), + url: `/api/pleroma/admin/users/${id}/chats`, + method: 'get', + headers: authHeaders(token) + }) +} + export async function approveUserAccount(nicknames, authHost, token) { return await request({ baseURL: baseName(authHost), diff --git a/src/lang/en.js b/src/lang/en.js index 378dbd79..a3d6ce02 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -309,6 +309,7 @@ export default { actorType: 'Actor Type', nickname: 'Nickname', recentStatuses: 'Recent Statuses', + chats: 'Chats', roles: 'Roles', active: 'Active', status: 'Status', @@ -316,6 +317,7 @@ export default { deactivated: 'Deactivated', pending: 'Pending', noStatuses: 'No statuses to show', + noChats: 'No chats to show', openAccountInInstance: 'Open account in instance', securitySettings: { email: 'Email', diff --git a/src/store/modules/userProfile.js b/src/store/modules/userProfile.js index 0cdc0df6..40af065c 100644 --- a/src/store/modules/userProfile.js +++ b/src/store/modules/userProfile.js @@ -1,9 +1,11 @@ -import { fetchUser, fetchUserStatuses, fetchUserCredentials, updateUserCredentials } from '@/api/users' +import { fetchUser, fetchUserStatuses, fetchUserChats, fetchUserCredentials, updateUserCredentials } from '@/api/users' const userProfile = { state: { statuses: [], statusesLoading: true, + chats: [], + chatsLoading: true, user: {}, userCredentials: {}, userProfileLoading: true @@ -15,6 +17,12 @@ const userProfile = { SET_STATUSES_LOADING: (state, status) => { state.statusesLoading = status }, + SET_CHATS: (state, chats) => { + state.chats = chats + }, + SET_CHATS_LOADING: (state, chat) => { + state.chatsLoading = chat + }, SET_USER: (state, user) => { state.user = user }, @@ -34,6 +42,7 @@ const userProfile = { commit('SET_USER_PROFILE_LOADING', false) dispatch('FetchUserStatuses', { userId, godmode }) + dispatch('FetchUserChats', { userId }) }, FetchUserStatuses({ commit, dispatch, getters }, { userId, godmode }) { commit('SET_STATUSES_LOADING', true) @@ -43,6 +52,14 @@ const userProfile = { commit('SET_STATUSES_LOADING', false) }, + FetchUserChats({ commit, dispatch, getters }, { userId }) { + commit('SET_CHATS_LOADING', true) + + fetchUserChats(userId, getters.authHost, getters.token) + .then(chats => dispatch('SetChats', chats.data)) + + commit('SET_CHATS_LOADING', false) + }, async FetchUserCredentials({ commit, getters }, { nickname }) { const userResponse = await fetchUserCredentials(nickname, getters.authHost, getters.token) commit('SET_USER_CREDENTIALS', userResponse.data) @@ -50,6 +67,9 @@ const userProfile = { SetStatuses({ commit }, statuses) { commit('SET_STATUSES', statuses) }, + SetChats({ commit }, chats) { + commit('SET_CHATS', chats) + }, async UpdateUserCredentials({ dispatch, getters }, { nickname, credentials }) { await updateUserCredentials(nickname, credentials, getters.authHost, getters.token) dispatch('FetchUserCredentials', { nickname }) diff --git a/src/views/users/show.vue b/src/views/users/show.vue index 5aa21038..34bd8e32 100644 --- a/src/views/users/show.vue +++ b/src/views/users/show.vue @@ -37,78 +37,97 @@ :reset-password-dialog-open="resetPasswordDialogOpen" @close-reset-token-dialog="closeResetPasswordDialog"/>