const Dict = require('./dict').Dict;

exports.ids = new Dict();

exports.initialize = function () {
    exports.ids = new Dict();
    _.each(page_params.starred_messages, function (id) {
        exports.ids.set(id, true);
    });
    exports.rerender_ui();
};

exports.add = function (ids) {
    _.each(ids, function (id) {
        exports.ids.set(id, true);
    });
    exports.rerender_ui();
};

exports.remove = function (ids) {
    _.each(ids, function (id) {
        if (exports.ids.has(id)) {
            exports.ids.del(id);
        }
    });
    exports.rerender_ui();
};

exports.count = function () {
    return exports.ids.num_items();
};

exports.get_starred_msg_ids = function () {
    return exports.ids.keys();
};

exports.rerender_ui = function () {
    let count = exports.count();

    if (!page_params.starred_message_counts) {
        // This essentially hides the count
        count = 0;
    }

    top_left_corner.update_starred_count(count);
};

window.starred_messages = exports;

@@ -1,42 +1,4 @@
-const Dict = require('./dict').Dict;%0A%0A
 expo
@@ -7,27 +7,26 @@
 s.ids = new 
-Dic
+Se
 t();%0A%0Aexport
@@ -73,19 +73,14 @@
 .ids
- = new Dict
+.clear
 ();%0A
@@ -152,36 +152,30 @@
 exports.ids.
-set(id, true
+add(id
 );%0A    %7D);%0A 
@@ -291,20 +291,14 @@
 ids.
-set(id, true
+add(id
 );%0A 
@@ -409,20 +409,16 @@
         
-if (
 exports.
@@ -425,61 +425,19 @@
 ids.
-has(id)) %7B%0A            exports.ids.del(id);%0A        %7D
+delete(id);
 %0A   
@@ -529,19 +529,12 @@
 ids.
-num_items()
+size
 ;%0A%7D;
@@ -582,32 +582,36 @@
 () %7B%0A    return 
+%5B...
 exports.ids.keys
@@ -609,15 +609,9 @@
 .ids
-.keys()
+%5D
 ;%0A%7D;

Replace ids Dict with Set.