feat: group mentions + improved user mentions (#2602)

* added logic to mention groups + fixed user mentions

* usage example updated

* docs fixed

* window.injectToFunction clarifications

* usage example clarifications

* fix: typo

* docs: added missed docs
This commit is contained in:
alechkos 2024-01-11 10:33:10 +02:00 • committed by GitHub
commit e0d955f130
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,12 +58,12 @@ exports.ExposeStore = (moduleRaidStr) => {
window.Store.LidUtils = window.mR.findModule('getCurrentLid')[0];
window.Store.WidToJid = window.mR.findModule('widToUserJid')[0];
window.Store.JidToWid = window.mR.findModule('userJidToUserWid')[0];
window.Store.getMsgInfo = (window.mR.findModule('sendQueryMsgInfo')[0] || {}).sendQueryMsgInfo || window.mR.findModule('queryMsgInfo')[0].queryMsgInfo;
window.Store.pinUnpinMsg = window.mR.findModule('sendPinInChatMsg')[0].sendPinInChatMsg;
/* eslint-disable no-undef, no-cond-assign */
window.Store.QueryExist = ((m = window.mR.findModule('queryExists')[0]) ? m.queryExists : window.mR.findModule('queryExist')[0].queryWidExists);
window.Store.ReplyUtils = (m = window.mR.findModule('canReplyMsg')).length > 0 && m[0];
window.Store.getMsgInfo = (window.mR.findModule('sendQueryMsgInfo')[0] || {}).sendQueryMsgInfo || window.mR.findModule('queryMsgInfo')[0].queryMsgInfo;
/* eslint-enable no-undef, no-cond-assign */
window.Store.Settings = {
@ -195,7 +195,22 @@ exports.LoadUtils = () => {
}
if (options.mentionedJidList) {
options.mentionedJidList = options.mentionedJidList.map(cId => window.Store.Contact.get(cId).id);
options.mentionedJidList = await Promise.all(
options.mentionedJidList.map(async (id) => {
const wid = window.Store.WidFactory.createWid(id);
if (await window.Store.QueryExist(wid)) {
return wid;
}
})
);
options.mentionedJidList = options.mentionedJidList.filter(Boolean);
}
if (options.groupMentions) {
options.groupMentions = options.groupMentions.map((e) => ({
groupSubject: e.subject,
groupJid: window.Store.WidFactory.createWid(e.id)
}));
}
let locationOptions = {};
@ -368,7 +383,22 @@ exports.LoadUtils = () => {
delete options.extraOptions;
if (options.mentionedJidList) {
options.mentionedJidList = options.mentionedJidList.map(cId => window.Store.Contact.get(cId).id);
options.mentionedJidList = await Promise.all(
options.mentionedJidList.map(async (id) => {
const wid = window.Store.WidFactory.createWid(id);
if (await window.Store.QueryExist(wid)) {
return wid;
}
})
);
options.mentionedJidList = options.mentionedJidList.filter(Boolean);
}
if (options.groupMentions) {
options.groupMentions = options.groupMentions.map((e) => ({
groupSubject: e.subject,
groupJid: window.Store.WidFactory.createWid(e.id)
}));
}
if (options.linkPreview) {