user groups: Add live update support for user_group add event.

We add live update support for user group events as part of
https://github.com/zulip/zulip/issues/19526.
This however has a few TODOs:
1. Deciding on how we want to sort the group list on left of
   #groups overlay.
2. How we highlight the newly created groups after it is added
   to the list.
These will be covered as we add support for more groups events.
This commit is contained in:
m-e-l-u-h-a-n
2023-02-02 22:19:02 +05:30
committed by Tim Abbott
parent fdd9f018ad
commit 6147f2bd7a
6 changed files with 78 additions and 4 deletions

View File

@@ -10,6 +10,20 @@ import * as user_group_create_members_data from "./user_group_create_members_dat
import * as user_groups from "./user_groups";
import * as user_group_settings_ui from "./user_groups_settings_ui";
let created_group_name;
export function reset_name() {
created_group_name = undefined;
}
export function set_name(group_name) {
created_group_name = group_name;
}
export function get_name() {
return created_group_name;
}
class UserGroupMembershipError {
report_no_members_to_user_group() {
$("#user_group_membership_error").text(
@@ -101,6 +115,7 @@ function create_user_group() {
const data = {};
const group_name = $("#create_user_group_name").val().trim();
const description = $("#create_user_group_description").val().trim();
set_name(group_name);
// Even though we already check to make sure that while typing the user cannot enter
// newline characters (by pressing the Enter key) it would still be possible to copy
@@ -142,6 +157,7 @@ function create_user_group() {
xhr,
$(".user_group_create_info"),
);
reset_name();
loading.destroy_indicator($("#user_group_creating_indicator"));
},
});