message_edit: Add code to live-update inline-topic edit icon.

This commit adds code to live-update the inline-topic edit
icon on changing move_messages_within_stream_limit_seconds
or edit_topic_policy. We simply rerender the message list
as it becomes difficult to check for each recipient row
and update it because topic edit permission depends on
when the message was sent.

This also live-updates the resolve topic icon as it depends
on topic edit permission only.
This commit is contained in:
Sahil Batra
2023-01-31 15:55:33 +05:30
committed by Tim Abbott
parent 2eb204f699
commit 2fcaf88305
4 changed files with 19 additions and 1 deletions

View File

@@ -508,10 +508,12 @@ run_test("realm settings", ({override}) => {
event = event_fixtures.realm__update_dict__default;
page_params.realm_allow_message_editing = false;
page_params.realm_message_content_edit_limit_seconds = 0;
page_params.realm_edit_topic_policy = 3;
override(settings_org, "populate_auth_methods", noop);
dispatch(event);
assert_same(page_params.realm_allow_message_editing, true);
assert_same(page_params.realm_message_content_edit_limit_seconds, 5);
assert_same(page_params.realm_edit_topic_policy, 4);
assert_same(page_params.realm_authentication_methods, {Google: true});
event = event_fixtures.realm__update_dict__icon;

View File

@@ -380,6 +380,7 @@ exports.fixtures = {
data: {
allow_message_editing: true,
message_content_edit_limit_seconds: 5,
edit_topic_policy: 4,
authentication_methods: {
Google: true,
},

View File

@@ -21,6 +21,7 @@ import * as keydown_util from "./keydown_util";
import * as loading from "./loading";
import * as markdown from "./markdown";
import * as message_lists from "./message_lists";
import * as message_live_update from "./message_live_update";
import * as message_store from "./message_store";
import * as message_viewport from "./message_viewport";
import {page_params} from "./page_params";
@@ -305,6 +306,15 @@ export function end_if_focused_on_message_row_edit() {
}
}
export function update_inline_topic_edit_ui() {
// This function is called when
// "realm_move_messages_within_stream_limit_seconds" setting is
// changed. This is a rare event, so it's OK to be lazy and just
// do a full rerender, even though the only thing we need to
// change is the inline topic edit icons in recipient bars.
message_live_update.rerender_messages_view();
}
function handle_message_row_edit_keydown(e) {
if (keydown_util.is_enter_event(e)) {
if ($(e.target).hasClass("message_edit_content")) {

View File

@@ -18,6 +18,7 @@ import * as emoji_picker from "./emoji_picker";
import * as giphy from "./giphy";
import * as hotspots from "./hotspots";
import * as linkifiers from "./linkifiers";
import * as message_edit from "./message_edit";
import * as message_events from "./message_events";
import * as message_flags from "./message_flags";
import * as message_lists from "./message_lists";
@@ -212,7 +213,7 @@ export function dispatch_normal_event(event) {
message_content_edit_limit_seconds: noop,
message_content_delete_limit_seconds: noop,
move_messages_between_streams_limit_seconds: noop,
move_messages_within_stream_limit_seconds: noop,
move_messages_within_stream_limit_seconds: message_edit.update_inline_topic_edit_ui,
message_retention_days: noop,
move_messages_between_streams_policy: noop,
name: notifications.redraw_title,
@@ -267,6 +268,10 @@ export function dispatch_normal_event(event) {
if (Object.hasOwn(realm_settings, key)) {
settings_org.sync_realm_settings(key);
}
if (key === "edit_topic_policy") {
message_live_update.rerender_messages_view();
}
}
if (event.data.authentication_methods !== undefined) {
settings_org.populate_auth_methods(