6767 @open-user-tag =" openUserTag"
6868 @add-room =" addRoom"
6969 @menu-action-handler =" menuActionHandler"
70- @message-action-handler =" messageActionHandler"
7170 @send-message-reaction =" sendMessageReaction"
7271 @typing-message =" typingMessage"
7372 >
@@ -248,11 +247,10 @@ export default {
248247 : require (' @/assets/logo.png' )
249248
250249 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
256254 })
257255 })
258256
@@ -265,7 +263,7 @@ export default {
265263 }
266264
267265 this .listenUsersOnlineStatus (formattedRooms)
268- this .listenRoomsTypingUsers (query)
266+ this .listenRooms (query)
269267 // setTimeout(() => console.log('TOTAL', this.dbRequestCount), 2000)
270268 },
271269
@@ -298,6 +296,7 @@ export default {
298296
299297 formatLastMessage (message ) {
300298 if (! message .timestamp ) return
299+
301300 const date = new Date (message .timestamp .seconds * 1000 )
302301 const timestampFormat = isSameDay (date, new Date ()) ? ' HH:mm' : ' DD/MM/YY'
303302
@@ -314,7 +313,6 @@ export default {
314313 ... {
315314 content,
316315 timestamp,
317- date: message .timestamp .seconds ,
318316 distributed: true ,
319317 seen: message .sender_id === this .currentUserId ? message .seen : null ,
320318 new:
@@ -418,7 +416,7 @@ export default {
418416 }
419417 },
420418
421- async sendMessage ({ content, roomId, file, replyMessage, usersTag }) {
419+ async sendMessage ({ content, roomId, file, replyMessage }) {
422420 const message = {
423421 sender_id: this .currentUserId ,
424422 content,
@@ -458,7 +456,7 @@ export default {
458456 roomsRef .doc (roomId).update ({ lastUpdated: new Date () })
459457 },
460458
461- openFile ({ message, action }) {
459+ openFile ({ message }) {
462460 window .open (message .file .url , ' _blank' )
463461 },
464462
@@ -577,14 +575,6 @@ export default {
577575 }
578576 },
579577
580- messageActionHandler () {
581- // do something
582- },
583-
584- textareaActionHandler ({ message, roomId }) {
585- this .roomMessage = ' Implement your own action!'
586- },
587-
588578 async sendMessageReaction ({ reaction, remove, messageId, roomId }) {
589579 const dbAction = remove
590580 ? firebase .firestore .FieldValue .arrayRemove (this .currentUserId )
@@ -617,12 +607,15 @@ export default {
617607 })
618608 },
619609
620- async listenRoomsTypingUsers (query ) {
610+ async listenRooms (query ) {
621611 const listener = query .onSnapshot (rooms => {
622612 // this.incrementDbCounter('Listen Rooms Typing Users', rooms.size)
623613 rooms .forEach (room => {
624614 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+ }
626619 })
627620 })
628621 this .roomsListeners .push (listener)
0 commit comments