filter: Fix bug where invalid stream name could throw an error.

This commit is contained in:
evykassirer 2024-09-24 11:26:27 -07:00 committed by Tim Abbott
parent 758fdc87e0
commit 7bff149325
1 changed files with 11 additions and 8 deletions

View File

@ -724,14 +724,17 @@ export class Filter {
Filter.canonicalize_operator(term.operator) === expected && !term.negated;
if (is(terms[0], "channel") && is(terms[1], "topic")) {
const channel = stream_data.get_valid_sub_by_id_string(terms[0].operand).name;
const topic = terms[1].operand;
parts.push({
type: "channel_topic",
channel,
topic,
});
terms = terms.slice(2);
// `channel` might be undefined if it's coming from a text query
const channel = stream_data.get_sub_by_id_string(terms[0].operand)?.name;
if (channel) {
const topic = terms[1].operand;
parts.push({
type: "channel_topic",
channel,
topic,
});
terms = terms.slice(2);
}
}
}