message_events: Don't accept undefined filter in filter_has_term_type.

Accepting an undefined Filter  has no advantage; every caller either
passes a defined Filter or has to later check for undefined anyway.
This commit is contained in:
evykassirer
2024-12-06 22:00:19 -08:00
committed by Tim Abbott
parent ca4e425031
commit f241aa77c1

View File

@@ -41,9 +41,8 @@ import * as util from "./util.ts";
function filter_has_term_type(filter, term_type) { function filter_has_term_type(filter, term_type) {
return ( return (
filter !== undefined && filter.sorted_term_types().includes(term_type) ||
(filter.sorted_term_types().includes(term_type) || filter.sorted_term_types().includes(`not-${term_type}`)
filter.sorted_term_types().includes(`not-${term_type}`))
); );
} }
@@ -81,7 +80,7 @@ export function update_current_view_for_topic_visibility() {
// is easier to just load the narrow from scratch, instead of asking server // is easier to just load the narrow from scratch, instead of asking server
// for relevant messages in the updated topic. // for relevant messages in the updated topic.
const filter = message_lists.current?.data.filter; const filter = message_lists.current?.data.filter;
if (filter_has_term_type(filter, "is-followed")) { if (filter !== undefined && filter_has_term_type(filter, "is-followed")) {
// Use `set_timeout to call after we update the topic // Use `set_timeout to call after we update the topic
// visibility policy locally. // visibility policy locally.
// Calling this outside `user_topics_ui` to avoid circular imports. // Calling this outside `user_topics_ui` to avoid circular imports.