mirror of
https://github.com/lingble/chatwoot.git
synced 2026-01-11 14:55:35 +00:00
# Pull Request Template ## Description Replaces the messageMixin with the new useMessage composable Fixes https://linear.app/chatwoot/issue/CW-3475/rewrite-messagemixin-mixin-to-a-composable ## Type of change Please delete options that are not relevant. - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected) - [ ] This change requires a documentation update
23 lines
628 B
JavaScript
23 lines
628 B
JavaScript
import { computed } from 'vue';
|
|
|
|
/**
|
|
* Composable for handling message-related computations.
|
|
* @param {Object} message - The message object to be processed.
|
|
* @returns {Object} An object containing computed properties for message content and attachments.
|
|
*/
|
|
export function useMessage(message) {
|
|
const messageContentAttributes = computed(() => {
|
|
const { content_attributes: attribute = {} } = message;
|
|
return attribute;
|
|
});
|
|
|
|
const hasAttachments = computed(() => {
|
|
return !!(message.attachments && message.attachments.length > 0);
|
|
});
|
|
|
|
return {
|
|
messageContentAttributes,
|
|
hasAttachments,
|
|
};
|
|
}
|