PollData: Pass in function for rendering user names.

This will make it easier to share this code with the mobile app, which
does not use people.js.
This commit is contained in:
Wesley Aptekar-Cassels
2021-04-16 18:00:05 +08:00
committed by Steve Howell
parent 331927bbbe
commit 42f328fec6
2 changed files with 12 additions and 2 deletions

View File

@@ -15,11 +15,19 @@ 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,
comma_separated_names,
report_error_function,
}) {
this.me = current_user_id;
this.is_my_poll = is_my_poll;
this.poll_question = question;
this.input_mode = is_my_poll; // for now
this.comma_separated_names = comma_separated_names;
this.report_error_function = report_error_function;
if (question) {
@@ -64,7 +72,7 @@ export class PollData {
options.push({
option: obj.option,
names: people.safe_full_names(voters),
names: this.comma_separated_names(voters),
count: voters.length,
key,
current_user_vote,
@@ -192,6 +200,7 @@ export function activate({
is_my_poll,
question,
options,
comma_separated_names: people.safe_full_names,
report_error_function: blueslip.warn,
});