refactor: Remove stream_data.get_default_status().

There was no reason to have this when it's more
robust to look up streams by id than name.
This commit is contained in:
Steve Howell 2020-03-22 16:04:47 +00:00 committed by Tim Abbott
parent abc0c4d48c
commit 4610ef3169
2 changed files with 5 additions and 15 deletions

View File

@ -101,9 +101,9 @@ run_test('basics', () => {
assert.equal(stream_data.maybe_get_stream_name(42), undefined); assert.equal(stream_data.maybe_get_stream_name(42), undefined);
stream_data.set_realm_default_streams([denmark]); stream_data.set_realm_default_streams([denmark]);
assert(stream_data.get_default_status('Denmark')); assert(stream_data.is_default_stream_id(denmark.stream_id));
assert(!stream_data.get_default_status('social')); assert(!stream_data.is_default_stream_id(social.stream_id));
assert(!stream_data.get_default_status('UNKNOWN')); assert(!stream_data.is_default_stream_id(999999));
}); });
run_test('renames', () => { run_test('renames', () => {
@ -745,7 +745,7 @@ run_test('remove_default_stream', () => {
stream_data.add_sub(remove_me); stream_data.add_sub(remove_me);
stream_data.set_realm_default_streams([remove_me]); stream_data.set_realm_default_streams([remove_me]);
stream_data.remove_default_stream(remove_me.stream_id); stream_data.remove_default_stream(remove_me.stream_id);
assert(!stream_data.get_default_status('remove_me')); assert(!stream_data.is_default_stream_id(remove_me.stream_id));
assert.equal(page_params.realm_default_streams.length, 0); assert.equal(page_params.realm_default_streams.length, 0);
}); });

View File

@ -338,7 +338,7 @@ exports.get_invite_stream_data = function () {
name: sub.name, name: sub.name,
stream_id: sub.stream_id, stream_id: sub.stream_id,
invite_only: sub.invite_only, invite_only: sub.invite_only,
default_stream: exports.get_default_status(sub.name), default_stream: default_stream_ids.has(sub.stream_id),
}; };
}; };
const invite_stream_data = exports.subscribed_subs().map(filter_stream_data); const invite_stream_data = exports.subscribed_subs().map(filter_stream_data);
@ -598,16 +598,6 @@ exports.get_default_stream_ids = function () {
return Array.from(default_stream_ids); return Array.from(default_stream_ids);
}; };
exports.get_default_status = function (stream_name) {
const stream_id = exports.get_stream_id(stream_name);
if (!stream_id) {
return false;
}
return default_stream_ids.has(stream_id);
};
exports.is_default_stream_id = function (stream_id) { exports.is_default_stream_id = function (stream_id) {
return default_stream_ids.has(stream_id); return default_stream_ids.has(stream_id);
}; };