settings_streams: Fix error thrown when adding 'default-channels'.

The 'Select channel' dropdown in 'Add default channels' modal is
the LAST dropdown element on the modal and it does not contain
`data-stream-id` attribute.

.attr('data-stream-id') would return undefined for this element
and as a result the returned `Set` would have its last element a
`NaN` --- passing a `NaN` inside 'data' field of 'channel.post' threw
an error.

We tweaked the selector string to selectively map over the elements with
'data-stream-id' attribute.
Also we removed '.toString()' converting stream-id to a string (stream-id is a
'number' type).
This commit is contained in:
Varun Singh
2024-05-28 11:47:13 +05:30
committed by Tim Abbott
parent 4deecfa58d
commit 50e0f336f0
3 changed files with 8 additions and 5 deletions

View File

@@ -296,12 +296,12 @@ export function delete_sub(stream_id: number): void {
stream_info.delete(stream_id);
}
export function get_non_default_stream_names(): {name: string; unique_id: string}[] {
export function get_non_default_stream_names(): {name: string; unique_id: number}[] {
let subs = [...stream_info.values()];
subs = subs.filter((sub) => !is_default_stream_id(sub.stream_id) && !sub.invite_only);
const names = subs.map((sub) => ({
name: sub.name,
unique_id: sub.stream_id.toString(),
unique_id: sub.stream_id,
}));
return names;
}