lastMessage in chat (#1606)

* lastMessage in chat

* lastMessage info

* Update src/util/Injected.js

Co-authored-by: Rajeh Taher <rajeh@reforward.dev>

* fix  serialize msg

* markup

---------

Co-authored-by: tofers <tofers90>
Co-authored-by: Rajeh Taher <rajeh@reforward.dev>
This commit is contained in:
tofers
2023-04-01 17:07:39 +03:00
committed by GitHub
parent 780005a81a
commit 812ff0ddfc
3 changed files with 17 additions and 1 deletions

View File

@@ -75,6 +75,12 @@ class Chat extends Base {
*/
this.muteExpiration = data.muteExpiration;
/**
* Last message fo chat
* @type {Message}
*/
this.lastMessage = data.lastMessage ? new Message(super.client, data.lastMessage) : undefined;
return super._patch(data);
}

View File

@@ -427,7 +427,15 @@ exports.LoadUtils = () => {
await window.Store.GroupMetadata.update(chatWid);
res.groupMetadata = chat.groupMetadata.serialize();
}
res.lastMessage = null;
if (res.msgs && res.msgs.length) {
const lastMessage = window.Store.Msg.get(chat.lastReceivedKey._serialized);
if (lastMessage) {
res.lastMessage = window.WWebJS.getMessageModel(lastMessage);
}
}
delete res.msgs;
delete res.msgUnsyncedButtonReplyMsgs;
delete res.unsyncedButtonReplies;