fix: correctly start and stop autolock timer
This commit is contained in:
@@ -81,6 +81,10 @@ export class AutolockService {
|
|||||||
*/
|
*/
|
||||||
beginWebFocusPolling() {
|
beginWebFocusPolling() {
|
||||||
this.pollFocusInterval = setInterval(() => {
|
this.pollFocusInterval = setInterval(() => {
|
||||||
|
if (document.hidden) {
|
||||||
|
/** Native event listeners will have fired */
|
||||||
|
return;
|
||||||
|
}
|
||||||
const hasFocus = document.hasFocus();
|
const hasFocus = document.hasFocus();
|
||||||
if (hasFocus && this.lastFocusState === 'hidden') {
|
if (hasFocus && this.lastFocusState === 'hidden') {
|
||||||
this.documentVisibilityChanged(true);
|
this.documentVisibilityChanged(true);
|
||||||
@@ -150,6 +154,7 @@ export class AutolockService {
|
|||||||
return date;
|
return date;
|
||||||
};
|
};
|
||||||
this.lockAfterDate = addToNow(interval / MILLISECONDS_PER_SECOND);
|
this.lockAfterDate = addToNow(interval / MILLISECONDS_PER_SECOND);
|
||||||
|
clearTimeout(this.lockTimeout);
|
||||||
this.lockTimeout = setTimeout(() => {
|
this.lockTimeout = setTimeout(() => {
|
||||||
this.cancelAutoLockTimer();
|
this.cancelAutoLockTimer();
|
||||||
this.lockApplication();
|
this.lockApplication();
|
||||||
|
|||||||
@@ -56,17 +56,16 @@ export class AppState {
|
|||||||
this.$timeout = $timeout;
|
this.$timeout = $timeout;
|
||||||
this.$rootScope = $rootScope;
|
this.$rootScope = $rootScope;
|
||||||
this.application = application;
|
this.application = application;
|
||||||
this.registerVisibilityObservers();
|
|
||||||
this.addAppEventObserver();
|
this.addAppEventObserver();
|
||||||
this.streamNotesAndTags();
|
this.streamNotesAndTags();
|
||||||
const onVisibilityChange = () => {
|
this.onVisibilityChange = () => {
|
||||||
const visible = document.visibilityState === "visible";
|
const visible = document.visibilityState === "visible";
|
||||||
const event = visible
|
const event = visible
|
||||||
? AppStateEvent.WindowDidFocus
|
? AppStateEvent.WindowDidFocus
|
||||||
: AppStateEvent.WindowDidBlur;
|
: AppStateEvent.WindowDidBlur;
|
||||||
this.notifyEvent(event);
|
this.notifyEvent(event);
|
||||||
}
|
}
|
||||||
this.onVisibilityChange = onVisibilityChange.bind(this);
|
this.registerVisibilityObservers();
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit() {
|
deinit() {
|
||||||
|
|||||||
Reference in New Issue
Block a user