mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 14:03:30 +00:00 
			
		
		
		
	Fix type errors in LazySet.
I think the only place that was broken is where we copy users from streams.
This commit is contained in:
		
							
								
								
									
										23
									
								
								frontend_tests/node_tests/lazy_set.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								frontend_tests/node_tests/lazy_set.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
				
			|||||||
 | 
					set_global('blueslip', global.make_zblueslip());
 | 
				
			||||||
 | 
					const LazySet = zrequire('lazy_set').LazySet;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					    We mostly test LazySet indirectly.  This code
 | 
				
			||||||
 | 
					    may be short-lived, anyway, once we change
 | 
				
			||||||
 | 
					    how we download subscribers in page_params.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					run_test('map', () => {
 | 
				
			||||||
 | 
					    const ls = LazySet([1, 2]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const triple = (n) => n * 3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assert.deepEqual(ls.map(triple), [3, 6]);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					run_test('conversions', () => {
 | 
				
			||||||
 | 
					    blueslip.set_test_data('error', 'not a number');
 | 
				
			||||||
 | 
					    const ls = LazySet([1, 2]);
 | 
				
			||||||
 | 
					    ls.add('3');
 | 
				
			||||||
 | 
					    assert(ls.has('3'));
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
@@ -53,18 +53,30 @@ exports.LazySet = function (vals) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    self.has = function (v) {
 | 
					    self.has = function (v) {
 | 
				
			||||||
        make_set();
 | 
					        make_set();
 | 
				
			||||||
        return self.set.has(v);
 | 
					        const val = self._clean(v);
 | 
				
			||||||
 | 
					        return self.set.has(val);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    self.add = function (v) {
 | 
					    self.add = function (v) {
 | 
				
			||||||
        make_set();
 | 
					        make_set();
 | 
				
			||||||
        self.set.add(v);
 | 
					        const val = self._clean(v);
 | 
				
			||||||
 | 
					        self.set.add(val);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    self.del = function (v) {
 | 
					    self.del = function (v) {
 | 
				
			||||||
        make_set();
 | 
					        make_set();
 | 
				
			||||||
        self.set.delete(v);
 | 
					        const val = self._clean(v);
 | 
				
			||||||
 | 
					        self.set.delete(val);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    self._clean = function (v) {
 | 
				
			||||||
 | 
					        if (typeof v !== 'number') {
 | 
				
			||||||
 | 
					            blueslip.error('not a number');
 | 
				
			||||||
 | 
					            return parseInt(v, 10);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return v;
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return self;
 | 
					    return self;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -288,7 +288,8 @@ exports.show_new_stream_modal = function () {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $('#user-checkboxes label.checkbox').each(function () {
 | 
					        $('#user-checkboxes label.checkbox').each(function () {
 | 
				
			||||||
            const user_elem = $(this);
 | 
					            const user_elem = $(this);
 | 
				
			||||||
            const user_id = user_elem.attr('data-user-id');
 | 
					            const str_user_id = user_elem.attr('data-user-id');
 | 
				
			||||||
 | 
					            const user_id = parseInt(str_user_id, 10);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (subscriber_ids.has(user_id)) {
 | 
					            if (subscriber_ids.has(user_id)) {
 | 
				
			||||||
                user_elem.find('input').prop('checked', checked);
 | 
					                user_elem.find('input').prop('checked', checked);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,6 +52,7 @@ enforce_fully_covered = {
 | 
				
			|||||||
    'static/js/keydown_util.js',
 | 
					    'static/js/keydown_util.js',
 | 
				
			||||||
    'static/js/input_pill.js',
 | 
					    'static/js/input_pill.js',
 | 
				
			||||||
    'static/js/int_dict.ts',
 | 
					    'static/js/int_dict.ts',
 | 
				
			||||||
 | 
					    'static/js/lazy_set.js',
 | 
				
			||||||
    'static/js/list_cursor.js',
 | 
					    'static/js/list_cursor.js',
 | 
				
			||||||
    'static/js/markdown.js',
 | 
					    'static/js/markdown.js',
 | 
				
			||||||
    'static/js/message_store.js',
 | 
					    'static/js/message_store.js',
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user