chore(): generate docs
This commit is contained in:
parent
5ad6a03b2c
commit
f41d1e2174
73 changed files with 684 additions and 291 deletions
|
|
@ -4,7 +4,7 @@
|
|||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.28.0 » Source: Client.js</title>
|
||||
<title>whatsapp-web.js 1.28.1-alpha.0 » Source: Client.js</title>
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
|
||||
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
|
||||
<div id="jsdoc-navbar-container">
|
||||
<div id="jsdoc-navbar-content">
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>28.<wbr>0</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>28.<wbr>1-alpha.<wbr>0</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
@ -309,7 +309,7 @@ class Client extends EventEmitter {
|
|||
await this.authStrategy.beforeBrowserInitialized();
|
||||
|
||||
const puppeteerOpts = this.options.puppeteer;
|
||||
if (puppeteerOpts &amp;&amp; puppeteerOpts.browserWSEndpoint) {
|
||||
if (puppeteerOpts &amp;&amp; (puppeteerOpts.browserWSEndpoint || puppeteerOpts.browserURL)) {
|
||||
browser = await puppeteer.connect(puppeteerOpts);
|
||||
page = await browser.newPage();
|
||||
} else {
|
||||
|
|
@ -1224,25 +1224,38 @@ class Client extends EventEmitter {
|
|||
/**
|
||||
* Mutes this chat forever, unless a date is specified
|
||||
* @param {string} chatId ID of the chat that will be muted
|
||||
* @param {?Date} unmuteDate Date when the chat will be unmuted, leave as is to mute forever
|
||||
* @param {?Date} unmuteDate Date when the chat will be unmuted, don't provide a value to mute forever
|
||||
* @returns {Promise&lt;{isMuted: boolean, muteExpiration: number}>}
|
||||
*/
|
||||
async muteChat(chatId, unmuteDate) {
|
||||
unmuteDate = unmuteDate ? unmuteDate.getTime() / 1000 : -1;
|
||||
await this.pupPage.evaluate(async (chatId, timestamp) => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await chat.mute.mute({expiration: timestamp, sendDevice:!0});
|
||||
}, chatId, unmuteDate || -1);
|
||||
unmuteDate = unmuteDate ? Math.floor(unmuteDate.getTime() / 1000) : -1;
|
||||
return this._muteUnmuteChat(chatId, 'MUTE', unmuteDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmutes the Chat
|
||||
* @param {string} chatId ID of the chat that will be unmuted
|
||||
* @returns {Promise&lt;{isMuted: boolean, muteExpiration: number}>}
|
||||
*/
|
||||
async unmuteChat(chatId) {
|
||||
await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.muteChat(chat, false);
|
||||
}, chatId);
|
||||
return this._muteUnmuteChat(chatId, 'UNMUTE');
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal method to mute or unmute the chat
|
||||
* @param {string} chatId ID of the chat that will be muted/unmuted
|
||||
* @param {string} action The action: 'MUTE' or 'UNMUTE'
|
||||
* @param {number} unmuteDateTs Timestamp at which the chat will be unmuted
|
||||
* @returns {Promise&lt;{isMuted: boolean, muteExpiration: number}>}
|
||||
*/
|
||||
async _muteUnmuteChat (chatId, action, unmuteDateTs) {
|
||||
return this.pupPage.evaluate(async (chatId, action, unmuteDateTs) => {
|
||||
const chat = window.Store.Chat.get(chatId) ?? await window.Store.Chat.find(chatId);
|
||||
action === 'MUTE'
|
||||
? await chat.mute.mute({ expiration: unmuteDateTs, sendDevice: true })
|
||||
: await chat.mute.unmute({ sendDevice: true });
|
||||
return { isMuted: chat.mute.expiration !== 0, muteExpiration: chat.mute.expiration };
|
||||
}, chatId, action, unmuteDateTs || -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1312,7 +1325,7 @@ class Client extends EventEmitter {
|
|||
*/
|
||||
async resetState() {
|
||||
await this.pupPage.evaluate(() => {
|
||||
window.Store.AppState.phoneWatchdog.shiftTimer.forceRunNow();
|
||||
window.Store.AppState.reconnect();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -1752,6 +1765,23 @@ class Client extends EventEmitter {
|
|||
}, flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting background synchronization.
|
||||
* NOTE: this action will take effect after you restart the client.
|
||||
* @param {boolean} flag true/false
|
||||
* @returns {Promise&lt;boolean>}
|
||||
*/
|
||||
async setBackgroundSync(flag) {
|
||||
return await this.pupPage.evaluate(async flag => {
|
||||
const backSync = window.Store.Settings.getGlobalOfflineNotifications();
|
||||
if (backSync === flag) {
|
||||
return flag;
|
||||
}
|
||||
await window.Store.Settings.setGlobalOfflineNotifications(flag);
|
||||
return flag;
|
||||
}, flag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user device count by ID
|
||||
* Each WaWeb Connection counts as one device, and the phone (if exists) counts as one
|
||||
|
|
@ -1776,8 +1806,9 @@ class Client extends EventEmitter {
|
|||
*/
|
||||
async syncHistory(chatId) {
|
||||
return await this.pupPage.evaluate(async (chatId) => {
|
||||
const chat = await window.WWebJS.getChat(chatId);
|
||||
if (chat.endOfHistoryTransferType === 0) {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = window.Store.Chat.get(chatWid) ?? (await window.Store.Chat.find(chatWid));
|
||||
if (chat?.endOfHistoryTransferType === 0) {
|
||||
await window.Store.HistorySync.sendPeerDataOperationRequest(3, {
|
||||
chatId: chat.id
|
||||
});
|
||||
|
|
@ -1786,6 +1817,39 @@ class Client extends EventEmitter {
|
|||
return false;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save new contact to user's addressbook or edit the existing one
|
||||
* @param {string} phoneNumber The contact's phone number in a format "17182222222", where "1" is a country code
|
||||
* @param {string} firstName
|
||||
* @param {string} lastName
|
||||
* @param {boolean} [syncToAddressbook = false] If set to true, the contact will also be saved to the user's address book on their phone. False by default
|
||||
* @returns {Promise&lt;import('..').ChatId>} Object in a wid format
|
||||
*/
|
||||
async saveOrEditAddressbookContact(phoneNumber, firstName, lastName, syncToAddressbook = false)
|
||||
{
|
||||
return await this.pupPage.evaluate(async (phoneNumber, firstName, lastName, syncToAddressbook) => {
|
||||
return await window.Store.AddressbookContactUtils.saveContactAction(
|
||||
phoneNumber,
|
||||
null,
|
||||
firstName,
|
||||
lastName,
|
||||
syncToAddressbook
|
||||
);
|
||||
}, phoneNumber, firstName, lastName, syncToAddressbook);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes the contact from user's addressbook
|
||||
* @param {string} phoneNumber The contact's phone number in a format "17182222222", where "1" is a country code
|
||||
* @returns {Promise&lt;void>}
|
||||
*/
|
||||
async deleteAddressbookContact(phoneNumber)
|
||||
{
|
||||
return await this.pupPage.evaluate(async (phoneNumber) => {
|
||||
return await window.Store.AddressbookContactUtils.deleteContactAction(phoneNumber);
|
||||
}, phoneNumber);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Client;
|
||||
|
|
@ -1799,7 +1863,7 @@ module.exports = Client;
|
|||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on May 12, 2025.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on May 30, 2025.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
|
|
|||
Loading…
Reference in a new issue