Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
intrn(consultation): include profile picture in chat message
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethTrecy committed Sep 13, 2022
1 parent 10c9970 commit b793de0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion components/consultation/chat_window/chat_message_item.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<template>
<div class="message-item">
<ProfilePicture
v-if="isOtherMessage"
class="flex-1"
:user="chatMessage.user"/>
<div :class="messageAlignment">
<h6 class="message-item-name">
{{ chatMessage.user.data.name }}
Expand All @@ -10,6 +14,10 @@
{{ chatMessage.data.value }}
</p>
</div>
<ProfilePicture
v-if="isSelfMessage"
class="flex-1"
:user="chatMessage.user"/>
</div>
</template>

Expand Down Expand Up @@ -38,6 +46,8 @@ import type { PageContext } from "$/types/renderer"
import type { TextMessage, StatusMessage } from "$/types/message"
import type { DeserializedChatMessageResource } from "$/types/documents/chat_message"
import ProfilePicture from "@/helpers/profile_picture.vue"
const pageContext = inject("pageContext") as PageContext<"deserialized">
const { pageProps } = pageContext
Expand All @@ -54,10 +64,24 @@ function isStatusMessage(value: DeserializedChatMessageResource<"user">)
return value.kind === "status"
}
const isSelfMessage = computed<boolean>(() => {
const isMessageCameFromSelf = !isStatusMessage(chatMessage)
&& userProfile.data.id === chatMessage.user.data.id
return isMessageCameFromSelf
})
const isOtherMessage = computed<boolean>(() => {
const isMessageCameFromOther = !isStatusMessage(chatMessage)
&& userProfile.data.id !== chatMessage.user.data.id
return isMessageCameFromOther
})
const messageAlignment = computed<Alignment>(() => {
if (isStatusMessage(chatMessage)) {
return "align-center"
} else if (userProfile.data.id === chatMessage.user.data.id) {
} else if (isSelfMessage.value) {
return "align-right"
}
Expand Down

0 comments on commit b793de0

Please sign in to comment.