Allow pre-filling the message dialog
Given that send_message_dialog() fills the form with previous inputs if there are any, we can also provide data to pre-fill the first form. This can be useful for preset dialogs, like an "all players" dialog with all players already input. Add an initial data parameter to send_message_dialog() and add it to the message list if it is provided.
This commit is contained in:
parent
effbe22fa1
commit
a091ce93df
1 changed files with 9 additions and 1 deletions
|
@ -71,16 +71,24 @@ async function create_history_journal(user) {
|
|||
* This allows us to populate the form with previous inputs and go back and forth
|
||||
* within the chain, to be able to fix mistakes or send fewer messages.
|
||||
*
|
||||
* We also use this to pre-fill the first form with data if any is passed.
|
||||
*
|
||||
* NOTE: The recipients are the same for all the messages of a chain, to simplify
|
||||
* the processing later as we only have to build one array of messages, shared among
|
||||
* the recipients.
|
||||
*
|
||||
* @param {MessageFormResponse|null} initial_form_data Data to pre-fill the first form with.
|
||||
* @returns {Promise<void>} The Promise for the processing of the messages.
|
||||
*/
|
||||
async function send_message_dialog() {
|
||||
async function send_message_dialog(initial_form_data = null) {
|
||||
/** @type{MessageFormResponse[]} */
|
||||
let messages = []
|
||||
let current_message = 0
|
||||
|
||||
if (initial_form_data !== null) {
|
||||
messages.push(initial_form_data);
|
||||
}
|
||||
|
||||
let chain = false;
|
||||
do {
|
||||
if (chain) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue