mirror of https://github.com/zulip/zulip.git
narrow_title: Migrate module to typescript.
This commit is contained in:
parent
01abd96127
commit
e0fef6fdff
|
@ -150,7 +150,7 @@ EXEMPT_FILES = make_set(
|
||||||
"web/src/muted_users_ui.js",
|
"web/src/muted_users_ui.js",
|
||||||
"web/src/narrow.js",
|
"web/src/narrow.js",
|
||||||
"web/src/narrow_history.js",
|
"web/src/narrow_history.js",
|
||||||
"web/src/narrow_title.js",
|
"web/src/narrow_title.ts",
|
||||||
"web/src/navbar_alerts.js",
|
"web/src/navbar_alerts.js",
|
||||||
"web/src/navbar_help_menu.js",
|
"web/src/navbar_help_menu.js",
|
||||||
"web/src/navbar_menus.js",
|
"web/src/navbar_menus.js",
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
|
import assert from "minimalistic-assert";
|
||||||
|
|
||||||
import * as favicon from "./favicon";
|
import * as favicon from "./favicon";
|
||||||
|
import type {Filter} from "./filter";
|
||||||
import {$t} from "./i18n";
|
import {$t} from "./i18n";
|
||||||
import * as inbox_util from "./inbox_util";
|
import * as inbox_util from "./inbox_util";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as recent_view_util from "./recent_view_util";
|
import * as recent_view_util from "./recent_view_util";
|
||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
|
import type {FullUnreadCountsData} from "./unread";
|
||||||
|
|
||||||
export let unread_count = 0;
|
export let unread_count = 0;
|
||||||
let pm_count = 0;
|
let pm_count = 0;
|
||||||
export let narrow_title = "home";
|
export let narrow_title = "home";
|
||||||
|
|
||||||
export function compute_narrow_title(filter) {
|
export function compute_narrow_title(filter?: Filter): string {
|
||||||
if (filter === undefined) {
|
if (filter === undefined) {
|
||||||
// "All messages" and "Recent conversations" views have
|
// "All messages" and "Recent conversations" views have
|
||||||
// an `undefined` filter.
|
// an `undefined` filter.
|
||||||
|
@ -18,9 +22,8 @@ export function compute_narrow_title(filter) {
|
||||||
return $t({defaultMessage: "Recent conversations"});
|
return $t({defaultMessage: "Recent conversations"});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inbox_util.is_visible()) {
|
assert(inbox_util.is_visible());
|
||||||
return $t({defaultMessage: "Inbox"});
|
return $t({defaultMessage: "Inbox"});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const filter_title = filter.get_title();
|
const filter_title = filter.get_title();
|
||||||
|
@ -76,7 +79,7 @@ export function compute_narrow_title(filter) {
|
||||||
return filter_title;
|
return filter_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function redraw_title() {
|
export function redraw_title(): void {
|
||||||
// Update window title to reflect unread messages in current view
|
// Update window title to reflect unread messages in current view
|
||||||
const new_title =
|
const new_title =
|
||||||
(unread_count ? "(" + unread_count + ") " : "") +
|
(unread_count ? "(" + unread_count + ") " : "") +
|
||||||
|
@ -89,7 +92,7 @@ export function redraw_title() {
|
||||||
document.title = new_title;
|
document.title = new_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update_unread_counts(counts) {
|
export function update_unread_counts(counts: FullUnreadCountsData): void {
|
||||||
const new_unread_count = unread.calculate_notifiable_count(counts);
|
const new_unread_count = unread.calculate_notifiable_count(counts);
|
||||||
const new_pm_count = counts.direct_message_count;
|
const new_pm_count = counts.direct_message_count;
|
||||||
if (new_unread_count === unread_count && new_pm_count === pm_count) {
|
if (new_unread_count === unread_count && new_pm_count === pm_count) {
|
||||||
|
@ -111,7 +114,7 @@ export function update_unread_counts(counts) {
|
||||||
redraw_title();
|
redraw_title();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update_narrow_title(filter) {
|
export function update_narrow_title(filter: Filter): void {
|
||||||
narrow_title = compute_narrow_title(filter);
|
narrow_title = compute_narrow_title(filter);
|
||||||
redraw_title();
|
redraw_title();
|
||||||
}
|
}
|
|
@ -836,7 +836,7 @@ export function get_unread_topics(include_per_topic_latest_msg_id = false): Unre
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
type FullUnreadCountsData = {
|
export type FullUnreadCountsData = {
|
||||||
direct_message_count: number;
|
direct_message_count: number;
|
||||||
mentioned_message_count: number;
|
mentioned_message_count: number;
|
||||||
direct_message_with_mention_count: number;
|
direct_message_with_mention_count: number;
|
||||||
|
|
Loading…
Reference in New Issue