diff --git a/src/WAConnection/4.Events.ts b/src/WAConnection/4.Events.ts index b4bd036..eebefa9 100644 --- a/src/WAConnection/4.Events.ts +++ b/src/WAConnection/4.Events.ts @@ -252,11 +252,15 @@ export class WAConnection extends Base { // profile picture updates this.on('CB:Cmd,type:picture', async json => { const jid = whatsappID(json[1].jid) - const chat = this.chats.get(jid) - if (!chat) return + const imgUrl = await this.getProfilePicture(jid) + const contact = this.contacts[jid] + if (contact) contact.imgUrl = imgUrl - await this.setProfilePicture (chat) - this.emit ('chat-update', { jid, imgUrl: chat.imgUrl }) + const chat = this.chats.get(jid) + if (chat) { + chat.imgUrl = imgUrl + this.emit ('chat-update', { jid, imgUrl }) + } }) // status updates this.on('CB:Status', async json => { diff --git a/src/WAConnection/Constants.ts b/src/WAConnection/Constants.ts index 154638f..b2ccd41 100644 --- a/src/WAConnection/Constants.ts +++ b/src/WAConnection/Constants.ts @@ -191,12 +191,12 @@ export interface WAContact { /** short name for the contact */ short?: string // Baileys Added + imgUrl?: string lastKnownPresence?: Presence lastSeen?: number } export interface WAUser extends WAContact { phone: any - imgUrl?: string } export interface WAChat { jid: string