mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-19 12:09:15 +00:00
Allow a chat to be muted indefinitely (#849)
* muteChat fixed * Update src/Client.js Co-authored-by: Pedro S. Lopez <pedroslopez@me.com> * Update src/Client.js Co-authored-by: Pedro S. Lopez <pedroslopez@me.com> * date fix Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
This commit is contained in:
10
index.d.ts
vendored
10
index.d.ts
vendored
@@ -94,11 +94,11 @@ declare namespace WAWebJS {
|
|||||||
getNumberId(number: string): Promise<ContactId | null>
|
getNumberId(number: string): Promise<ContactId | null>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes the Chat until a specified date
|
* Mutes this chat forever, unless a date is specified
|
||||||
* @param chatId ID of the chat that will be muted
|
* @param chatId ID of the chat that will be muted
|
||||||
* @param unmuteDate Date when the chat will be unmuted
|
* @param unmuteDate Date when the chat will be unmuted, leave as is to mute forever
|
||||||
*/
|
*/
|
||||||
muteChat(chatId: string, unmuteDate: Date): Promise<void>
|
muteChat(chatId: string, unmuteDate?: Date): Promise<void>
|
||||||
|
|
||||||
/** Force reset of connection state for the client */
|
/** Force reset of connection state for the client */
|
||||||
resetState(): Promise<void>
|
resetState(): Promise<void>
|
||||||
@@ -867,8 +867,8 @@ declare namespace WAWebJS {
|
|||||||
delete: () => Promise<boolean>,
|
delete: () => Promise<boolean>,
|
||||||
/** Loads chat messages, sorted from earliest to latest. */
|
/** Loads chat messages, sorted from earliest to latest. */
|
||||||
fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
|
fetchMessages: (searchOptions: MessageSearchOptions) => Promise<Message[]>,
|
||||||
/** Mutes this chat until a specified date */
|
/** Mutes this chat forever, unless a date is specified */
|
||||||
mute: (unmuteDate: Date) => Promise<void>,
|
mute: (unmuteDate?: Date) => Promise<void>,
|
||||||
/** Send a message to this chat */
|
/** Send a message to this chat */
|
||||||
sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
|
sendMessage: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
|
||||||
/** Set the message as seen */
|
/** Set the message as seen */
|
||||||
|
|||||||
@@ -765,15 +765,16 @@ class Client extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes the Chat until a specified date
|
* Mutes this chat forever, unless a date is specified
|
||||||
* @param {string} chatId ID of the chat that will be muted
|
* @param {string} chatId ID of the chat that will be muted
|
||||||
* @param {Date} unmuteDate Date when the chat will be unmuted
|
* @param {?Date} unmuteDate Date when the chat will be unmuted, leave as is to mute forever
|
||||||
*/
|
*/
|
||||||
async muteChat(chatId, unmuteDate) {
|
async muteChat(chatId, unmuteDate) {
|
||||||
|
unmuteDate = unmuteDate ? unmuteDate.getTime() / 1000 : -1;
|
||||||
await this.pupPage.evaluate(async (chatId, timestamp) => {
|
await this.pupPage.evaluate(async (chatId, timestamp) => {
|
||||||
let chat = await window.Store.Chat.get(chatId);
|
let chat = await window.Store.Chat.get(chatId);
|
||||||
await chat.mute.mute(timestamp, !0);
|
await chat.mute.mute(timestamp, !0);
|
||||||
}, chatId, unmuteDate.getTime() / 1000);
|
}, chatId, unmuteDate || -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -147,10 +147,10 @@ class Chat extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mutes this chat until a specified date
|
* Mutes this chat forever, unless a date is specified
|
||||||
* @param {Date} unmuteDate Date at which the Chat will be unmuted
|
* @param {?Date} unmuteDate Date at which the Chat will be unmuted, leave as is to mute forever
|
||||||
*/
|
*/
|
||||||
async mute(unmuteDate) {
|
async mute(unmuteDate = undefined) {
|
||||||
return this.client.muteChat(this.id._serialized, unmuteDate);
|
return this.client.muteChat(this.id._serialized, unmuteDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user