unread_ui: Rename functions names to offer a general clarity.

Previously, the naming of functions in unread_ui was targeted towards a
specific unread banner. This is terrible if we plan on having multiple
types of unread banners and this change aims to offer that level of clarity.
This commit is contained in:
Joelute
2023-04-11 17:36:11 -04:00
committed by Tim Abbott
parent afbd0a9b43
commit ffbe6e870a
7 changed files with 16 additions and 16 deletions

View File

@@ -272,7 +272,7 @@ export function initialize() {
// The below checks might seem redundant, but it's // The below checks might seem redundant, but it's
// possible this logic, which runs after a delay, lost // possible this logic, which runs after a delay, lost
// a race with switching to another view, like Recent // a race with switching to another view, like Recent
// Topics, and we don't want to displ[ay this banner // Topics, and we don't want to display this banner
// in such a view. // in such a view.
// //
// This can likely be fixed more cleanly with another approach. // This can likely be fixed more cleanly with another approach.

View File

@@ -178,7 +178,7 @@ export function reset_ui_state() {
narrow_banner.hide_empty_narrow_message(); narrow_banner.hide_empty_narrow_message();
message_scroll.hide_top_of_narrow_notices(); message_scroll.hide_top_of_narrow_notices();
message_scroll.hide_indicators(); message_scroll.hide_indicators();
unread_ui.reset_mark_as_read_turned_off_banner(); unread_ui.reset_unread_banner();
} }
export function handle_middle_pane_transition() { export function handle_middle_pane_transition() {

View File

@@ -884,7 +884,7 @@ export function show() {
set_visible(true); set_visible(true);
$(".header").css("padding-bottom", "0px"); $(".header").css("padding-bottom", "0px");
unread_ui.hide_mark_as_read_turned_off_banner(); unread_ui.hide_unread_banner();
// We want to show `new stream message` instead of // We want to show `new stream message` instead of
// `new topic`, which we are already doing in this // `new topic`, which we are already doing in this

View File

@@ -173,7 +173,7 @@ export function mark_unsubscribed(sub) {
// This update would likely be better implemented by having it // This update would likely be better implemented by having it
// disappear whenever no unread messages remain. // disappear whenever no unread messages remain.
unread_ui.hide_mark_as_read_turned_off_banner(); unread_ui.hide_unread_banner();
} }
// Unread messages in the now-unsubscribe stream need to be // Unread messages in the now-unsubscribe stream need to be

View File

@@ -13,20 +13,20 @@ import * as topic_list from "./topic_list";
import * as unread from "./unread"; import * as unread from "./unread";
import {notify_server_messages_read} from "./unread_ops"; import {notify_server_messages_read} from "./unread_ops";
let user_closed_mark_as_read_turned_off_banner = false; let user_closed_unread_banner = false;
export function hide_mark_as_read_turned_off_banner() { export function hide_unread_banner() {
// Use visibility instead of hide() to prevent messages on the screen from // Use visibility instead of hide() to prevent messages on the screen from
// shifting vertically. // shifting vertically.
$("#mark_as_read_turned_off_banner").toggleClass("invisible", true); $("#mark_as_read_turned_off_banner").toggleClass("invisible", true);
} }
export function reset_mark_as_read_turned_off_banner() { export function reset_unread_banner() {
hide_mark_as_read_turned_off_banner(); hide_unread_banner();
user_closed_mark_as_read_turned_off_banner = false; user_closed_unread_banner = false;
} }
export function notify_messages_remain_unread() { export function notify_messages_remain_unread() {
if (!user_closed_mark_as_read_turned_off_banner) { if (!user_closed_unread_banner) {
$("#mark_as_read_turned_off_banner").toggleClass("invisible", false); $("#mark_as_read_turned_off_banner").toggleClass("invisible", false);
} }
} }
@@ -98,7 +98,7 @@ export function initialize() {
update_unread_counts(); update_unread_counts();
$("#mark_as_read_turned_off_banner").html(render_mark_as_read_turned_off_banner()); $("#mark_as_read_turned_off_banner").html(render_mark_as_read_turned_off_banner());
hide_mark_as_read_turned_off_banner(); hide_unread_banner();
$("#mark_view_read").on("click", () => { $("#mark_view_read").on("click", () => {
// Mark all messages in the current view as read. // Mark all messages in the current view as read.
// //
@@ -112,10 +112,10 @@ export function initialize() {
// New messages received may be marked as read based on narrow type. // New messages received may be marked as read based on narrow type.
message_lists.current.resume_reading(); message_lists.current.resume_reading();
hide_mark_as_read_turned_off_banner(); hide_unread_banner();
}); });
$("#mark_as_read_close").on("click", () => { $("#mark_as_read_close").on("click", () => {
hide_mark_as_read_turned_off_banner(); hide_unread_banner();
user_closed_mark_as_read_turned_off_banner = true; user_closed_unread_banner = true;
}); });
} }

View File

@@ -110,7 +110,7 @@ mock_esm("../src/user_topics", {
}); });
const narrow = mock_esm("../src/narrow", { const narrow = mock_esm("../src/narrow", {
update_narrow_title: noop, update_narrow_title: noop,
hide_mark_as_read_turned_off_banner: noop, hide_unread_banner: noop,
handle_middle_pane_transition: noop, handle_middle_pane_transition: noop,
has_shown_message_list_view: true, has_shown_message_list_view: true,
}); });

View File

@@ -410,7 +410,7 @@ test("mark_unsubscribed (render_title_area)", ({override}) => {
override(stream_list, "remove_sidebar_row", noop); override(stream_list, "remove_sidebar_row", noop);
override(stream_list, "update_subscribe_to_more_streams_link", noop); override(stream_list, "update_subscribe_to_more_streams_link", noop);
override(unread_ui, "update_unread_counts", noop); override(unread_ui, "update_unread_counts", noop);
override(unread_ui, "hide_mark_as_read_turned_off_banner", noop); override(unread_ui, "hide_unread_banner", noop);
$("#streams_overlay_container .stream-row:not(.notdisplayed)").length = 0; $("#streams_overlay_container .stream-row:not(.notdisplayed)").length = 0;