angular-user-idle
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -0,1 +1,4 @@ | ||
## 1.0.4 | ||
- Fix incorrect user's inactivity timer | ||
## 1.0.3 | ||
@@ -2,0 +5,0 @@ - Update gitignore |
{ | ||
"name": "angular-user-idle", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "User's idle service for Angular 4", | ||
@@ -5,0 +5,0 @@ "main": "user-idle.umd.js", |
@@ -8,2 +8,6 @@ import { Observable } from 'rxjs'; | ||
ping$: Observable<any>; | ||
/** | ||
* Events that can interrupts user's inactivity timer. | ||
*/ | ||
private readonly activityEvents$; | ||
private timerStart$; | ||
@@ -28,9 +32,9 @@ private timeout$; | ||
/** | ||
* Interrupt timer by user's events. | ||
* Timeout status. | ||
*/ | ||
private interrupting; | ||
private isTimeout; | ||
/** | ||
* Timeout status. | ||
* Timer of user's inactivity is in progress. | ||
*/ | ||
private isTimeout; | ||
private isInactivityTimer; | ||
private idleSubscription; | ||
@@ -37,0 +41,0 @@ constructor(config: UserIdleServiceConfig); |
@@ -39,3 +39,4 @@ (function (global, factory) { | ||
} | ||
this.idle$ = rxjs.Observable.merge(rxjs.Observable.fromEvent(window, 'mousemove'), rxjs.Observable.fromEvent(window, 'resize'), rxjs.Observable.fromEvent(document, 'keydown')); | ||
this.activityEvents$ = rxjs.Observable.merge(rxjs.Observable.fromEvent(window, 'mousemove'), rxjs.Observable.fromEvent(window, 'resize'), rxjs.Observable.fromEvent(document, 'keydown')); | ||
this.idle$ = rxjs.Observable.from(this.activityEvents$); | ||
} | ||
@@ -49,15 +50,13 @@ /** | ||
* If any of user events is not active for idle-seconds when start timer. | ||
* If this.interrupts is sets to true the timer will be stopped if user | ||
* does any event (mousemove, resize or keydown). | ||
* @type {Subscription} | ||
*/ | ||
this.idleSubscription = this.idle$ | ||
.map(function () { | ||
if (_this.interrupting) { | ||
_this.timerStart$.next(false); | ||
} | ||
.bufferTime(5000) // Starting point of detecting of user's inactivity | ||
.filter(function (arr) { return !arr.length && !_this.isInactivityTimer; }) | ||
.switchMap(function () { | ||
_this.isInactivityTimer = true; | ||
return rxjs.Observable.interval(1000) | ||
.takeUntil(rxjs.Observable.merge(_this.activityEvents$, rxjs.Observable.timer(_this.idle * 1000) | ||
.do(function () { return _this.timerStart$.next(true); }))) | ||
.finally(function () { return _this.isInactivityTimer = false; }); | ||
}) | ||
.bufferTime(this.idle * 1000) | ||
.filter(function (arr) { return !arr.length; }) | ||
.map(function () { return _this.timerStart$.next(true); }) | ||
.subscribe(); | ||
@@ -64,0 +63,0 @@ this.setupTimer(this.timeout); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14892
265