mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	starred_messages: Replace ids Dict with Set.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							1189747d4c
						
					
				
				
					commit
					b5cd8dcedd
				
			@@ -1,37 +1,33 @@
 | 
				
			|||||||
const Dict = require('./dict').Dict;
 | 
					exports.ids = new Set();
 | 
				
			||||||
 | 
					 | 
				
			||||||
exports.ids = new Dict();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.initialize = function () {
 | 
					exports.initialize = function () {
 | 
				
			||||||
    exports.ids = new Dict();
 | 
					    exports.ids.clear();
 | 
				
			||||||
    _.each(page_params.starred_messages, function (id) {
 | 
					    _.each(page_params.starred_messages, function (id) {
 | 
				
			||||||
        exports.ids.set(id, true);
 | 
					        exports.ids.add(id);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    exports.rerender_ui();
 | 
					    exports.rerender_ui();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.add = function (ids) {
 | 
					exports.add = function (ids) {
 | 
				
			||||||
    _.each(ids, function (id) {
 | 
					    _.each(ids, function (id) {
 | 
				
			||||||
        exports.ids.set(id, true);
 | 
					        exports.ids.add(id);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    exports.rerender_ui();
 | 
					    exports.rerender_ui();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.remove = function (ids) {
 | 
					exports.remove = function (ids) {
 | 
				
			||||||
    _.each(ids, function (id) {
 | 
					    _.each(ids, function (id) {
 | 
				
			||||||
        if (exports.ids.has(id)) {
 | 
					        exports.ids.delete(id);
 | 
				
			||||||
            exports.ids.del(id);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    exports.rerender_ui();
 | 
					    exports.rerender_ui();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.count = function () {
 | 
					exports.count = function () {
 | 
				
			||||||
    return exports.ids.num_items();
 | 
					    return exports.ids.size;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.get_starred_msg_ids = function () {
 | 
					exports.get_starred_msg_ids = function () {
 | 
				
			||||||
    return exports.ids.keys();
 | 
					    return [...exports.ids];
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.rerender_ui = function () {
 | 
					exports.rerender_ui = function () {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user