feat: update provider

This commit is contained in:
Shivam Mishra
2024-12-11 17:39:22 +05:30
parent 7f2b6019f9
commit 777747b237
@@ -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 <Message /> 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) {