Browse Source

lastModified fix

Ivan Greenking 1 year ago
parent
commit
516101549a
1 changed files with 4 additions and 1 deletions
  1. 4 1
      models.js

+ 4 - 1
models.js

@@ -132,11 +132,14 @@ module.exports = async (dbName='graphql-chat') => {
                 this.___permissions.read.push(chatId)
                 this.___permissions.read = [...new Set(this.___permissions.read)]
 
+                let newMsg = !this._id
 
                 let result =  await super.save(...params)
 
                 await this.chat
-                this.chat.lastModified = this.createdAt.getTime()
+                if (newMsg){
+                    this.chat.lastModified = this.createdAt.getTime()
+                }
                 await Savable.prototype.save.call(this.chat)