Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label hexColor property is aways undefined #2992

Open
1 task done
douglasnoas opened this issue Apr 26, 2024 · 0 comments
Open
1 task done

Label hexColor property is aways undefined #2992

douglasnoas opened this issue Apr 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@douglasnoas
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

var labels = await client.getLabels();
labels[0].hexColor //undefined

whatsapp is now using colorIndex

Expected behavior

label.hexColor should not be undefined

Steps to Reproduce the Bug or Issue

Just use client.getLabels to get a Label[] list

Relevant Code

No response

Browser Type

Chromium

WhatsApp Account Type

WhatsApp Business

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

anywhere

Additional context

suggestion fix for Label.js adding a local color table

'use strict';

const Base = require('./Base');
// eslint-disable-next-line no-unused-vars
const Chat = require('./Chat');

const Colors = [
    "#ff9485",
    "#64c4ff",
    "#ffd429",
    "#dfaef0",
    "#99b6c1",
    "#55ccb3",
    "#ff9dff",
    "#d3a91d",
    "#6d7cce",
    "#d7e752",
    "#00d0e2",
    "#ffc5c7",
    "#93ceac",
    "#f74848",
    "#00a0f2",
    "#83e422",
    "#ffaf04",
    "#b5ebff",
    "#9ba6ff",
    "#9368cf"
]

/**
 * WhatsApp Business Label information
 */
class Label extends Base {
    /**
     * @param {Base} client
     * @param {object} labelData
     */
    constructor(client, labelData){
        super(client);

        if(labelData) this._patch(labelData);
    }

    _patch(labelData){
        /**
         * Label ID
         * @type {string}
         */
        this.id = labelData.id;

        /**
         * Label name
         * @type {string}
         */
        this.name = labelData.name;

        /**
         * Label hex color
         * @type {string}
         */
        this.hexColor = Colors[labelData.colorIndex];
    }
    /**
     * Get all chats that have been assigned this Label
     * @returns {Promise<Array<Chat>>}
     */
    async getChats(){
        return this.client.getChatsByLabelId(this.id);
    }

}

module.exports = Label;
@douglasnoas douglasnoas added the bug Something isn't working label Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant