From 0153bb98e2363b59a0e039900b6fc0d4371bd723 Mon Sep 17 00:00:00 2001 From: Mary Kate Date: Thu, 10 Sep 2020 15:27:41 -0500 Subject: [PATCH] chat show style cleanup and basic message moderation functions --- src/api/chat.js | 7 +- src/components/ChatMessage/index.vue | 145 ++++++++++++------ src/lang/en.js | 3 + src/store/modules/chat.js | 6 +- src/views/chats/show.vue | 215 ++++++++------------------- 5 files changed, 177 insertions(+), 199 deletions(-) diff --git a/src/api/chat.js b/src/api/chat.js index 7a3bd66c..e37b6a8a 100644 --- a/src/api/chat.js +++ b/src/api/chat.js @@ -2,10 +2,13 @@ import request from '@/utils/request' import { getToken } from '@/utils/auth' import { baseName } from './utils' -export async function deleteChatMessage(id, message_id, authHost, token) { +export async function deleteChatMessage(chat_id, message_id, authHost, token) { + console.log(chat_id) + console.log(message_id) + return await request({ baseURL: baseName(authHost), - url: `/api/pleroma/admin/chats/{id}/messages/${message_id}`, + url: `/api/pleroma/admin/chats/${chat_id}/messages/${message_id}`, method: 'delete', headers: authHeaders(token) }) diff --git a/src/components/ChatMessage/index.vue b/src/components/ChatMessage/index.vue index 400ec205..2e6a05cb 100644 --- a/src/components/ChatMessage/index.vue +++ b/src/components/ChatMessage/index.vue @@ -1,28 +1,57 @@ diff --git a/src/lang/en.js b/src/lang/en.js index 76f8b879..bd60ce52 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -382,6 +382,7 @@ export default { unlisted: 'Make status unlisted', sensitive: 'Sensitive', deleteStatus: 'Delete status', + deleteMessage: 'Delete message', reportOn: 'Report on', reportsOn: 'Reports on', id: 'ID', @@ -391,6 +392,8 @@ export default { content: 'Content', reportedStatus: 'Reported status', statusDeleted: 'This status has been deleted', + messageDeleted: 'This message has been deleted', + messageModeration: 'Message options', leaveNote: 'Leave a note', postNote: 'Send', deleteNote: 'Delete', diff --git a/src/store/modules/chat.js b/src/store/modules/chat.js index 5a78093f..29c993fc 100644 --- a/src/store/modules/chat.js +++ b/src/store/modules/chat.js @@ -1,4 +1,4 @@ -import { fetchChat, fetchChatMessages } from '@/api/chat' +import { fetchChat, fetchChatMessages, deleteChatMessage } from '@/api/chat' const chat = { state: { @@ -30,6 +30,10 @@ const chat = { const chat = await fetchChatMessages(id, getters.authHost, getters.token) commit('SET_CHAT_MESSAGES', chat.data) commit('SET_LOADING', false) + }, + async DeleteMessage({ commit, dispatch, getters, state }, params) { + await deleteChatMessage(params.chat_id, params.message_id, getters.authHost, getters.token) + dispatch('FetchChatMessages', params.chat_id) } } } diff --git a/src/views/chats/show.vue b/src/views/chats/show.vue index 5ca80032..74603fa9 100644 --- a/src/views/chats/show.vue +++ b/src/views/chats/show.vue @@ -1,49 +1,47 @@