fix: make function getContactDeviceCount work (#3284)
Co-authored-by: Shir Serlui <70711723+shirser121@users.noreply.github.com>
This commit is contained in:
parent
0fa6ebb66d
commit
5b0e0612de
2 changed files with 11 additions and 9 deletions
2
index.d.ts
vendored
2
index.d.ts
vendored
|
|
@ -183,7 +183,7 @@ declare namespace WAWebJS {
|
||||||
* So for a non-enterprise user with one WaWeb connection it should return "2"
|
* So for a non-enterprise user with one WaWeb connection it should return "2"
|
||||||
* @param {string} contactId
|
* @param {string} contactId
|
||||||
*/
|
*/
|
||||||
getContactDeviceCount(contactId: string): Promise<Number>
|
getContactDeviceCount(userId: string): Promise<number>
|
||||||
|
|
||||||
/** Sync history conversation of the Chat */
|
/** Sync history conversation of the Chat */
|
||||||
syncHistory(chatId: string): Promise<boolean>
|
syncHistory(chatId: string): Promise<boolean>
|
||||||
|
|
|
||||||
|
|
@ -1729,15 +1729,17 @@ class Client extends EventEmitter {
|
||||||
* Get user device count by ID
|
* Get user device count by ID
|
||||||
* Each WaWeb Connection counts as one device, and the phone (if exists) counts as one
|
* Each WaWeb Connection counts as one device, and the phone (if exists) counts as one
|
||||||
* So for a non-enterprise user with one WaWeb connection it should return "2"
|
* So for a non-enterprise user with one WaWeb connection it should return "2"
|
||||||
* @param {string} contactId
|
* @param {string} userId
|
||||||
* @returns {number}
|
* @returns {Promise<number>}
|
||||||
*/
|
*/
|
||||||
async getContactDeviceCount(contactId) {
|
async getContactDeviceCount(userId) {
|
||||||
let devices = await window.Store.DeviceList.getDeviceIds([window.Store.WidFactory.createWid(contactId)]);
|
return await this.pupPage.evaluate(async (userId) => {
|
||||||
if(devices && devices.length && devices[0] != null && typeof devices[0].devices == 'object'){
|
const devices = await window.Store.DeviceList.getDeviceIds([window.Store.WidFactory.createWid(userId)]);
|
||||||
|
if (devices && devices.length && devices[0] != null && typeof devices[0].devices == 'object') {
|
||||||
return devices[0].devices.length;
|
return devices[0].devices.length;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
}, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue