mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-19 20:19:14 +00:00
feat: mark chat as unread (#475)
Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
committed by
Pedro S. Lopez
parent
5c6195738f
commit
3e32fe27ea
5
index.d.ts
vendored
5
index.d.ts
vendored
@@ -99,6 +99,9 @@ declare namespace WAWebJS {
|
|||||||
/** Mark as seen for the Chat */
|
/** Mark as seen for the Chat */
|
||||||
sendSeen(chatId: string): Promise<boolean>
|
sendSeen(chatId: string): Promise<boolean>
|
||||||
|
|
||||||
|
/** Mark the Chat as unread */
|
||||||
|
markChatUnread(chatId: string): Promise<void>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the current user's status message
|
* Sets the current user's status message
|
||||||
* @param status New status message
|
* @param status New status message
|
||||||
@@ -777,6 +780,8 @@ declare namespace WAWebJS {
|
|||||||
unmute: () => Promise<void>,
|
unmute: () => Promise<void>,
|
||||||
/** Returns the Contact that corresponds to this Chat. */
|
/** Returns the Contact that corresponds to this Chat. */
|
||||||
getContact: () => Promise<Contact>,
|
getContact: () => Promise<Contact>,
|
||||||
|
/** Marks this Chat as unread */
|
||||||
|
markUnread: () => Promise<void>
|
||||||
/** Returns array of all Labels assigned to this Chat */
|
/** Returns array of all Labels assigned to this Chat */
|
||||||
getLabels: () => Promise<Label[]>
|
getLabels: () => Promise<Label[]>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -689,6 +689,17 @@ class Client extends EventEmitter {
|
|||||||
}, chatId);
|
}, chatId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the Chat as unread
|
||||||
|
* @param {string} chatId ID of the chat that will be marked as unread
|
||||||
|
*/
|
||||||
|
async markChatUnread(chatId) {
|
||||||
|
await this.pupPage.evaluate(async chatId => {
|
||||||
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
|
await window.Store.Cmd.markChatUnread(chat, true);
|
||||||
|
}, chatId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the contact ID's profile picture URL, if privacy settings allow it
|
* Returns the contact ID's profile picture URL, if privacy settings allow it
|
||||||
* @param {string} contactId the whatsapp user's ID
|
* @param {string} contactId the whatsapp user's ID
|
||||||
|
|||||||
@@ -161,6 +161,13 @@ class Chat extends Base {
|
|||||||
return this.client.unmuteChat(this.id._serialized);
|
return this.client.unmuteChat(this.id._serialized);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark this chat as unread
|
||||||
|
*/
|
||||||
|
async markUnread(){
|
||||||
|
return this.client.markChatUnread(this.id._serialized);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads chat messages, sorted from earliest to latest.
|
* Loads chat messages, sorted from earliest to latest.
|
||||||
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||||
|
|||||||
Reference in New Issue
Block a user