Files
zulip/static/js/muted_users_ui.js
Anders Kaseorg fde9b1d366 channel: Remove idempotent retry loop.
This was added by commit 7f174213ed, and
appears to have been designed for responses that are *successful* but
falsy. Logically, these should not implicitly represent a failure to
be retried if it were.

Note from tabbott: The background is that this idempotent retry loop
was a hacky workaround for a bug we never understood but saw daily in
production. Especially during server restarts / client reloads,
something would result in 200 responses with no data being seen by the
frontend, despite the Django server not having received/processed the
request. Fortunately, this strange failure mode appears to have
stopped happening in late 2019, so we can delete this hack.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-08-19 12:14:41 -07:00

68 lines
1.9 KiB
JavaScript

import render_confirm_mute_user from "../templates/confirm_dialog/confirm_mute_user.hbs";
import * as activity from "./activity";
import * as channel from "./channel";
import * as confirm_dialog from "./confirm_dialog";
import {$t_html} from "./i18n";
import * as message_lists from "./message_lists";
import * as muted_users from "./muted_users";
import * as overlays from "./overlays";
import * as people from "./people";
import * as pm_list from "./pm_list";
import * as popovers from "./popovers";
import * as recent_topics_ui from "./recent_topics_ui";
import * as settings_muted_users from "./settings_muted_users";
export function mute_user(user_id) {
channel.post({
url: "/json/users/me/muted_users/" + user_id,
});
}
export function confirm_mute_user(user_id) {
function on_click() {
mute_user(user_id);
}
const html_body = render_confirm_mute_user({
user_name: people.get_full_name(user_id),
});
confirm_dialog.launch({
html_heading: $t_html({defaultMessage: "Mute user"}),
help_link: "/help/mute-a-user",
html_body,
on_click,
});
}
export function unmute_user(user_id) {
channel.del({
url: "/json/users/me/muted_users/" + user_id,
});
}
export function rerender_for_muted_user() {
message_lists.current.update_muting_and_rerender();
if (message_lists.current !== message_lists.home) {
message_lists.home.update_muting_and_rerender();
}
if (overlays.settings_open() && settings_muted_users.loaded) {
settings_muted_users.populate_list();
}
activity.redraw();
pm_list.update_private_messages();
// If a user is (un)muted, we want to update their avatars on the recent topics
// participants column.
recent_topics_ui.complete_rerender();
}
export function handle_user_updates(muted_user_ids) {
popovers.hide_all();
muted_users.set_muted_users(muted_user_ids);
rerender_for_muted_user();
}