unread_ops: Convert stream ids to integers before sending request to server.

This bug was introduced in #31299, which replaced the channel name
with a string id. It's still valid to send the channel id to the
server, but it shouldn't be a string, it should be a number.
(See https://zulip.com/api/construct-narrow#channel-and-user-ids)

In the future, we hope to update NarrowTerm to allow for integer
operands for channel terms.
This commit is contained in:
evykassirer 2024-09-20 12:10:57 -07:00 committed by Tim Abbott
parent 57c39fc257
commit 52440c1cff
1 changed files with 10 additions and 1 deletions

View File

@ -89,6 +89,15 @@ function bulk_update_read_flags_for_narrow(
caller_modal_id?: string, caller_modal_id?: string,
): void { ): void {
let response_html; let response_html;
const terms_with_integer_channel_id = narrow.map((term) => {
if (term.operator === "channel") {
return {
...term,
operand: Number.parseInt(term.operand, 10),
};
}
return term;
});
const request = { const request = {
anchor, anchor,
// anchor="oldest" is an anchor ID lower than any valid // anchor="oldest" is an anchor ID lower than any valid
@ -100,7 +109,7 @@ function bulk_update_read_flags_for_narrow(
num_after, num_after,
op, op,
flag: "read", flag: "read",
narrow: JSON.stringify(narrow), narrow: JSON.stringify(terms_with_integer_channel_id),
}; };
void channel.post({ void channel.post({
url: "/json/messages/flags/narrow", url: "/json/messages/flags/narrow",