stream_data: Extract function to get stream options for dropdown.

To be used by various dropdown widgets in the app.
This commit is contained in:
Aman Agrawal
2023-06-20 15:00:30 +05:30
committed by Tim Abbott
parent 0024e88fcb
commit 29b3769b59
3 changed files with 152 additions and 16 deletions

View File

@@ -246,22 +246,7 @@ function item_click_callback(event, dropdown) {
}
function get_options_for_recipient_widget() {
const options = stream_data
.subscribed_subs()
.map((stream) => ({
name: stream.name,
unique_id: stream.stream_id,
stream,
}))
.sort((a, b) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
return -1;
}
if (a.name.toLowerCase() > b.name.toLowerCase()) {
return 1;
}
return 0;
});
const options = stream_data.get_options_for_dropdown_widget();
const direct_messages_option = {
is_direct_message: true,