user_profile: Update stream dropdown option value to be of "number" type.

It is better to have stream dropdown option value, which is the ID
of the stream, to be of "number" type.

This fixes the assertion error which occurred when someone tried to
subscribe the user to a stream from user profile modal.
This commit is contained in:
Sahil Batra 2024-08-22 22:53:22 +05:30 committed by Tim Abbott
parent df38639cfd
commit 5c7756e1ef
1 changed files with 3 additions and 2 deletions

View File

@ -209,6 +209,7 @@ function render_user_profile_subscribe_widget(): void {
get_options: get_user_unsub_streams, get_options: get_user_unsub_streams,
item_click_callback: change_state_of_subscribe_button, item_click_callback: change_state_of_subscribe_button,
$events_container: $("#user-profile-modal"), $events_container: $("#user-profile-modal"),
unique_id_type: dropdown_widget.DataTypes.NUMBER,
}; };
user_profile_subscribe_widget = user_profile_subscribe_widget =
user_profile_subscribe_widget ?? new dropdown_widget.DropdownWidget(opts); user_profile_subscribe_widget ?? new dropdown_widget.DropdownWidget(opts);
@ -255,7 +256,7 @@ function reset_subscribe_widget(): void {
export function get_user_unsub_streams(): { export function get_user_unsub_streams(): {
name: string; name: string;
unique_id: string; unique_id: number;
stream: StreamSubscription; stream: StreamSubscription;
}[] { }[] {
const target_user_id = Number.parseInt($("#user-profile-modal").attr("data-user-id")!, 10); const target_user_id = Number.parseInt($("#user-profile-modal").attr("data-user-id")!, 10);
@ -263,7 +264,7 @@ export function get_user_unsub_streams(): {
.get_streams_for_user(target_user_id) .get_streams_for_user(target_user_id)
.can_subscribe.map((stream) => ({ .can_subscribe.map((stream) => ({
name: stream.name, name: stream.name,
unique_id: stream.stream_id.toString(), unique_id: stream.stream_id,
stream, stream,
})) }))
.sort((a, b) => { .sort((a, b) => {