stream_events: Assume mark_unsusbscribed sub is defined.

THere's only one call to this function, which should have
a defined `sub`, so we can enforce this through typescript
instead of doing an `undefined` check.
This commit is contained in:
evykassirer 2024-11-25 17:03:30 -08:00 committed by Tim Abbott
parent 12c18a026b
commit 8fff2fcd3c
2 changed files with 2 additions and 10 deletions

View File

@ -247,11 +247,8 @@ export function mark_subscribed(
user_profile.update_user_profile_streams_list_for_users([people.my_current_user_id()]);
}
export function mark_unsubscribed(sub: StreamSubscription | undefined): void {
if (sub === undefined) {
// We don't know about this stream
return;
} else if (sub.subscribed) {
export function mark_unsubscribed(sub: StreamSubscription): void {
if (sub.subscribed) {
stream_data.unsubscribe_myself(sub);
if (overlays.streams_open()) {
stream_settings_ui.update_settings_for_unsubscribed(sub);

View File

@ -277,11 +277,6 @@ test("update_property", ({override}) => {
}
});
test("marked_unsubscribed (code coverage)", () => {
// We don't error for unsubscribed streams for some reason.
stream_events.mark_unsubscribed(undefined);
});
test("marked_(un)subscribed (early return)", () => {
// The early-return prevents us from exploding or needing
// to override functions with side effects