Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

notifications: Rename window_has_focus variable and function.

Anders Kaseorgff8351fb711c
diff --git a/frontend_tests/node_tests/general.js b/frontend_tests/node_tests/general.js
index 86f94ff07a1..16b8e7bc337 100644
--- a/frontend_tests/node_tests/general.js
+++ b/frontend_tests/node_tests/general.js
@@ -521,7 +521,7 @@ run_test("unread_ops", () => {
unread.process_loaded_messages(test_messages);
// Make our window appear visible.
- notifications.window_has_focus = () => true;
+ notifications.is_window_focused = () => true;
// Make our "test" message appear visible.
message_viewport.bottom_message_visible = () => true;
diff --git a/static/js/notifications.js b/static/js/notifications.js
index f96c24cdf9e..fc53ab338ef 100644
--- a/static/js/notifications.js
+++ b/static/js/notifications.js
@@ -10,9 +10,9 @@ const settings_config = require("./settings_config");
const notice_memory = new Map();
-// When you start Zulip, window_has_focus should be true, but it might not be the
+// When you start Zulip, window_focused should be true, but it might not be the
// case after a server-initiated reload.
-let window_has_focus = document.hasFocus && document.hasFocus();
+let window_focused = document.hasFocus && document.hasFocus();
let supports_sound;
@@ -71,7 +71,7 @@ function get_audio_file_path(audio_element, audio_file_without_extension) {
exports.initialize = function () {
$(window)
.on("focus", () => {
- window_has_focus = true;
+ window_focused = true;
for (const notice_mem_entry of notice_memory.values()) {
notice_mem_entry.obj.close();
@@ -83,7 +83,7 @@ exports.initialize = function () {
unread_ops.process_visible();
})
.on("blur", () => {
- window_has_focus = false;
+ window_focused = false;
});
const audio = $("<audio>");
@@ -212,8 +212,8 @@ exports.update_pm_count = function () {
}
};
-exports.window_has_focus = function () {
- return window_has_focus;
+exports.is_window_focused = function () {
+ return window_focused;
};
function in_browser_notify(message, title, content, raw_operators, opts) {
diff --git a/static/js/unread_ops.js b/static/js/unread_ops.js
index a8d8245f1e4..9379104608c 100644
--- a/static/js/unread_ops.js
+++ b/static/js/unread_ops.js
@@ -94,7 +94,7 @@ exports.notify_server_message_read = function (message, options) {
// If we ever materially change the algorithm for this function, we
// may need to update notifications.received_messages as well.
exports.process_visible = function () {
- if (overlays.is_active() || !notifications.window_has_focus()) {
+ if (overlays.is_active() || !notifications.is_window_focused()) {
return;
}