mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	js: Convert static/js/starred_messages.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							5ae2f172d0
						
					
				
				
					commit
					636587665b
				
			@@ -187,7 +187,6 @@
 | 
			
		||||
                "settings_streams": false,
 | 
			
		||||
                "settings_user_groups": false,
 | 
			
		||||
                "settings_users": false,
 | 
			
		||||
                "starred_messages": false,
 | 
			
		||||
                "stream_list": false,
 | 
			
		||||
                "StripeCheckout": false,
 | 
			
		||||
                "subs": false,
 | 
			
		||||
 
 | 
			
		||||
@@ -7,7 +7,7 @@ const rewiremock = require("rewiremock/node");
 | 
			
		||||
const {set_global, zrequire} = require("../zjsunit/namespace");
 | 
			
		||||
const {run_test} = require("../zjsunit/test");
 | 
			
		||||
 | 
			
		||||
set_global("starred_messages", {
 | 
			
		||||
rewiremock("../../static/js/starred_messages").with({
 | 
			
		||||
    add: () => {},
 | 
			
		||||
    remove: () => {},
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
@@ -119,7 +119,6 @@ const compose = zrequire("compose");
 | 
			
		||||
zrequire("composebox_typeahead");
 | 
			
		||||
zrequire("narrow");
 | 
			
		||||
zrequire("stream_list");
 | 
			
		||||
zrequire("starred_messages");
 | 
			
		||||
zrequire("recent_topics");
 | 
			
		||||
 | 
			
		||||
run_test("initialize_everything", () => {
 | 
			
		||||
 
 | 
			
		||||
@@ -30,7 +30,6 @@ import "../ui";
 | 
			
		||||
import "../composebox_typeahead";
 | 
			
		||||
import "../hotkey";
 | 
			
		||||
import "../notifications";
 | 
			
		||||
import "../starred_messages";
 | 
			
		||||
import "../alert_words_ui";
 | 
			
		||||
import "../attachments_ui";
 | 
			
		||||
import "../message_store";
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1
									
								
								static/js/global.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								static/js/global.d.ts
									
									
									
									
										vendored
									
									
								
							@@ -59,7 +59,6 @@ declare let settings_sections: any;
 | 
			
		||||
declare let settings_streams: any;
 | 
			
		||||
declare let settings_user_groups: any;
 | 
			
		||||
declare let settings_users: any;
 | 
			
		||||
declare let starred_messages: any;
 | 
			
		||||
declare let stream_list: any;
 | 
			
		||||
declare let subs: any;
 | 
			
		||||
declare let message_view_header: any;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
import _ from "lodash";
 | 
			
		||||
 | 
			
		||||
import * as channel from "./channel";
 | 
			
		||||
import * as starred_messages from "./starred_messages";
 | 
			
		||||
 | 
			
		||||
function send_flag_update(message, flag, op) {
 | 
			
		||||
    channel.post({
 | 
			
		||||
 
 | 
			
		||||
@@ -16,6 +16,7 @@ import * as people from "./people";
 | 
			
		||||
import * as reload from "./reload";
 | 
			
		||||
import * as scroll_bar from "./scroll_bar";
 | 
			
		||||
import * as settings_config from "./settings_config";
 | 
			
		||||
import * as starred_messages from "./starred_messages";
 | 
			
		||||
import * as stream_data from "./stream_data";
 | 
			
		||||
import * as stream_events from "./stream_events";
 | 
			
		||||
import * as stream_topic_history from "./stream_topic_history";
 | 
			
		||||
 
 | 
			
		||||
@@ -1,45 +1,43 @@
 | 
			
		||||
"use strict";
 | 
			
		||||
import * as top_left_corner from "./top_left_corner";
 | 
			
		||||
 | 
			
		||||
const top_left_corner = require("./top_left_corner");
 | 
			
		||||
export const starred_ids = new Set();
 | 
			
		||||
 | 
			
		||||
exports.starred_ids = new Set();
 | 
			
		||||
 | 
			
		||||
exports.initialize = function () {
 | 
			
		||||
    exports.starred_ids.clear();
 | 
			
		||||
export function initialize() {
 | 
			
		||||
    starred_ids.clear();
 | 
			
		||||
 | 
			
		||||
    for (const id of page_params.starred_messages) {
 | 
			
		||||
        exports.starred_ids.add(id);
 | 
			
		||||
        starred_ids.add(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    exports.rerender_ui();
 | 
			
		||||
};
 | 
			
		||||
    rerender_ui();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.add = function (ids) {
 | 
			
		||||
export function add(ids) {
 | 
			
		||||
    for (const id of ids) {
 | 
			
		||||
        exports.starred_ids.add(id);
 | 
			
		||||
        starred_ids.add(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    exports.rerender_ui();
 | 
			
		||||
};
 | 
			
		||||
    rerender_ui();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.remove = function (ids) {
 | 
			
		||||
export function remove(ids) {
 | 
			
		||||
    for (const id of ids) {
 | 
			
		||||
        exports.starred_ids.delete(id);
 | 
			
		||||
        starred_ids.delete(id);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    exports.rerender_ui();
 | 
			
		||||
};
 | 
			
		||||
    rerender_ui();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.get_count = function () {
 | 
			
		||||
    return exports.starred_ids.size;
 | 
			
		||||
};
 | 
			
		||||
export function get_count() {
 | 
			
		||||
    return starred_ids.size;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.get_starred_msg_ids = function () {
 | 
			
		||||
    return Array.from(exports.starred_ids);
 | 
			
		||||
};
 | 
			
		||||
export function get_starred_msg_ids() {
 | 
			
		||||
    return Array.from(starred_ids);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
exports.rerender_ui = function () {
 | 
			
		||||
    let count = exports.get_count();
 | 
			
		||||
export function rerender_ui() {
 | 
			
		||||
    let count = get_count();
 | 
			
		||||
 | 
			
		||||
    if (!page_params.starred_message_counts) {
 | 
			
		||||
        // This essentially hides the count
 | 
			
		||||
@@ -47,6 +45,4 @@ exports.rerender_ui = function () {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    top_left_corner.update_starred_count(count);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
window.starred_messages = exports;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,7 @@ const sent_messages = require("./sent_messages");
 | 
			
		||||
const settings_panel_menu = require("./settings_panel_menu");
 | 
			
		||||
const settings_toggle = require("./settings_toggle");
 | 
			
		||||
const spoilers = require("./spoilers");
 | 
			
		||||
const starred_messages = require("./starred_messages");
 | 
			
		||||
const stream_color = require("./stream_color");
 | 
			
		||||
const stream_data = require("./stream_data");
 | 
			
		||||
const stream_edit = require("./stream_edit");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user