mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user