Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

transmit: Pass params directly instead of using opts.

Evy Kassirer665bce3c13c6
diff --git a/docs/subsystems/widgets.md b/docs/subsystems/widgets.md
index 01a08fa0686..24409580b24 100644
--- a/docs/subsystems/widgets.md
+++ b/docs/subsystems/widgets.md
@@ -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,
+ );
});
```
diff --git a/web/src/transmit.ts b/web/src/transmit.ts
index 5bfa9b2824f..3945694ec84 100644
--- a/web/src/transmit.ts
+++ b/web/src/transmit.ts
@@ -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,
diff --git a/web/src/zform.js b/web/src/zform.js
index 1194fbd3a11..6f5f938c947 100644
--- a/web/src/zform.js
+++ b/web/src/zform.js
@@ -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;
diff --git a/web/tests/transmit.test.cjs b/web/tests/transmit.test.cjs
index e7e2fc2ba6e..756c97a907b 100644
--- a/web/tests/transmit.test.cjs
+++ b/web/tests/transmit.test.cjs
@@ -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, "");
});