From 777747b23761d2150d30b953b7eceb691321e6b2 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Wed, 11 Dec 2024 17:39:22 +0530 Subject: [PATCH] feat: update provider --- .../components-next/message/provider.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/components-next/message/provider.js b/app/javascript/dashboard/components-next/message/provider.js index 0cf180964..cf35c6c40 100644 --- a/app/javascript/dashboard/components-next/message/provider.js +++ b/app/javascript/dashboard/components-next/message/provider.js @@ -1,4 +1,7 @@ -import { inject, provide } from 'vue'; +import { inject, provide, computed } from 'vue'; +import { useMapGetter } from 'dashboard/composables/store'; +import { useSnakeCase } from 'dashboard/composables/useTransformKeys'; +import { ATTACHMENT_TYPES } from './constants'; const MessageControl = Symbol('MessageControl'); @@ -8,7 +11,21 @@ export function useMessageContext() { throw new Error(`Component is missing a parent component.`); } - return { ...context }; + const currentChatAttachments = useMapGetter('getSelectedChatAttachments'); + const filteredCurrentChatAttachments = computed(() => { + const attachments = currentChatAttachments.value.filter(attachment => + [ + ATTACHMENT_TYPES.IMAGE, + ATTACHMENT_TYPES.VIDEO, + ATTACHMENT_TYPES.IG_REEL, + ATTACHMENT_TYPES.AUDIO, + ].includes(attachment.file_type) + ); + + return useSnakeCase(attachments); + }); + + return { ...context, filteredCurrentChatAttachments }; } export function provideMessageContext(context) {