mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	topic_data: Rename recent_topics to stream_dict.
The var in question is indexed by stream_id, so stream_dict seems like a good name for it. We want to distinguish per-stream data structures from the stream-level entry points.
This commit is contained in:
		@@ -2,10 +2,10 @@ var topic_data = (function () {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
var exports = {};
 | 
					var exports = {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var recent_topics = new Dict(); // stream_id -> array of objects
 | 
					var stream_dict = new Dict(); // stream_id -> array of objects
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.stream_has_topics = function (stream_id) {
 | 
					exports.stream_has_topics = function (stream_id) {
 | 
				
			||||||
    return recent_topics.has(stream_id);
 | 
					    return stream_dict.has(stream_id);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.process_message = function (message, remove_message) {
 | 
					exports.process_message = function (message, remove_message) {
 | 
				
			||||||
@@ -14,7 +14,7 @@ exports.process_message = function (message, remove_message) {
 | 
				
			|||||||
    var stream_id = message.stream_id;
 | 
					    var stream_id = message.stream_id;
 | 
				
			||||||
    var canon_topic = message.subject.toLowerCase();
 | 
					    var canon_topic = message.subject.toLowerCase();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var recents = recent_topics.get(stream_id) || [];
 | 
					    var recents = stream_dict.get(stream_id) || [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    recents = _.filter(recents, function (item) {
 | 
					    recents = _.filter(recents, function (item) {
 | 
				
			||||||
        var is_duplicate = (
 | 
					        var is_duplicate = (
 | 
				
			||||||
@@ -42,11 +42,11 @@ exports.process_message = function (message, remove_message) {
 | 
				
			|||||||
        return b.timestamp - a.timestamp;
 | 
					        return b.timestamp - a.timestamp;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    recent_topics.set(stream_id, recents);
 | 
					    stream_dict.set(stream_id, recents);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
exports.get_recent_names = function (stream_id) {
 | 
					exports.get_recent_names = function (stream_id) {
 | 
				
			||||||
    var topic_objs = recent_topics.get(stream_id);
 | 
					    var topic_objs = stream_dict.get(stream_id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (!topic_objs) {
 | 
					    if (!topic_objs) {
 | 
				
			||||||
        return [];
 | 
					        return [];
 | 
				
			||||||
@@ -59,7 +59,7 @@ exports.get_recent_names = function (stream_id) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
exports.populate_for_tests = function (stream_map) {
 | 
					exports.populate_for_tests = function (stream_map) {
 | 
				
			||||||
    // This is only used by tests.
 | 
					    // This is only used by tests.
 | 
				
			||||||
    recent_topics = Dict.from(stream_map);
 | 
					    stream_dict = Dict.from(stream_map);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return exports;
 | 
					return exports;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user