feat: support attachments in bubble

This commit is contained in:
Shivam Mishra
2023-10-10 19:21:45 +05:30
parent d3dd20e4b9
commit 7added2d48
2 changed files with 62 additions and 21 deletions
@@ -37,6 +37,7 @@
<bubble-reply-to
v-if="inReplyToMessageId && inboxSupportsReplyTo"
:content="inReplyTo.content"
:attachments="inReplyTo.attachments"
:default-empty-message="$t('CONVERSATION.REPLY_MESSAGE_NOT_FOUND')"
@click="navigateToMessage"
/>
@@ -1,29 +1,69 @@
<script setup>
import { computed } from 'vue';
import { extractTextFromMarkdown } from 'dashboard/helper/editorHelper';
const props = defineProps({
content: {
type: String,
default: '',
},
defaultEmptyMessage: {
type: String,
required: true,
},
});
const cleanedContent = computed(() => extractTextFromMarkdown(props.content));
</script>
<template>
<div
class="p-2 -mx-2 overflow-hidden rounded-md bg-woot-600 line-clamp-3 min-w-[15rem] mb-2 cursor-pointer"
class="p-2 -mx-2 rounded-md bg-woot-600 min-w-[15rem] mb-2 cursor-pointer"
@click="$emit('click')"
>
<template v-if="content">
<div v-if="content" class="line-clamp-3">
{{ cleanedContent }}
</template>
</div>
<div v-else-if="hasAttachments" class="line-clamp-3">
{{ attachmentLabel }}
</div>
<template v-else> {{ defaultEmptyMessage }} </template>
</div>
</template>
<script>
import { extractTextFromMarkdown } from 'dashboard/helper/editorHelper';
export default {
name: 'ReplyTo',
props: {
content: {
type: String,
default: '',
},
attachments: {
type: Array,
default: () => [],
},
defaultEmptyMessage: {
type: String,
required: true,
},
},
computed: {
cleanedContent() {
return extractTextFromMarkdown(this.content);
},
hasAttachments() {
return this.attachments.length > 0;
},
attachmentLabel() {
if (!this.attachments.length) return null;
const firstFileName = this.attachments[0].data_url?.split('/').pop();
if (this.attachments.length > 1) {
if (firstFileName) {
return this.$t(
'CONVERSATION.REPLY_TO_ATTACHMENT.FILE_PLUS_MULTIPLE',
{
first: firstFileName,
count: (this.attachments.length - 1).toLocaleString(),
}
);
}
return this.$t('CONVERSATION.REPLY_TO_ATTACHMENT.COUNT', {
count: this.attachments.length.toLocaleString(),
});
}
return (
firstFileName ?? this.$t('CONVERSATION.REPLY_TO_ATTACHMENT.ATTACHMENT')
);
},
},
};
</script>