message_fetch: Don't allow undefined narrow term operands.

This commit is contained in:
evykassirer
2024-09-24 12:00:58 -07:00
committed by Tim Abbott
parent 65f465562f
commit b2e1c5aec4

View File

@@ -349,10 +349,12 @@ export function load_messages(opts: MessageFetchOptions, attempt = 1): void {
const sub = stream_data.get_sub_by_id_string(term.operand); const sub = stream_data.get_sub_by_id_string(term.operand);
server_terms.push({ server_terms.push({
...term, ...term,
// If the sub is undefined, we'll get an error which is handled // If we can't find the sub, we shouldn't send `undefined`
// later by showing a "this channel does not exist or is private" // because we want to preserve the NarrowTerm type, so we just
// notice. // send the unknown stream id.
operand: sub?.name, // This should show a "this channel does not exist or is private"
// notice (both logged in and logged out).
operand: sub?.name ?? term.operand,
}); });
} else { } else {
server_terms.push({...term}); server_terms.push({...term});