mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-21 04:59:14 +00:00
feat: archive chats (#63)
This commit is contained in:
@@ -309,7 +309,6 @@ class Client extends EventEmitter {
|
||||
return new Message(this, newMessage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all current chat instances
|
||||
* @returns {Promise<Array<Chat>>}
|
||||
@@ -392,6 +391,30 @@ class Client extends EventEmitter {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables and returns the archive state of the Chat
|
||||
* @returns {boolean}
|
||||
*/
|
||||
async archiveChat(chatId) {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, true);
|
||||
return chat.archive;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes and returns the archive state of the Chat
|
||||
* @returns {boolean}
|
||||
*/
|
||||
async unarchiveChat(chatId) {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, false);
|
||||
return chat.archive;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
|
||||
Reference in New Issue
Block a user