Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
fix: Fix presence.js not triggering after 60s
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobgreenleaf committed Aug 21, 2015
1 parent 696474a commit 7d5eba5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "incusjs",
"version": "1.0.1",
"version": "1.0.4",
"description": "",
"main": "src/incus.js",
"scripts": {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/presence.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var Presence = function(incus, inactivityThresholdSeconds) {
this.incus = incus;
this.timerReference = null;
this.lastActiveTime = null;
this._lastResetCall = null;
this.inactivityThresholdSeconds = (typeof inactivityThresholdSeconds !== 'undefined' ? inactivityThresholdSeconds : 60);

document.body.addEventListener('touchstart', this.handleUserActivity.bind(this));
Expand Down Expand Up @@ -66,8 +67,8 @@ Presence.prototype = {
var nowUnixTimeMsec = (+ new Date);

// Throttle reset commands
if(this.handleUserActivity.lastSuccessfulCall === null || this.handleUserActivity.lastSuccessfulCall + (1000 / MAXIMUM_COMMNANDS_PER_SECOND) <= nowUnixTimeMsec) {
this.handleUserActivity.lastSuccessfulCall = nowUnixTimeMsec;
if(this._lastResetCall === null || this._lastResetCall + (1000 / MAXIMUM_COMMNANDS_PER_SECOND) <= nowUnixTimeMsec) {
this._lastResetCall = nowUnixTimeMsec;
this.reset();
}
}
Expand Down

0 comments on commit 7d5eba5

Please sign in to comment.