quiq-chat
Advanced tools
Comparing version 1.17.2 to 1.18.0
@@ -274,3 +274,3 @@ 'use strict'; | ||
var version = "1.17.2"; | ||
var version = "1.18.0"; | ||
@@ -1164,2 +1164,83 @@ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
// | ||
var log$9 = logger('SlumberParty'); | ||
var SlumberParty = function () { | ||
function SlumberParty() { | ||
var _this = this; | ||
_classCallCheck$2(this, SlumberParty); | ||
this.handlers = { | ||
wake: [] | ||
}; | ||
this.frequency = 2000; | ||
this.addEventListener = function (event, f) { | ||
if (Array.isArray(_this.handlers[event]) && !_this.handlers[event].includes(f)) { | ||
_this.handlers[event].push(f); | ||
} | ||
}; | ||
this.removeEventListener = function (event, f) { | ||
if (Array.isArray(_this.handlers[event])) { | ||
var idx = _this.handlers[event].indexOf(f); | ||
if (idx > -1) { | ||
_this.handlers[event].splice(idx, 1); | ||
} | ||
} | ||
}; | ||
this.wallClockTime = Date.now(); | ||
setInterval(function () { | ||
// See https://stackoverflow.com/a/4080174/3961837 | ||
var currentTime = Date.now(); | ||
if (currentTime > _this.wallClockTime + 60000) { | ||
// ignore small delays | ||
// Probably just woke up! | ||
log$9.info('Firing wake handlers'); | ||
_this._fireHandlersForEvent('wake'); | ||
} | ||
_this.wallClockTime = currentTime; | ||
}, this.frequency); | ||
} | ||
/** | ||
* Register a function to be fired when the computer is believed to have woken from sleep | ||
* @param event {string} Name of the event (wake) | ||
* @param f - A function of the form () => void | ||
*/ | ||
/** | ||
* Unregister a previously registered event handler (must be exact same reference) | ||
* @param event {string} Name of the event (wake) | ||
* @param f - A function of the form () => void | ||
*/ | ||
_createClass(SlumberParty, [{ | ||
key: '_fireHandlersForEvent', | ||
value: function _fireHandlersForEvent(event) { | ||
if (Array.isArray(this.handlers[event])) { | ||
this.handlers[event].forEach(function (f) { | ||
return f(); | ||
}); | ||
} | ||
} | ||
}]); | ||
return SlumberParty; | ||
}(); | ||
// Export as a singleton | ||
var SlumberParty$1 = new SlumberParty(); | ||
var init = function init() { | ||
@@ -1183,2 +1264,3 @@ if (!inLocalDevelopment()) Raven.config('https://5622397f17c44165a039d3b91d3e0193@sentry.io/170102', { | ||
// | ||
// Initialize Sentry | ||
init(); | ||
@@ -1360,7 +1442,10 @@ | ||
case 17: | ||
_context2.next = 24; | ||
// Listen for machine wakeup, so we can refresh app to clear any connection oddities | ||
SlumberParty$1.addEventListener('wake', _this2._handleMachineWake); | ||
_context2.next = 25; | ||
break; | ||
case 19: | ||
_context2.prev = 19; | ||
case 20: | ||
_context2.prev = 20; | ||
_context2.t0 = _context2['catch'](2); | ||
@@ -1375,3 +1460,3 @@ | ||
case 24: | ||
case 25: | ||
case 'end': | ||
@@ -1381,3 +1466,3 @@ return _context2.stop(); | ||
} | ||
}, _callee2, _this2, [[2, 19]]); | ||
}, _callee2, _this2, [[2, 20]]); | ||
})); | ||
@@ -1389,2 +1474,5 @@ | ||
_this2.connected = false; | ||
// Stop listening for wake events | ||
SlumberParty$1.removeEventListener('wake', _this2._handleMachineWake); | ||
}; | ||
@@ -1763,2 +1851,7 @@ | ||
this._handleMachineWake = function () { | ||
_this2.stop(); | ||
_this2.start(); | ||
}; | ||
this._processNewMessages = function (newMessages) { | ||
@@ -1765,0 +1858,0 @@ var sendNewMessageCallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; |
{ | ||
"name": "quiq-chat", | ||
"version": "1.17.2", | ||
"version": "1.18.0", | ||
"description": | ||
@@ -5,0 +5,0 @@ "Library to help with network requests to create a webchat client for Quiq Messaging", |
@@ -24,5 +24,7 @@ // @flow | ||
import * as storage from './storage'; | ||
import SlumberParty from './slumberParty'; | ||
import logger from './logging'; | ||
import * as Senty from './sentry'; | ||
// Initialize Sentry | ||
Senty.init(); | ||
@@ -166,2 +168,5 @@ | ||
} | ||
// Listen for machine wakeup, so we can refresh app to clear any connection oddities | ||
SlumberParty.addEventListener('wake', this._handleMachineWake); | ||
} catch (err) { | ||
@@ -181,2 +186,5 @@ log.error(`Could not start QuiqChatClient: ${err.message}`); | ||
this.connected = false; | ||
// Stop listening for wake events | ||
SlumberParty.removeEventListener('wake', this._handleMachineWake); | ||
}; | ||
@@ -405,2 +413,7 @@ | ||
_handleMachineWake = () => { | ||
this.stop(); | ||
this.start(); | ||
}; | ||
_processNewMessages = ( | ||
@@ -407,0 +420,0 @@ newMessages: Array<TextMessage>, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
1853768
139
11189