mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Added stream_data.get_name().
This function returns the stream's actual name, if we can get it; otherwise, it's the identity function. (imported from commit 7a981adba9632d6c6eba54cb6514a9226d1e83e8)
This commit is contained in:
		@@ -75,6 +75,19 @@ exports.get_invite_only = function (stream_name) {
 | 
				
			|||||||
    return sub.invite_only;
 | 
					    return sub.invite_only;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					exports.get_name = function (stream_name) {
 | 
				
			||||||
 | 
					    // This returns the actual name of a stream if we are subscribed to
 | 
				
			||||||
 | 
					    // it (i.e "Denmark" vs. "denmark"), while falling thru to
 | 
				
			||||||
 | 
					    // stream_name if we don't have a subscription.  (Stream names
 | 
				
			||||||
 | 
					    // are case-insensitive, but we try to display the actual name
 | 
				
			||||||
 | 
					    // when we know it.)
 | 
				
			||||||
 | 
					    var sub = exports.get_sub(stream_name);
 | 
				
			||||||
 | 
					    if (sub === undefined) {
 | 
				
			||||||
 | 
					        return stream_name;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return sub.name;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
return exports;
 | 
					return exports;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}());
 | 
					}());
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,4 +36,7 @@ var stream_data = require('js/stream_data.js');
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    assert(stream_data.get_invite_only('social'));
 | 
					    assert(stream_data.get_invite_only('social'));
 | 
				
			||||||
    assert.equal(stream_data.get_color('social'), 'red');
 | 
					    assert.equal(stream_data.get_color('social'), 'red');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    assert.equal(stream_data.get_name('denMARK'), 'Denmark');
 | 
				
			||||||
 | 
					    assert.equal(stream_data.get_name('unknown Stream'), 'unknown Stream');
 | 
				
			||||||
}());
 | 
					}());
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user