From 331927bbbeadfcaf5d4f3a82db8231d23b7e2020 Mon Sep 17 00:00:00 2001 From: Wesley Aptekar-Cassels Date: Fri, 16 Apr 2021 17:54:38 +0800 Subject: [PATCH] PollData: Use options object, rather than positional args. --- frontend_tests/node_tests/poll_widget.js | 8 +++++++- static/js/poll_widget.js | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/frontend_tests/node_tests/poll_widget.js b/frontend_tests/node_tests/poll_widget.js index 97902d9905..240afe1a22 100644 --- a/frontend_tests/node_tests/poll_widget.js +++ b/frontend_tests/node_tests/poll_widget.js @@ -32,7 +32,13 @@ run_test("PollData my question", () => { const is_my_poll = true; const question = "Favorite color?"; - const data_holder = new poll_widget.PollData(me.user_id, is_my_poll, question, [], blueslip.warn); + const data_holder = new poll_widget.PollData({ + current_user_id: me.user_id, + is_my_poll, + question, + options: [], + report_error_function: blueslip.warn, + }); let data = data_holder.get_widget_data(); diff --git a/static/js/poll_widget.js b/static/js/poll_widget.js index 35f54f947d..d1dbad02f8 100644 --- a/static/js/poll_widget.js +++ b/static/js/poll_widget.js @@ -15,7 +15,7 @@ export class PollData { key_to_option = new Map(); my_idx = 1; - constructor(current_user_id, is_my_poll, question, options, report_error_function) { + constructor({current_user_id, is_my_poll, question, options, report_error_function}) { this.me = current_user_id; this.is_my_poll = is_my_poll; this.poll_question = question; @@ -187,13 +187,13 @@ export function activate({ message, }) { const is_my_poll = people.is_my_user_id(message.sender_id); - const poll_data = new PollData( - people.my_current_user_id(), + const poll_data = new PollData({ + current_user_id: people.my_current_user_id(), is_my_poll, question, options, - blueslip.warn, - ); + report_error_function: blueslip.warn, + }); function update_edit_controls() { const has_question = elem.find("input.poll-question").val().trim() !== "";