mirror of https://github.com/zulip/zulip.git
refactor: Extract remove_subscriber.
This commit is contained in:
parent
e742ebb8e8
commit
d7f90acbf6
|
@ -263,28 +263,7 @@ function submit_add_subscriber_form(stream_id) {
|
|||
invite_user_to_stream(user_ids, sub, invite_success, invite_failure);
|
||||
}
|
||||
|
||||
export function initialize() {
|
||||
$("#subscriptions_table").on("keyup", ".subscriber_list_add form", (e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
const stream_id = get_stream_id(e.target);
|
||||
submit_add_subscriber_form(stream_id);
|
||||
}
|
||||
});
|
||||
|
||||
$("#subscriptions_table").on("submit", ".subscriber_list_add form", (e) => {
|
||||
e.preventDefault();
|
||||
const stream_id = get_stream_id(e.target);
|
||||
submit_add_subscriber_form(stream_id);
|
||||
});
|
||||
|
||||
$("#subscriptions_table").on("submit", ".subscriber_list_remove form", (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const list_entry = $(e.target).closest("tr");
|
||||
const target_user_id = Number.parseInt(list_entry.attr("data-subscriber-id"), 10);
|
||||
|
||||
const stream_id = get_stream_id(e.target);
|
||||
function remove_subscriber({stream_id, target_user_id, list_entry}) {
|
||||
const sub = get_sub(stream_id);
|
||||
if (!sub) {
|
||||
return;
|
||||
|
@ -334,5 +313,30 @@ export function initialize() {
|
|||
}
|
||||
|
||||
remove_user_from_stream(target_user_id, sub, removal_success, removal_failure);
|
||||
}
|
||||
|
||||
export function initialize() {
|
||||
$("#subscriptions_table").on("keyup", ".subscriber_list_add form", (e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
const stream_id = get_stream_id(e.target);
|
||||
submit_add_subscriber_form(stream_id);
|
||||
}
|
||||
});
|
||||
|
||||
$("#subscriptions_table").on("submit", ".subscriber_list_add form", (e) => {
|
||||
e.preventDefault();
|
||||
const stream_id = get_stream_id(e.target);
|
||||
submit_add_subscriber_form(stream_id);
|
||||
});
|
||||
|
||||
$("#subscriptions_table").on("submit", ".subscriber_list_remove form", (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const list_entry = $(e.target).closest("tr");
|
||||
const target_user_id = Number.parseInt(list_entry.attr("data-subscriber-id"), 10);
|
||||
const stream_id = get_stream_id(e.target);
|
||||
|
||||
remove_subscriber({stream_id, target_user_id, list_entry});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue