Skip to content

Commit

Permalink
feat(OpenConversationsList): expose description
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Apr 29, 2024
1 parent a6aa9f6 commit 9a1733e
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 19 deletions.
1 change: 1 addition & 0 deletions lib/Service/RoomFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public function formatRoomV4(
return array_merge($roomData, [
'name' => $room->getName(),
'displayName' => $room->getDisplayName($isListingBreakoutRooms || $isSIPBridgeRequest || $this->userId === null ? '' : $this->userId, $isListingBreakoutRooms || $isSIPBridgeRequest),
'description' => $room->getListable() !== Room::LISTABLE_NONE ? $room->getDescription() : '',
'objectType' => $room->getObjectType(),
'objectId' => $room->getObjectId(),
'readOnly' => $room->getReadOnly(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default {

setup(props) {
const { item, isSearchResult } = toRefs(props)
const { counterType, conversationInformation } = useConversationInfo({ item, isSearchResult })
const { counterType, conversationInformation } = useConversationInfo({ item, isSearchResult, exposeMessages: true, exposeDescription: true })

return {
counterType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ export default {
},

props: {
exposeMessages: {
type: Boolean,
default: false,
},
item: {
type: Object,
default() {
Expand All @@ -66,9 +62,10 @@ export default {
emits: ['click'],

setup(props) {
const { item, exposeMessages } = toRefs(props)
const { item } = toRefs(props)
const selectedRoom = inject('selectedRoom', null)
const { counterType, conversationInformation } = useConversationInfo({ item, exposeMessages })
const exposeDescription = inject('exposeDescription', false)
const { counterType, conversationInformation } = useConversationInfo({ item, exposeDescription })

return {
selectedRoom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
:item-size="CONVERSATION_ITEM_SIZE"
key-field="token">
<template #default="{ item }">
<ConversationSearchResult :item="item" :expose-messages="exposeMessages" @click="onClick" />
<ConversationSearchResult :item="item" @click="onClick" />
</template>
<template #after>
<LoadingPlaceholder v-if="loading" type="conversations" />
Expand Down Expand Up @@ -42,10 +42,7 @@ export default {
type: Array,
required: true,
},
exposeMessages: {
type: Boolean,
default: false,
},

loading: {
type: Boolean,
default: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</template>

<script>
import { provide } from 'vue'

import RoomSelector from '../../RoomSelector.vue'

Expand All @@ -25,6 +26,10 @@ export default {
RoomSelector,
},

setup() {
provide('exposeDescription', true)
},

data() {
return {
modal: false,
Expand Down
16 changes: 9 additions & 7 deletions src/composables/useConversationInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ import { ATTENDEE, CONVERSATION } from '../constants.js'
* @param {object} payload function payload
* @param {import('vue').Ref} payload.item conversation item
* @param {import('vue').Ref} [payload.isSearchResult] whether conversation item appears as search result
* @param {import('vue').Ref} [payload.exposeMessages] whether to show messages in conversation item
* @param {boolean} [payload.exposeMessages] whether to show messages in conversation item
* @param {boolean} [payload.exposeDescription] whether to show description in conversation item
*/
export function useConversationInfo({
item,
isSearchResult = ref(null),
exposeMessages = ref(null),
exposeMessages = false,
exposeDescription = false,
}) {
const counterType = computed(() => {
if (exposeMessages.value === false) {
if (exposeMessages === false) {
return ''
} else if (item.value.unreadMentionDirect || (item.value.unreadMessages !== 0
&& [CONVERSATION.TYPE.ONE_TO_ONE, CONVERSATION.TYPE.ONE_TO_ONE_FORMER].includes(item.value.type)
Expand All @@ -43,7 +45,7 @@ export function useConversationInfo({
* e.g. no avatars on mentions.
*/
const simpleLastChatMessage = computed(() => {
if (exposeMessages.value === false || !hasLastMessage.value) {
if (exposeMessages === false || !hasLastMessage.value) {
return ''
}

Expand All @@ -62,7 +64,7 @@ export function useConversationInfo({
* @return {string} Part of the name until the first space
*/
const shortLastChatMessageAuthor = computed(() => {
if (exposeMessages.value === false || !hasLastMessage.value || item.value.lastMessage.systemMessage.length) {
if (exposeMessages === false || !hasLastMessage.value || item.value.lastMessage.systemMessage.length) {
return ''
}

Expand All @@ -81,8 +83,8 @@ export function useConversationInfo({
return t('spreed', 'Joining conversation …')
}

if (exposeMessages.value === false || !hasLastMessage.value) {
return ''
if (exposeMessages === false || !hasLastMessage.value) {
return exposeDescription ? item.value?.description : ''
}

if (shortLastChatMessageAuthor.value === '') {
Expand Down

0 comments on commit 9a1733e

Please sign in to comment.