diff --git a/web/src/popover_menus_data.ts b/web/src/popover_menus_data.ts index bef05ece07..f71043b883 100644 --- a/web/src/popover_menus_data.ts +++ b/web/src/popover_menus_data.ts @@ -11,6 +11,7 @@ import * as hash_util from "./hash_util.ts"; import {$t} from "./i18n.ts"; import * as message_edit from "./message_edit.ts"; import * as message_lists from "./message_lists.ts"; +import * as message_util from "./message_util.ts"; import * as muted_users from "./muted_users.ts"; import {page_params} from "./page_params.ts"; import * as people from "./people.ts"; @@ -52,6 +53,7 @@ type TopicPopoverContext = { topic_name: string; topic_unmuted: boolean; is_spectator: boolean; + is_topic_empty: boolean; can_move_topic: boolean; can_rename_topic: boolean; is_realm_admin: boolean; @@ -248,6 +250,7 @@ export function get_topic_popover_content_context({ const visibility_policy = user_topics.get_topic_visibility_policy(sub.stream_id, topic_name); const all_visibility_policies = user_topics.all_visibility_policies; const is_spectator = page_params.is_spectator; + const is_topic_empty = message_util.get_messages_in_topic(stream_id, topic_name).length === 0; return { stream_name: sub.name, stream_id: sub.stream_id, @@ -255,6 +258,7 @@ export function get_topic_popover_content_context({ topic_name, topic_unmuted, is_spectator, + is_topic_empty, can_move_topic, can_rename_topic, is_realm_admin: current_user.is_admin, diff --git a/web/src/topic_popover.js b/web/src/topic_popover.js index 805d6135e9..46cfbbeafc 100644 --- a/web/src/topic_popover.js +++ b/web/src/topic_popover.js @@ -63,6 +63,10 @@ export function initialize() { return; } + if (instance.context.is_topic_empty) { + return; + } + $popper.on("change", "input[name='sidebar-topic-visibility-select']", (e) => { const start_time = Date.now(); const visibility_policy = Number.parseInt( diff --git a/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs b/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs index 300d169afa..0e915cd810 100644 --- a/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs +++ b/web/templates/popovers/left_sidebar/left_sidebar_topic_actions_popover.hbs @@ -3,103 +3,110 @@