From 509f2c1ad6275dca30485eb94a419b4e1ae0471f Mon Sep 17 00:00:00 2001 From: Marco Ambrosini Date: Thu, 22 Jul 2021 15:14:22 +0200 Subject: Add ability to clear conversation history Signed-off-by: Marco Ambrosini --- src/store/conversationsStore.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/store') diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index d31db4097..a4c9f0457 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -35,6 +35,7 @@ import { setConversationName, setConversationDescription, deleteConversation, + clearConversationHistory, setNotificationLevel, } from '../services/conversationsService' import { getCurrentUser } from '@nextcloud/auth' @@ -196,6 +197,25 @@ const actions = { await context.dispatch('deleteConversation', token) }, + /** + * Delete all the messages from a conversation. + * + * @param {object} context default store context; + * @param {object} token the token of the conversation whose history is + * to be cleared; + */ + async clearConversationHistory(context, { token }) { + try { + const response = await clearConversationHistory(token) + context.dispatch('deleteMessages', token) + return response + } catch (error) { + console.debug( + t('spreed', 'Error while clearing conversation history'), + error) + } + }, + /** * Resets the store to it's original state. * @param {object} context default store context; -- cgit v1.2.3