mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 03:29:14 +00:00
extra options can override other options when sending message (#1103)
* Fix the option to use special options When we want to use some extra function we need to pass it into the options object, but because it inserted in the first line, the auto options reset some options (like 'type'). This is minor change that can help to add functionallity * Update Injected.js Put the special options in the end * Update Injected.js Fix , mistake * only `extra` options can override everything else Co-authored-by: Pedro Lopez <pedroslopez@me.com>
This commit is contained in:
@@ -153,7 +153,7 @@ exports.LoadUtils = () => {
|
||||
}
|
||||
}
|
||||
|
||||
let extraOptions = {};
|
||||
let buttonOptions = {};
|
||||
if(options.buttons){
|
||||
let caption;
|
||||
if(options.buttons.type === 'chat') {
|
||||
@@ -162,7 +162,7 @@ exports.LoadUtils = () => {
|
||||
}else{
|
||||
caption = options.caption ? options.caption : ' '; //Caption can't be empty
|
||||
}
|
||||
extraOptions = {
|
||||
buttonOptions = {
|
||||
productHeaderImageRejected: false,
|
||||
isFromTemplate: false,
|
||||
isDynamicReplyButtonsMsg: true,
|
||||
@@ -175,12 +175,12 @@ exports.LoadUtils = () => {
|
||||
delete options.buttons;
|
||||
}
|
||||
|
||||
let listOptions = {};
|
||||
if(options.list){
|
||||
if(window.Store.Conn.platform === 'smba' || window.Store.Conn.platform === 'smbi'){
|
||||
throw '[LT01] Whatsapp business can\'t send this yet';
|
||||
}
|
||||
extraOptions = {
|
||||
...extraOptions,
|
||||
listOptions = {
|
||||
type: 'list',
|
||||
footer: options.list.footer,
|
||||
list: {
|
||||
@@ -190,7 +190,7 @@ exports.LoadUtils = () => {
|
||||
body: options.list.description
|
||||
};
|
||||
delete options.list;
|
||||
delete extraOptions.list.footer;
|
||||
delete listOptions.list.footer;
|
||||
}
|
||||
|
||||
const newMsgId = new window.Store.MsgKey({
|
||||
@@ -199,6 +199,9 @@ exports.LoadUtils = () => {
|
||||
id: window.Store.genId(),
|
||||
});
|
||||
|
||||
const extraOptions = options.extraOptions || {};
|
||||
delete options.extraOptions;
|
||||
|
||||
const message = {
|
||||
...options,
|
||||
id: newMsgId,
|
||||
@@ -215,6 +218,8 @@ exports.LoadUtils = () => {
|
||||
...attOptions,
|
||||
...quotedMsgOptions,
|
||||
...vcardOptions,
|
||||
...buttonOptions,
|
||||
...listOptions,
|
||||
...extraOptions
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user