diff --git a/app/javascript/ui/MessageList.vue b/app/javascript/ui/MessageList.vue index 598261bfb..332fcd8ee 100644 --- a/app/javascript/ui/MessageList.vue +++ b/app/javascript/ui/MessageList.vue @@ -3,9 +3,15 @@ import { ref, onMounted, computed, watch, useTemplateRef } from 'vue'; import Message from 'next/message/Message.vue'; import ButtonNext from 'next/button/Button.vue'; import TypingIndicator from 'next/message/TypingIndicator.vue'; -import { useStore, useMapGetter } from 'dashboard/composables/store'; -import { useCamelCase } from 'dashboard/composables/useTransformKeys'; +import { + useStore, + useMapGetter, + useFunctionGetter, +} from '../dashboard/composables/store'; +import { getTypingUsersText } from '../dashboard/helper/commons'; +import { useCamelCase } from '../dashboard/composables/useTransformKeys'; import { useInfiniteScroll, useThrottleFn } from '@vueuse/core'; +import { useI18n } from 'vue-i18n'; const props = defineProps({ conversationId: { @@ -15,12 +21,30 @@ const props = defineProps({ }, }); +const { t } = useI18n(); + const messageListRef = useTemplateRef('messageListRef'); const store = useStore(); const isAllLoaded = useMapGetter('getAllMessagesLoaded'); const isFetching = ref(false); const messageContent = ref(''); +const typingUserList = useFunctionGetter( + 'conversationTypingStatus/getUserList', + props.conversationId +); + +const isAnyoneTyping = computed(() => { + return typingUserList.value.length > 0; +}); + +const typingUserNames = computed(() => { + if (!isAnyoneTyping.value) return ''; + const [i18nKey, params] = getTypingUsersText(typingUserList.value); + // eslint-disable-next-line @intlify/vue-i18n/no-dynamic-keys + return t(i18nKey, params); +}); + const conversation = computed(() => { return store.getters.getConversationById(props.conversationId); }); @@ -105,8 +129,11 @@ const sendMessage = async () => { >