fix: make function getContactDeviceCount work (#3284)

Co-authored-by: Shir Serlui <70711723+shirser121@users.noreply.github.com>
This commit is contained in:
alechkos 2024-09-23 17:12:17 +03:00 • committed by GitHub
commit 5b0e0612de
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1729,15 +1729,17 @@ class Client extends EventEmitter {
* Get user device count by ID
* 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"
* @param {string} contactId
* @returns {number}
* @param {string} userId
* @returns {Promise<number>}
*/
async getContactDeviceCount(contactId) {
let devices = await window.Store.DeviceList.getDeviceIds([window.Store.WidFactory.createWid(contactId)]);
if(devices && devices.length && devices[0] != null && typeof devices[0].devices == 'object'){
return devices[0].devices.length;
}
return 0;
async getContactDeviceCount(userId) {
return await this.pupPage.evaluate(async (userId) => {
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 0;
}, userId);
}
/**