Set focus-related flags correctly after a server reload

(imported from commit 408469c0da0cfa5513e6838329816cd88665981f)
This commit is contained in:
Steve Howell
2013-09-16 12:22:52 -04:00
parent 98af7e8664
commit e83c026a27
3 changed files with 14 additions and 2 deletions

View File

@@ -17,7 +17,9 @@ var OFFLINE_THRESHOLD_SECS = 140;
exports.ACTIVE = "active"; exports.ACTIVE = "active";
exports.IDLE = "idle"; exports.IDLE = "idle";
exports.has_focus = true; // When you start Zulip, has_focus should be true, but it might not be the
// case after a server-initiated reload.
exports.has_focus = document.hasFocus && document.hasFocus();
// We initialize this to true, to count new page loads, but set it to // We initialize this to true, to count new page loads, but set it to
// false in the onload function in reload.js if this was a // false in the onload function in reload.js if this was a

View File

@@ -3,7 +3,11 @@ var notifications = (function () {
var exports = {}; var exports = {};
var notice_memory = {}; var notice_memory = {};
var window_has_focus = true;
// When you start Zulip, window_has_focus should be true, but it might not be the
// case after a server-initiated reload.
var window_has_focus = document.hasFocus && document.hasFocus();
var asked_permission_already = false; var asked_permission_already = false;
var names; var names;
var supports_sound; var supports_sound;

View File

@@ -14,6 +14,12 @@ set_global('$', function () {
}; };
}); });
set_global('document', {
hasFocus: function () {
return true;
}
});
var activity = require('js/activity.js'); var activity = require('js/activity.js');
(function test_sort_users() { (function test_sort_users() {