From aba6325b99db638d327fc70a62f199c32d8d1cad Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Wed, 28 Aug 2024 10:50:29 +0200 Subject: [PATCH] feat(NoteToSelf): add tasks counter Signed-off-by: DorraJaouad --- .../MessagesList/MessagesList.spec.js | 3 +- src/components/MessagesList/MessagesList.vue | 22 ++++++- src/components/TopBar/TasksCounter.vue | 60 +++++++++++++++++++ src/components/TopBar/TopBar.vue | 7 +++ src/stores/chatExtras.js | 7 +++ 5 files changed, 95 insertions(+), 4 deletions(-) create mode 100644 src/components/TopBar/TasksCounter.vue diff --git a/src/components/MessagesList/MessagesList.spec.js b/src/components/MessagesList/MessagesList.spec.js index 80372bc4a0a..a716f4fa461 100644 --- a/src/components/MessagesList/MessagesList.spec.js +++ b/src/components/MessagesList/MessagesList.spec.js @@ -4,6 +4,7 @@ */ import { createLocalVue, shallowMount } from '@vue/test-utils' import { cloneDeep } from 'lodash' +import { createPinia, setActivePinia } from 'pinia' import Vuex from 'vuex' import MessagesList from './MessagesList.vue' @@ -23,7 +24,7 @@ describe('MessagesList.vue', () => { beforeEach(() => { localVue = createLocalVue() localVue.use(Vuex) - + setActivePinia(createPinia()) testStoreConfig = cloneDeep(storeConfig) testStoreConfig.modules.messagesStore.getters.getVisualLastReadMessageId = jest.fn().mockReturnValue(getVisualLastReadMessageIdMock) diff --git a/src/components/MessagesList/MessagesList.vue b/src/components/MessagesList/MessagesList.vue index 91d99f45f54..97b826c3acf 100644 --- a/src/components/MessagesList/MessagesList.vue +++ b/src/components/MessagesList/MessagesList.vue @@ -76,8 +76,9 @@ import LoadingPlaceholder from '../UIShared/LoadingPlaceholder.vue' import TransitionWrapper from '../UIShared/TransitionWrapper.vue' import { useIsInCall } from '../../composables/useIsInCall.js' -import { ATTENDEE, CHAT } from '../../constants.js' +import { ATTENDEE, CHAT, CONVERSATION } from '../../constants.js' import { EventBus } from '../../services/EventBus.js' +import { useChatExtrasStore } from '../../stores/chatExtras.js' import { debugTimer } from '../../utils/debugTimer.ts' export default { @@ -119,9 +120,9 @@ export default { emits: ['update:is-chat-scrolled-to-bottom'], setup() { - const isInCall = useIsInCall() return { - isInCall, + isInCall: useIsInCall(), + chatExtrasStore: useChatExtrasStore(), } }, @@ -289,6 +290,12 @@ export default { // scroll to bottom if needed this.scrollToBottom({ smooth: true }) + + if (this.conversation?.type === CONVERSATION.TYPE.NOTE_TO_SELF) { + this.$nextTick(() => { + this.updateTasksCount() + }) + } }, }, }, @@ -1238,6 +1245,15 @@ export default { // scroll down by the height difference this.$refs.scroller.scrollTop += heightDiff }, + + updateTasksCount() { + if (!this.$refs.scroller) { + return + } + const tasksDoneCount = this.$refs.scroller.querySelectorAll('.checkbox-content__icon--checked')?.length + const tasksCount = this.$refs.scroller.querySelectorAll('.task-list-item')?.length + this.chatExtrasStore.setTasksCounters({ tasksCount, tasksDoneCount }) + }, }, } diff --git a/src/components/TopBar/TasksCounter.vue b/src/components/TopBar/TasksCounter.vue new file mode 100644 index 00000000000..6f28d8f7f09 --- /dev/null +++ b/src/components/TopBar/TasksCounter.vue @@ -0,0 +1,60 @@ + + + + + + + diff --git a/src/components/TopBar/TopBar.vue b/src/components/TopBar/TopBar.vue index 6038baa3231..fbc57b98c88 100644 --- a/src/components/TopBar/TopBar.vue +++ b/src/components/TopBar/TopBar.vue @@ -46,6 +46,9 @@ + + +