FIX: change focus when application resumes in android

Per new lifecycle https://developers.google.com/web/updates/2018/07/page-lifecycle-api

On Android and latest Chrome when an app transitions from "frozen" to
active the new "resume" event fires with no accompanying "visibilitychange"
event.

This means that often background tabs may be stuck thinking that discourse
has no focus when, indeed, it has.

This leads to cases where no posts are marked read anymore.
This commit is contained in:
Sam Saffron 2019-10-01 11:59:56 +10:00 committed by Joffrey JAFFEUX
parent 3e73c0a34d
commit 67e8fbc480

View File

@ -24,12 +24,16 @@ export default Ember.Mixin.create({
Discourse.set("hasFocus", true);
document.addEventListener("visibilitychange", onchange);
document.addEventListener("resume", onchange);
document.addEventListener("freeze", onchange);
},
reset() {
this._super(...arguments);
document.removeEventListener("visibilitychange", onchange);
document.removeEventListener("resume", onchange);
document.removeEventListener("freeze", onchange);
onchange = undefined;
}