Repository: pedroslopez/whatsapp-web.js
File: src/Client.js (JavaScript)

Code before:
        }, chatId);
    }

    /**
     * Mark the Chat as unread
     * @param {string} chatId ID of the chat that will be marked as unread
     */
    async markChatUnread(chatId) {
        await this.pupPage.evaluate(async chatId => {
            let chat = await window.Store.Chat.get(chatId);
            await window.Store.Cmd.markChatUnread(chat, true);
        }, chatId);
    }

    /**
     * Returns the contact ID's profile picture URL, if privacy settings allow it
     * @param {string} contactId the whatsapp user's ID
     * @returns {Promise<string>}
     */
    async getProfilePicUrl(contactId) {
        const profilePic = await this.pupPage.evaluate(async contactId => {
            const chatWid = window.Store.WidFactory.createWid(contactId);
            let asyncPic = await window.Store.getProfilePicFull(chatWid).catch(() => {
                return undefined;
            });
            if (!asyncPic) {
                asyncPic = await window.Store.Wap.profilePicFind(contactId).catch(() => {
                    return undefined;
                });
            }
            return asyncPic;
        }, contactId);
        return profilePic ? profilePic.eurl : undefined;
    }

    /**
     * Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
     * @param {string} contactId the whatsapp user's ID (_serialized format)
     * @returns {Promise<WAWebJS.ChatId[]>}
     */
    async getCommonGroups(contactId) {
        const commonGroups = await this.pupPage.evaluate(async (contactId) => {
            const contact = window.Store.Contact.get(contactId);
            if (contact.commonGroups) {
                return contact.commonGroups.serialize();
            }
            const status = await window.Store.findCommonGroups(contact);
            if (status) {
                return contact.commonGroups.serialize();
            }
            return [];

Review comment (suggestion):
I think we should be explicit and only call the Wap function if we're not on MD. 

So, this would look something like:

```js
if(window.Store.Features.features.MD_BACKEND) {
// use getProfilePicFull
} else {
// use Wap.profilePicFind
}
```

Code after:
        }, chatId);
    }

    /**
     * Mark the Chat as unread
     * @param {string} chatId ID of the chat that will be marked as unread
     */
    async markChatUnread(chatId) {
        await this.pupPage.evaluate(async chatId => {
            let chat = await window.Store.Chat.get(chatId);
            await window.Store.Cmd.markChatUnread(chat, true);
        }, chatId);
    }

    /**
     * Returns the contact ID's profile picture URL, if privacy settings allow it
     * @param {string} contactId the whatsapp user's ID
     * @returns {Promise<string>}
     */
    async getProfilePicUrl(contactId) {
        const profilePic = await this.pupPage.evaluate(async contactId => {
            let asyncPic;
            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);
        return profilePic ? profilePic.eurl : undefined;
    }

    /**
     * Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
     * @param {string} contactId the whatsapp user's ID (_serialized format)
     * @returns {Promise<WAWebJS.ChatId[]>}
     */
    async getCommonGroups(contactId) {
        const commonGroups = await this.pupPage.evaluate(async (contactId) => {
            const contact = window.Store.Contact.get(contactId);
            if (contact.commonGroups) {
                return contact.commonGroups.serialize();
            }
            const status = await window.Store.findCommonGroups(contact);
            if (status) {
                return contact.commonGroups.serialize();