drafts: Fix bug opening drafts in 'general chat'.
Some checks failed
Code scanning / CodeQL (push) Has been cancelled
Zulip production suite / Ubuntu 22.04 production build (push) Has been cancelled
Zulip CI / ${{ matrix.name }} (zulip/ci:bookworm, true, false, Debian 12 (Python 3.11, backend + documentation), bookworm) (push) Has been cancelled
Zulip CI / ${{ matrix.name }} (zulip/ci:jammy, false, true, Ubuntu 22.04 (Python 3.10, backend + frontend), jammy) (push) Has been cancelled
Zulip CI / ${{ matrix.name }} (zulip/ci:noble, false, false, Ubuntu 24.04 (Python 3.12, backend), noble) (push) Has been cancelled
Zulip production suite / ${{ matrix.name }} (zulip/ci:bookworm, --test-custom-db, Debian 12 production install with custom db name and user, bookworm) (push) Has been cancelled
Zulip production suite / ${{ matrix.name }} (zulip/ci:jammy, , Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga, jammy) (push) Has been cancelled
Zulip production suite / ${{ matrix.name }} (zulip/ci:noble, , Ubuntu 24.04 production install, noble) (push) Has been cancelled
Zulip production suite / ${{ matrix.name }} (zulip/ci:bookworm-7.0, 7.0 Version Upgrade, bookworm) (push) Has been cancelled
Zulip production suite / ${{ matrix.name }} (zulip/ci:bookworm-8.0, 8.0 Version Upgrade, bookworm) (push) Has been cancelled
Zulip production suite / ${{ matrix.name }} (zulip/ci:jammy-6.0, 6.0 Version Upgrade, jammy) (push) Has been cancelled
Zulip production suite / ${{ matrix.name }} (zulip/ci:noble-9.0, 9.0 Version Upgrade, noble) (push) Has been cancelled

This was likely a longstanding issue that wasn't
caught because we required topics on CZO. The new
logic ensures topic match even for empty string
(general chat) topics.
This commit is contained in:
evykassirer 2025-03-25 16:10:03 -07:00 committed by Tim Abbott
parent f6b3d59c35
commit 8a51fa4b83

View File

@ -506,9 +506,9 @@ export function filter_drafts_by_compose_box_and_recipient(
// Match by stream and topic.
if (
stream_id &&
topic &&
topic !== undefined &&
draft.type === "stream" &&
draft.topic &&
draft.topic !== undefined &&
draft.stream_id !== undefined &&
util.same_recipient(
{type: "stream", stream_id: draft.stream_id, topic: draft.topic},
@ -518,7 +518,12 @@ export function filter_drafts_by_compose_box_and_recipient(
narrow_drafts_ids.push(id);
}
// Match by only stream.
else if (draft.type === "stream" && stream_id && !topic && draft.stream_id === stream_id) {
else if (
draft.type === "stream" &&
stream_id &&
topic === undefined &&
draft.stream_id === stream_id
) {
narrow_drafts_ids.push(id);
}
// Match by direct message recipient.