Skip to content

Commit 48e3f7e

Browse files
committed
(UI) add user state in rooms list
1 parent b358e03 commit 48e3f7e

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/ChatWindow/RoomsList.vue

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
No rooms
2626
</div>
2727

28-
<!-- :class="{ 'room-disabled': loadingMessages }" -->
2928
<div v-if="!loadingRooms" class="room-list">
3029
<div
3130
class="room-item"
@@ -41,7 +40,13 @@
4140
></div>
4241
<div class="name-container">
4342
<div class="title-container">
44-
<div class="room-name">{{ room.roomName }}</div>
43+
<div
44+
class="state-circle"
45+
:class="{ 'state-online': userStatus(room) }"
46+
></div>
47+
<div class="room-name">
48+
{{ room.roomName }}
49+
</div>
4550
<div class="room-name text-date" v-if="room.lastMessage">
4651
{{ room.lastMessage.timestamp }}
4752
</div>
@@ -73,6 +78,7 @@ export default {
7378
components: { Loader, SvgIcon },
7479
7580
props: {
81+
currentUserId: { type: [String, Number], required: true },
7682
textMessages: { type: Object, required: true },
7783
showRoomsList: { type: Boolean, required: true },
7884
showAddRoom: { type: Boolean, required: true },
@@ -111,6 +117,13 @@ export default {
111117
},
112118
addRoom() {
113119
this.$emit('addRoom')
120+
},
121+
userStatus(room) {
122+
if (!room.users || room.users.length !== 2) return
123+
124+
const user = room.users.find(u => u._id !== this.currentUserId)
125+
126+
return user.status && user.status.state === 'online'
114127
}
115128
}
116129
}
@@ -266,15 +279,23 @@ input {
266279
text-align: right;
267280
}
268281
269-
.room-disabled {
270-
pointer-events: none;
271-
}
272-
273282
.icon-check {
274283
height: 14px;
275284
width: 14px;
276285
vertical-align: middle;
277286
margin-top: -2px;
278287
margin-right: 1px;
279288
}
289+
290+
.state-circle {
291+
width: 9px;
292+
height: 9px;
293+
border-radius: 50%;
294+
background-color: #ccc;
295+
margin-right: 6px;
296+
}
297+
298+
.state-online {
299+
background-color: #4caf50;
300+
}
280301
</style>

0 commit comments

Comments
 (0)