mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
feat: WA Business Labels support (#407)
* Get all labels * Get chats by label * Get labels assigned to chats Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com> Co-authored-by: Pedro Lopez <pedroslopez@me.com>
This commit is contained in:
committed by
Pedro S. Lopez
parent
563f73d290
commit
274d24002b
@@ -29,6 +29,7 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
window.Store.WidFactory = window.mR.findModule('createWid')[0];
|
||||
window.Store.BlockContact = window.mR.findModule('blockContact')[0];
|
||||
window.Store.GroupMetadata = window.mR.findModule((module) => module.default && module.default.handlePendingInvite)[0].default;
|
||||
window.Store.Label = window.mR.findModule('LabelCollection')[0].default;
|
||||
};
|
||||
|
||||
exports.LoadUtils = () => {
|
||||
@@ -363,6 +364,27 @@ exports.LoadUtils = () => {
|
||||
return true;
|
||||
};
|
||||
|
||||
window.WWebJS.getLabelModel = label => {
|
||||
let res = label.serialize();
|
||||
res.hexColor = label.hexColor;
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
window.WWebJS.getLabels = () => {
|
||||
const labels = window.Store.Label.models;
|
||||
return labels.map(label => window.WWebJS.getLabelModel(label));
|
||||
};
|
||||
|
||||
window.WWebJS.getLabel = (labelId) => {
|
||||
const label = window.Store.Label.get(labelId);
|
||||
return window.WWebJS.getLabelModel(label);
|
||||
};
|
||||
|
||||
window.WWebJS.getChatLabels = async (chatId) => {
|
||||
const chat = await window.WWebJS.getChat(chatId);
|
||||
return (chat.labels || []).map(id => window.WWebJS.getLabel(id));
|
||||
};
|
||||
};
|
||||
|
||||
exports.MarkAllRead = () => {
|
||||
|
||||
Reference in New Issue
Block a user