feat: update provider
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user