don't refresh game list if the browser tab/window isn't active, and refresh immediately when it becomes active if an update was missed
This commit is contained in:
parent
ef4a558137
commit
014258fcf2
|
@ -65,6 +65,17 @@ $(document).ready(function() {
|
|||
app_resize();
|
||||
});
|
||||
|
||||
$(window).focus(function() {
|
||||
cah.windowActive = true;
|
||||
if (cah.missedGameListRefresh) {
|
||||
cah.GameList.instance.update();
|
||||
}
|
||||
});
|
||||
|
||||
$(window).blur(function() {
|
||||
cah.windowActive = false;
|
||||
});
|
||||
|
||||
/**
|
||||
* Handle a key up event in the nick box. If the key was enter, try to register with the server.
|
||||
*
|
||||
|
|
|
@ -80,9 +80,12 @@ cah.GameList.prototype.hide = function() {
|
|||
* Query the server to update the game list.
|
||||
*/
|
||||
cah.GameList.prototype.update = function() {
|
||||
if ($(this.element_).is(":visible")) {
|
||||
if ($(this.element_).is(":visible") && cah.windowActive) {
|
||||
// TODO display a loading indicator of some sort
|
||||
cah.Ajax.build(cah.$.AjaxOperation.GAME_LIST).run();
|
||||
cah.missedGameListRefresh = false;
|
||||
} else {
|
||||
cah.missedGameListRefresh = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -57,6 +57,21 @@ cah.ignoreList = {};
|
|||
*/
|
||||
cah.hideConnectQuit = false;
|
||||
|
||||
/**
|
||||
* Whether the game's browser window has focus, so we don't update the game list when we're not
|
||||
* active.
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
cah.windowActive = true;
|
||||
|
||||
/**
|
||||
* Whether we've missed a game list refresh due to not being the active window.
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
cah.missedGameListRefresh = false;
|
||||
|
||||
/**
|
||||
* Binds a function to a "this object". Result is a new function that will do the right thing across
|
||||
* contexts.
|
||||
|
|
Loading…
Reference in New Issue