Skip to content

Commit 48092be

Browse files
committed
(slots) add message-avatar_{{MESSAGE_ID}}
1 parent 504a818 commit 48092be

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ Example:
766766
| `room-header-info` | Replace the template of the room header text |
767767
| `room-options` | Replace the template of the room options |
768768
| `message_{{MESSAGE_ID}}` | Replace the template of the message (and system message) box |
769+
| `message-avatar_{{MESSAGE_ID}}` | Replace the template of the message avatar |
769770
| `message-failure_{{MESSAGE_ID}}` | Replace the message failure icon |
770771
| `messages-empty` | Replace the empty message template |
771772
| `rooms-empty` | Replace the empty rooms template |

demo/src/ChatContainer.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ export default {
448448
},
449449
450450
formatMessage(room, message) {
451+
// const senderUser = room.users.find(user => user._id === message.sender_id)
451452
const formattedMessage = {
452453
...message,
453454
...{

src/lib/Room/RoomMessage/RoomMessage.vue

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@
3434
@click="selectMessage"
3535
>
3636
<slot :name="'message_' + message._id">
37-
<div
37+
<slot
3838
v-if="message.avatar && message.senderId !== currentUserId"
39-
class="vac-avatar"
40-
:style="{ 'background-image': `url('${message.avatar}')` }"
41-
/>
39+
:name="'message-avatar_' + message._id"
40+
>
41+
<div
42+
class="vac-avatar"
43+
:style="{ 'background-image': `url('${message.avatar}')` }"
44+
/>
45+
</slot>
4246
<div
4347
v-if="hasSenderUserAvatar && !message.avatar"
4448
class="vac-avatar-offset"
@@ -197,11 +201,15 @@
197201
<div class="vac-failure-text">!</div>
198202
</div>
199203
</slot>
200-
<div
204+
<slot
201205
v-if="message.avatar && message.senderId === currentUserId"
202-
class="vac-avatar vac-avatar-current"
203-
:style="{ 'background-image': `url('${message.avatar}')` }"
204-
/>
206+
:name="'message-avatar_' + message._id"
207+
>
208+
<div
209+
class="vac-avatar vac-avatar-current"
210+
:style="{ 'background-image': `url('${message.avatar}')` }"
211+
/>
212+
</slot>
205213
<div
206214
v-if="hasCurrentUserAvatar && !message.avatar"
207215
class="vac-avatar-current-offset"

0 commit comments

Comments
 (0)