mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-17 19:26:20 +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:
2
index.d.ts
vendored
2
index.d.ts
vendored
@@ -1038,6 +1038,8 @@ declare namespace WAWebJS {
|
|||||||
timestamp: number,
|
timestamp: number,
|
||||||
/** Amount of messages unread */
|
/** Amount of messages unread */
|
||||||
unreadCount: number,
|
unreadCount: number,
|
||||||
|
/** Last message fo chat */
|
||||||
|
lastMessage: Message,
|
||||||
|
|
||||||
/** Archives this chat */
|
/** Archives this chat */
|
||||||
archive: () => Promise<void>,
|
archive: () => Promise<void>,
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ class Chat extends Base {
|
|||||||
*/
|
*/
|
||||||
this.muteExpiration = data.muteExpiration;
|
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);
|
return super._patch(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -428,6 +428,14 @@ exports.LoadUtils = () => {
|
|||||||
res.groupMetadata = chat.groupMetadata.serialize();
|
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.msgs;
|
||||||
delete res.msgUnsyncedButtonReplyMsgs;
|
delete res.msgUnsyncedButtonReplyMsgs;
|
||||||
delete res.unsyncedButtonReplies;
|
delete res.unsyncedButtonReplies;
|
||||||
|
|||||||
Reference in New Issue
Block a user