transmit: Pass params directly instead of using opts.

This commit is contained in:
Evy Kassirer
2025-09-27 14:30:56 -07:00
committed by Tim Abbott
parent 53cbfb9086
commit 665bce3c13
4 changed files with 9 additions and 22 deletions

View File

@@ -322,10 +322,10 @@ shown here) and then sets up a click handler like below:
// data structure. // data structure.
var reply_content = data.choices[idx].reply; var reply_content = data.choices[idx].reply;
transmit.reply_message({ transmit.reply_message(
message: opts.message, opts.message,
content: reply_content, reply_content,
}); );
}); });
``` ```

View File

@@ -98,7 +98,7 @@ export function send_message(
}); });
} }
export function reply_message(opts: {message: Message; content: string}): void { export function reply_message(message: Message, content: string): void {
// This code does an application-triggered reply to a message (as // This code does an application-triggered reply to a message (as
// opposed to the user themselves doing it). Its only use case // opposed to the user themselves doing it). Its only use case
// for now is experimental widget-aware bots, so treat this as // for now is experimental widget-aware bots, so treat this as
@@ -106,8 +106,6 @@ export function reply_message(opts: {message: Message; content: string}): void {
// bot that wants to give users 3 or 4 canned replies to some // bot that wants to give users 3 or 4 canned replies to some
// choice, but it wants to front-end each of these options // choice, but it wants to front-end each of these options
// with a one-click button. This function is part of that architecture. // with a one-click button. This function is part of that architecture.
const message = opts.message;
let content = opts.content;
function success(): void { function success(): void {
// TODO: If server response comes back before the message event, // TODO: If server response comes back before the message event,

View File

@@ -39,10 +39,7 @@ export function activate(opts) {
// data structure. // data structure.
const reply_content = data.choices[idx].reply; const reply_content = data.choices[idx].reply;
transmit.reply_message({ transmit.reply_message(opts.message, reply_content);
message: opts.message,
content: reply_content,
});
}); });
return $elem; return $elem;

View File

@@ -158,10 +158,7 @@ run_test("reply_message_stream", ({override}) => {
server_events_state.queue_id = 66; server_events_state.queue_id = 66;
sent_messages.get_new_local_id = () => "99"; sent_messages.get_new_local_id = () => "99";
transmit.reply_message({ transmit.reply_message(stream_message, content);
message: stream_message,
content,
});
assert.deepEqual(send_message_args, { assert.deepEqual(send_message_args, {
sender_id: 44, sender_id: 44,
@@ -199,10 +196,7 @@ run_test("reply_message_private", ({override}) => {
server_events_state.queue_id = 177; server_events_state.queue_id = 177;
sent_messages.get_new_local_id = () => "199"; sent_messages.get_new_local_id = () => "199";
transmit.reply_message({ transmit.reply_message(pm_message, content);
message: pm_message,
content,
});
assert.deepEqual(send_message_args, { assert.deepEqual(send_message_args, {
sender_id: 155, sender_id: 155,
@@ -221,7 +215,5 @@ run_test("reply_message_errors", () => {
blueslip.expect("error", "unknown message type"); blueslip.expect("error", "unknown message type");
transmit.reply_message({ transmit.reply_message(bogus_message, "");
message: bogus_message,
});
}); });