Skip to content

Commit 8af824e

Browse files
author
Dario Aubry
committed
(feat) add saved & distributed prop for double checkmark icon
1 parent b97607c commit 8af824e

File tree

5 files changed

+64
-18
lines changed

5 files changed

+64
-18
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ styles="{
362362
emojiReaction: '#828c94',
363363
document: '#1976d2',
364364
pencil: '#9e9e9e',
365-
checkmark: '#0696c7',
365+
checkmark: '#9e9e9e',
366+
checkmarkSeen: '#0696c7',
366367
eye: '#fff',
367368
dropdownMessage: '#fff',
368369
dropdownMessageBackground: 'rgba(0, 0, 0, 0.25)',
@@ -389,6 +390,8 @@ rooms="[
389390
username: 'John Doe',
390391
timestamp: '10:20',
391392
date: 123242424,
393+
saved: true,
394+
distributed: false,
392395
seen: false,
393396
new: true
394397
},
@@ -428,7 +431,11 @@ rooms="[
428431

429432
Message objects are rendered differently depending on their type. Currently, only text, emoji and file types are supported.<br><br>
430433
Each message object has a `sender_id` field which holds the id of the corresponding agent. If `sender_id` matches the `currentUserId` prop, specific UI and actions will be implemented.<br><br>
431-
Note: `username` will be displayed on each message of corresponding agents if at least 3 users are in the room.
434+
Note: `username` will be displayed on each message of corresponding agents if at least 3 users are in the room.<br><br>
435+
Message states:
436+
- `saved: true` one checkmark
437+
- `distributed: true` two checkmarks
438+
- `seen: true` two blue checkmarks
432439

433440
```javascript
434441
messages="[
@@ -439,6 +446,8 @@ messages="[
439446
username: 'John Doe',
440447
date: '13 November',
441448
timestamp: '10:20',
449+
saved: true,
450+
distributed: true,
442451
seen: true,
443452
disable_actions: false,
444453
disable_reactions: false,

src/ChatWindow/Message.vue

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,13 @@
123123
<svg-icon name="pencil" />
124124
</div>
125125
<span>{{ message.timestamp }}</span>
126-
<span v-if="isMessageSeen">
127-
<svg-icon name="checkmark" class="icon-check" />
128-
</span>
126+
<span v-if="isCheckmarkVisible">
127+
<svg-icon
128+
:name="message.distributed ? 'double-checkmark' : 'checkmark'"
129+
:param="message.seen ? 'seen' : ''"
130+
class="icon-check"
131+
></svg-icon>
132+
</span>
129133
</div>
130134

131135
<div
@@ -335,13 +339,17 @@ export default {
335339
this.message.file.url.indexOf('blob:http') !== -1 || this.imageLoading
336340
)
337341
},
338-
isMessageSeen() {
339-
return (
340-
this.message.sender_id === this.currentUserId &&
341-
this.message.seen &&
342-
!this.message.deleted
343-
)
344-
},
342+
isCheckmarkVisible() {
343+
return (
344+
this.message.sender_id === this.currentUserId &&
345+
!this.message.deleted &&
346+
(
347+
this.message.saved ||
348+
this.message.distributed ||
349+
this.message.seen
350+
)
351+
)
352+
},
345353
replyUsername() {
346354
const { sender_id } = this.message.replyMessage
347355
const replyUser = this.roomUsers.find(user => user._id === sender_id)

src/ChatWindow/RoomsList.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@
5959
class="text-last"
6060
:class="{ 'message-new': room.lastMessage && room.lastMessage.new }"
6161
>
62-
<span v-if="room.lastMessage && room.lastMessage.seen">
63-
<svg-icon name="checkmark" class="icon-check" />
62+
<span v-if="isMessageCheckmarkVisible(room)">
63+
<svg-icon
64+
:name="room.lastMessage.distributed ? 'double-checkmark' : 'checkmark'"
65+
:param="room.lastMessage.seen ? 'seen' : ''"
66+
class="icon-check"
67+
></svg-icon>
6468
</span>
6569
<format-message
6670
v-if="room.lastMessage"
@@ -166,7 +170,18 @@ export default {
166170
}
167171
168172
return `${user.username} - ${content}`
169-
}
173+
},
174+
isMessageCheckmarkVisible(room) {
175+
return (
176+
room.lastMessage &&
177+
room.lastMessage.sender_id === this.currentUserId &&
178+
(
179+
room.lastMessage.saved ||
180+
room.lastMessage.distributed ||
181+
room.lastMessage.seen
182+
)
183+
)
184+
}
170185
}
171186
}
172187
</script>

src/ChatWindow/SvgIcon.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ export default {
8989
name: 'checkmark',
9090
path: 'M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z'
9191
},
92+
{
93+
name: 'double-checkmark',
94+
path:
95+
'M18 7l-1.41-1.41-6.34 6.34 1.41 1.41L18 7zm4.24-1.41L11.66 16.17 7.48 12l-1.41 1.41L11.66 19l12-12-1.42-1.41zM.41 13.41L6 19l1.41-1.41L1.83 12 .41 13.41z'
96+
},
9297
{
9398
name: 'eye',
9499
path:
@@ -170,10 +175,16 @@ export default {
170175
fill: var(--chat-icon-color-pencil);
171176
}
172177
173-
#chat-icon-checkmark {
178+
#chat-icon-checkmark,
179+
#chat-icon-double-checkmark {
174180
fill: var(--chat-icon-color-checkmark);
175181
}
176182
183+
#chat-icon-checkmark-seen,
184+
#chat-icon-double-checkmark-seen {
185+
fill: var(--chat-icon-color-checkmark-seen);
186+
}
187+
177188
#chat-icon-eye {
178189
fill: var(--chat-icon-color-eye);
179190
}

src/themes/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ export const defaultThemeStyles = {
112112
emojiReaction: 'rgba(0, 0, 0, 0.3)',
113113
document: '#1976d2',
114114
pencil: '#9e9e9e',
115-
checkmark: '#0696c7',
115+
checkmark: '#9e9e9e',
116+
checkmarkSeen: '#0696c7',
116117
eye: '#fff',
117118
dropdownMessage: '#fff',
118119
dropdownMessageBackground: 'rgba(0, 0, 0, 0.25)',
@@ -232,7 +233,8 @@ export const defaultThemeStyles = {
232233
emojiReaction: '#fff',
233234
document: '#1976d2',
234235
pencil: '#ebedf2',
235-
checkmark: '#f0d90a',
236+
checkmark: '#ebedf2',
237+
checkmarkSeen: '#f0d90a',
236238
eye: '#fff',
237239
dropdownMessage: '#fff',
238240
dropdownMessageBackground: 'rgba(0, 0, 0, 0.25)',
@@ -360,6 +362,7 @@ export const cssThemeVars = ({
360362
'--chat-icon-color-document': icons.document,
361363
'--chat-icon-color-pencil': icons.pencil,
362364
'--chat-icon-color-checkmark': icons.checkmark,
365+
'--chat-icon-color-checkmark-seen': icons.checkmarkSeen,
363366
'--chat-icon-color-eye': icons.eye,
364367
'--chat-icon-color-dropdown-message': icons.dropdownMessage,
365368
'--chat-icon-bg-dropdown-message': icons.dropdownMessageBackground,

0 commit comments

Comments
 (0)