From a74842843076745d0647bbff8748406e89529b78 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Thu, 21 Nov 2024 18:34:45 +0100 Subject: [PATCH] feat: request tasks and show summary Signed-off-by: Maksim Sukharev --- src/components/NewMessage/NewMessage.vue | 8 + .../NewMessage/NewMessageAbsenceInfo.vue | 2 + .../NewMessage/NewMessageChatSummary.vue | 247 ++++++++++++++++++ src/stores/chatExtras.js | 14 +- 4 files changed, 270 insertions(+), 1 deletion(-) create mode 100644 src/components/NewMessage/NewMessageChatSummary.vue diff --git a/src/components/NewMessage/NewMessage.vue b/src/components/NewMessage/NewMessage.vue index 1f8ee687fd1..caea931afbe 100644 --- a/src/components/NewMessage/NewMessage.vue +++ b/src/components/NewMessage/NewMessage.vue @@ -38,6 +38,8 @@ :user-absence="userAbsence" :display-name="conversation.displayName" /> + +
+ + + + + + + diff --git a/src/stores/chatExtras.js b/src/stores/chatExtras.js index e022fd6c61c..b0600cb7ca3 100644 --- a/src/stores/chatExtras.js +++ b/src/stores/chatExtras.js @@ -6,6 +6,7 @@ import { defineStore } from 'pinia' import Vue from 'vue' +import { t } from '@nextcloud/l10n' import { generateUrl, getBaseUrl } from '@nextcloud/router' import BrowserStorage from '../services/BrowserStorage.js' @@ -71,6 +72,11 @@ export const useChatExtrasStore = defineStore('chatExtras', { hasChatSummaryTaskRequested: (state) => (token) => { return state.chatSummary[token] !== undefined }, + + getChatSummary: (state) => (token) => { + return Object.values(Object(state.chatSummary[token])).map(task => task.summary).join('\n\n') + || t('spreed', 'Error occurred during a summary generation') + }, }, actions: { @@ -280,6 +286,12 @@ export const useChatExtrasStore = defineStore('chatExtras', { } catch (error) { console.error('Error while requesting a summary:', error) } - } + }, + + storeChatSummary(token, fromMessageId, summary) { + if (this.chatSummary[token][fromMessageId]) { + Vue.set(this.chatSummary[token][fromMessageId], 'summary', summary) + } + }, }, })