mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	PollData: Use options object, rather than positional args.
This commit is contained in:
		
				
					committed by
					
						
						Steve Howell
					
				
			
			
				
	
			
			
			
						parent
						
							bef67d7bf1
						
					
				
				
					commit
					331927bbbe
				
			@@ -32,7 +32,13 @@ run_test("PollData my question", () => {
 | 
				
			|||||||
    const is_my_poll = true;
 | 
					    const is_my_poll = true;
 | 
				
			||||||
    const question = "Favorite color?";
 | 
					    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();
 | 
					    let data = data_holder.get_widget_data();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,7 +15,7 @@ export class PollData {
 | 
				
			|||||||
    key_to_option = new Map();
 | 
					    key_to_option = new Map();
 | 
				
			||||||
    my_idx = 1;
 | 
					    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.me = current_user_id;
 | 
				
			||||||
        this.is_my_poll = is_my_poll;
 | 
					        this.is_my_poll = is_my_poll;
 | 
				
			||||||
        this.poll_question = question;
 | 
					        this.poll_question = question;
 | 
				
			||||||
@@ -187,13 +187,13 @@ export function activate({
 | 
				
			|||||||
    message,
 | 
					    message,
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
    const is_my_poll = people.is_my_user_id(message.sender_id);
 | 
					    const is_my_poll = people.is_my_user_id(message.sender_id);
 | 
				
			||||||
    const poll_data = new PollData(
 | 
					    const poll_data = new PollData({
 | 
				
			||||||
        people.my_current_user_id(),
 | 
					        current_user_id: people.my_current_user_id(),
 | 
				
			||||||
        is_my_poll,
 | 
					        is_my_poll,
 | 
				
			||||||
        question,
 | 
					        question,
 | 
				
			||||||
        options,
 | 
					        options,
 | 
				
			||||||
        blueslip.warn,
 | 
					        report_error_function: blueslip.warn,
 | 
				
			||||||
    );
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    function update_edit_controls() {
 | 
					    function update_edit_controls() {
 | 
				
			||||||
        const has_question = elem.find("input.poll-question").val().trim() !== "";
 | 
					        const has_question = elem.find("input.poll-question").val().trim() !== "";
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user