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.

activity.js: Add setter for new_user_input.

Anders Kaseorg30d709062154
diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js
index 7cb530609e7..1b9b895e19b 100644
--- a/frontend_tests/node_tests/hotkey.js
+++ b/frontend_tests/node_tests/hotkey.js
@@ -15,8 +15,6 @@
const emoji_codes = zrequire("emoji_codes", "generated/emoji/emoji_codes.json");
-set_global("activity", {});
-
set_global("navigator", {
platform: "",
});
@@ -36,6 +34,7 @@ emoji.initialize({
emoji_codes,
});
+zrequire("activity");
const hotkey = zrequire("hotkey");
zrequire("common");
diff --git a/static/js/activity.js b/static/js/activity.js
index 09738d7d662..670cc6b38d2 100644
--- a/static/js/activity.js
+++ b/static/js/activity.js
@@ -29,6 +29,9 @@ exports.client_is_active = document.hasFocus && document.hasFocus();
// if this was a server-initiated-reload to avoid counting a
// server-initiated reload as user activity.
exports.new_user_input = true;
+exports.set_new_user_input = function (value) {
+ exports.new_user_input = value;
+};
function update_pm_count_in_dom(count_span, value_span, count) {
const li = count_span.parents("li");
diff --git a/static/js/hotkey.js b/static/js/hotkey.js
index b775f5d86b0..5d1031529fc 100644
--- a/static/js/hotkey.js
+++ b/static/js/hotkey.js
@@ -860,7 +860,7 @@ exports.process_hotkey = function (e, hotkey) {
instead just let keypress go for it. */
exports.process_keydown = function (e) {
- activity.new_user_input = true;
+ activity.set_new_user_input(true);
const hotkey = exports.get_keydown_hotkey(e);
if (!hotkey) {
return false;
diff --git a/static/js/reload.js b/static/js/reload.js
index d1c558da3eb..837f3502d91 100644
--- a/static/js/reload.js
+++ b/static/js/reload.js
@@ -167,7 +167,7 @@ exports.initialize = function () {
page_params.initial_narrow_offset = narrow_offset;
}
- activity.new_user_input = false;
+ activity.set_new_user_input(false);
hashchange.changehash(vars.oldhash);
};