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) {