getProfilePicture Fix => Evaluation failed: Error: Comms::sendIq called before startComms (#1264)

* Fix: Evaluation failed: Error: Comms::sendIq called before startComms

* [Requested Changes] - Only call Wap if we're not on MD & vice-versa

Co-authored-by: Joaquin Touris <joaquin@192.168.1.5>
This commit is contained in:
༺ LᴇG̸ᴇɴD ༻ 2022-03-05 11:24:40 -03:00 • committed by GitHub
commit b96607338a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -876,11 +876,20 @@ class Client extends EventEmitter {
* @returns {Promise<string>} * @returns {Promise<string>}
*/ */
async getProfilePicUrl(contactId) { async getProfilePicUrl(contactId) {
const profilePic = await this.pupPage.evaluate((contactId) => { const profilePic = await this.pupPage.evaluate(async contactId => {
const chatWid = window.Store.WidFactory.createWid(contactId); let asyncPic;
return window.Store.getProfilePicFull(chatWid); if (window.Store.Features.features.MD_BACKEND) {
const chatWid = window.Store.WidFactory.createWid(contactId);
asyncPic = await window.Store.getProfilePicFull(chatWid).catch(() => {
return undefined;
});
} else {
asyncPic = await window.Store.Wap.profilePicFind(contactId).catch(() => {
return undefined;
});
}
return asyncPic;
}, contactId); }, contactId);
return profilePic ? profilePic.eurl : undefined; return profilePic ? profilePic.eurl : undefined;
} }