This commit is contained in:
Mo Bitar
2019-12-04 10:15:50 -06:00
3 changed files with 51 additions and 19 deletions

View File

@@ -164,6 +164,16 @@ class PasscodeManager {
} }
configureAutoLock() { configureAutoLock() {
PasscodeManager.AutoLockPollFocusInterval = 1 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalNone = 0;
PasscodeManager.AutoLockIntervalImmediate = 1;
PasscodeManager.AutoLockIntervalOneMinute = 60 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalFiveMinutes = 300 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalOneHour = 3600 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalKey = "AutoLockIntervalKey";
if(isDesktopApplication()) { if(isDesktopApplication()) {
// desktop only // desktop only
this.$rootScope.$on("window-lost-focus", () => { this.$rootScope.$on("window-lost-focus", () => {
@@ -173,20 +183,27 @@ class PasscodeManager {
this.documentVisibilityChanged(true); this.documentVisibilityChanged(true);
}) })
} else { } else {
// tab visibility listender, web only // tab visibility listener, web only
document.addEventListener('visibilitychange', (e) => { document.addEventListener('visibilitychange', (e) => {
let visible = document.visibilityState == "visible"; let visible = document.visibilityState == "visible";
this.documentVisibilityChanged(visible); this.documentVisibilityChanged(visible);
}); });
// verify document is in focus every so often as visibilitychange event is not triggered
// on a typical window blur event but rather on tab changes
this.pollFocusTimeout = setInterval(() => {
let hasFocus = document.hasFocus();
if(hasFocus && this.lastFocusState == "hidden") {
this.documentVisibilityChanged(true);
} else if(!hasFocus && this.lastFocusState == "visible") {
this.documentVisibilityChanged(false);
}
// save this to compare against next time around
this.lastFocusState = hasFocus ? "visible" : "hidden";
}, PasscodeManager.AutoLockPollFocusInterval);
} }
PasscodeManager.AutoLockIntervalNone = 0;
PasscodeManager.AutoLockIntervalImmediate = 1;
PasscodeManager.AutoLockIntervalOneMinute = 60 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalFiveMinutes = 300 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalOneHour = 3600 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalKey = "AutoLockIntervalKey";
} }
getAutoLockIntervalOptions() { getAutoLockIntervalOptions() {

View File

@@ -61071,6 +61071,14 @@ function () {
value: function configureAutoLock() { value: function configureAutoLock() {
var _this80 = this; var _this80 = this;
PasscodeManager.AutoLockPollFocusInterval = 1 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalNone = 0;
PasscodeManager.AutoLockIntervalImmediate = 1;
PasscodeManager.AutoLockIntervalOneMinute = 60 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalFiveMinutes = 300 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalOneHour = 3600 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalKey = "AutoLockIntervalKey";
if (isDesktopApplication()) { if (isDesktopApplication()) {
// desktop only // desktop only
this.$rootScope.$on("window-lost-focus", function () { this.$rootScope.$on("window-lost-focus", function () {
@@ -61080,20 +61088,27 @@ function () {
_this80.documentVisibilityChanged(true); _this80.documentVisibilityChanged(true);
}); });
} else { } else {
// tab visibility listender, web only // tab visibility listener, web only
document.addEventListener('visibilitychange', function (e) { document.addEventListener('visibilitychange', function (e) {
var visible = document.visibilityState == "visible"; var visible = document.visibilityState == "visible";
_this80.documentVisibilityChanged(visible); _this80.documentVisibilityChanged(visible);
}); }); // verify document is in focus every so often as visibilitychange event is not triggered
} // on a typical window blur event but rather on tab changes
PasscodeManager.AutoLockIntervalNone = 0; this.pollFocusTimeout = setInterval(function () {
PasscodeManager.AutoLockIntervalImmediate = 1; var hasFocus = document.hasFocus();
PasscodeManager.AutoLockIntervalOneMinute = 60 * MillisecondsPerSecond;
PasscodeManager.AutoLockIntervalFiveMinutes = 300 * MillisecondsPerSecond; if (hasFocus && _this80.lastFocusState == "hidden") {
PasscodeManager.AutoLockIntervalOneHour = 3600 * MillisecondsPerSecond; _this80.documentVisibilityChanged(true);
PasscodeManager.AutoLockIntervalKey = "AutoLockIntervalKey"; } else if (!hasFocus && _this80.lastFocusState == "visible") {
_this80.documentVisibilityChanged(false);
} // save this to compare against next time around
_this80.lastFocusState = hasFocus ? "visible" : "hidden";
}, PasscodeManager.AutoLockPollFocusInterval);
}
} }
}, { }, {
key: "getAutoLockIntervalOptions", key: "getAutoLockIntervalOptions",

File diff suppressed because one or more lines are too long