mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 12:03:46 +00:00 
			
		
		
		
	This reverts commit c7f710b8d4.
Because the back end still stores muted topics fundamentally using
stream name as a key, trying to cut over the client to use stream
id was just making things more brittle.  Mutes would work after
renaming the stream, which was progress in the change that we
revert here, but only until page load.  The other problem, which
is more severe, is that the order of page loading functions would
cause no mutes to happen at page load time.  This could be fixed
to some degree, but we should do a deeper fix on the back end.
		
	
		
			
				
	
	
		
			57 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| var muting = (function () {
 | |
| 
 | |
| var exports = {};
 | |
| 
 | |
| var muted_topics = new Dict({fold_case: true});
 | |
| 
 | |
| exports.add_muted_topic = function (stream, topic) {
 | |
|     var sub_dict = muted_topics.get(stream);
 | |
|     if (!sub_dict) {
 | |
|         sub_dict = new Dict({fold_case: true});
 | |
|         muted_topics.set(stream, sub_dict);
 | |
|     }
 | |
|     sub_dict.set(topic, true);
 | |
| };
 | |
| 
 | |
| exports.remove_muted_topic = function (stream, topic) {
 | |
|     var sub_dict = muted_topics.get(stream);
 | |
|     if (sub_dict) {
 | |
|         sub_dict.del(topic);
 | |
|     }
 | |
| };
 | |
| 
 | |
| exports.is_topic_muted = function (stream, topic) {
 | |
|     if (stream === undefined) {
 | |
|         return false;
 | |
|     }
 | |
|     var sub_dict = muted_topics.get(stream);
 | |
|     return sub_dict && sub_dict.get(topic);
 | |
| };
 | |
| 
 | |
| exports.get_muted_topics = function () {
 | |
|     var topics = [];
 | |
|     muted_topics.each(function (sub_dict, stream) {
 | |
|         _.each(sub_dict.keys(), function (topic) {
 | |
|             topics.push([stream, topic]);
 | |
|         });
 | |
|     });
 | |
|     return topics;
 | |
| };
 | |
| 
 | |
| exports.set_muted_topics = function (tuples) {
 | |
|     muted_topics = new Dict({fold_case: true});
 | |
| 
 | |
|     _.each(tuples, function (tuple) {
 | |
|         var stream = tuple[0];
 | |
|         var topic = tuple[1];
 | |
| 
 | |
|         exports.add_muted_topic(stream, topic);
 | |
|     });
 | |
| };
 | |
| 
 | |
| return exports;
 | |
| }());
 | |
| if (typeof module !== 'undefined') {
 | |
|     module.exports = muting;
 | |
| }
 |