Skip to content
Browse files

FIX: change focus when application resumes in android

Per new lifecycle

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

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.
  • Loading branch information...
SamSaffron authored and jjaffeux committed Oct 1, 2019
1 parent 3e73c0a commit 67e8fbc480de6934de3ad45d05f52057beeefbab
Showing with 4 additions and 0 deletions.
  1. +4 −0 app/assets/javascripts/discourse-common/mixins/focus-event.js.es6
@@ -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() {

document.removeEventListener("visibilitychange", onchange);
document.removeEventListener("resume", onchange);
document.removeEventListener("freeze", onchange);

onchange = undefined;

1 comment on commit 67e8fbc


This comment has been minimized.

Copy link

commented on 67e8fbc Oct 7, 2019

This commit has been mentioned on Discourse Meta. There might be relevant details there:

Please sign in to comment.
You can’t perform that action at this time.