67
67
@open-user-tag =" openUserTag"
68
68
@add-room =" addRoom"
69
69
@menu-action-handler =" menuActionHandler"
70
- @message-action-handler =" messageActionHandler"
71
70
@send-message-reaction =" sendMessageReaction"
72
71
@typing-message =" typingMessage"
73
72
>
@@ -248,11 +247,10 @@ export default {
248
247
: require (' @/assets/logo.png' )
249
248
250
249
formattedRooms .push ({
251
- ... {
252
- roomId: key,
253
- avatar: roomAvatar,
254
- ... room
255
- }
250
+ ... room,
251
+ roomId: key,
252
+ avatar: roomAvatar,
253
+ index: room .lastUpdated .seconds
256
254
})
257
255
})
258
256
@@ -265,7 +263,7 @@ export default {
265
263
}
266
264
267
265
this .listenUsersOnlineStatus (formattedRooms)
268
- this .listenRoomsTypingUsers (query)
266
+ this .listenRooms (query)
269
267
// setTimeout(() => console.log('TOTAL', this.dbRequestCount), 2000)
270
268
},
271
269
@@ -298,6 +296,7 @@ export default {
298
296
299
297
formatLastMessage (message ) {
300
298
if (! message .timestamp ) return
299
+
301
300
const date = new Date (message .timestamp .seconds * 1000 )
302
301
const timestampFormat = isSameDay (date, new Date ()) ? ' HH:mm' : ' DD/MM/YY'
303
302
@@ -314,7 +313,6 @@ export default {
314
313
... {
315
314
content,
316
315
timestamp,
317
- date: message .timestamp .seconds ,
318
316
distributed: true ,
319
317
seen: message .sender_id === this .currentUserId ? message .seen : null ,
320
318
new:
@@ -418,7 +416,7 @@ export default {
418
416
}
419
417
},
420
418
421
- async sendMessage ({ content, roomId, file, replyMessage, usersTag }) {
419
+ async sendMessage ({ content, roomId, file, replyMessage }) {
422
420
const message = {
423
421
sender_id: this .currentUserId ,
424
422
content,
@@ -458,7 +456,7 @@ export default {
458
456
roomsRef .doc (roomId).update ({ lastUpdated: new Date () })
459
457
},
460
458
461
- openFile ({ message, action }) {
459
+ openFile ({ message }) {
462
460
window .open (message .file .url , ' _blank' )
463
461
},
464
462
@@ -577,14 +575,6 @@ export default {
577
575
}
578
576
},
579
577
580
- messageActionHandler () {
581
- // do something
582
- },
583
-
584
- textareaActionHandler ({ message, roomId }) {
585
- this .roomMessage = ' Implement your own action!'
586
- },
587
-
588
578
async sendMessageReaction ({ reaction, remove, messageId, roomId }) {
589
579
const dbAction = remove
590
580
? firebase .firestore .FieldValue .arrayRemove (this .currentUserId )
@@ -617,12 +607,15 @@ export default {
617
607
})
618
608
},
619
609
620
- async listenRoomsTypingUsers (query ) {
610
+ async listenRooms (query ) {
621
611
const listener = query .onSnapshot (rooms => {
622
612
// this.incrementDbCounter('Listen Rooms Typing Users', rooms.size)
623
613
rooms .forEach (room => {
624
614
const foundRoom = this .rooms .find (r => r .roomId === room .id )
625
- if (foundRoom) foundRoom .typingUsers = room .data ().typingUsers
615
+ if (foundRoom) {
616
+ foundRoom .typingUsers = room .data ().typingUsers
617
+ foundRoom .index = room .data ().lastUpdated .seconds
618
+ }
626
619
})
627
620
})
628
621
this .roomsListeners .push (listener)
0 commit comments