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.
var reply_content = data.choices[idx].reply;
transmit.reply_message({
message: opts.message,
content: reply_content,
});
transmit.reply_message(
opts.message,
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
// opposed to the user themselves doing it). Its only use case
// 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
// choice, but it wants to front-end each of these options
// with a one-click button. This function is part of that architecture.
const message = opts.message;
let content = opts.content;
function success(): void {
// TODO: If server response comes back before the message event,

View File

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

View File

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