From 92ace6784629f3f508ed466884e511867e59acfc Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Wed, 21 Mar 2018 15:17:53 -0400 Subject: [PATCH] Start idle listener on startup --- js/background.js | 9 +++++++++ preload.js | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/js/background.js b/js/background.js index ca2a59ffa..a39bc59f2 100644 --- a/js/background.js +++ b/js/background.js @@ -14,6 +14,7 @@ ;(function() { 'use strict'; + const { IdleListener } = Signal; const { Errors, Message } = window.Signal.Types; const { upgradeMessageSchema } = window.Signal.Migrations; @@ -75,6 +76,11 @@ storage.fetch(); + const idleListener = new IdleListener(); + idleListener.on('idle', (event) => { + console.log('Detected user idle:', event); + }); + // We need this 'first' check because we don't want to start the app up any other time // than the first time. And storage.fetch() will cause onready() to fire. var first = true; @@ -85,9 +91,12 @@ first = false; ConversationController.load().then(start, start); + idleListener.start(); }); Whisper.events.on('shutdown', function() { + idleListener.stop(); + if (messageReceiver) { messageReceiver.close().then(function() { Whisper.events.trigger('shutdown-complete'); diff --git a/preload.js b/preload.js index 151856242..cae0288e8 100644 --- a/preload.js +++ b/preload.js @@ -123,6 +123,10 @@ Message.upgradeSchema(message, upgradeSchemaContext); window.Signal = window.Signal || {}; + + const { IdleListener} = require('./js/modules/idle_listener'); + window.Signal.IdleListener = IdleListener; + window.Signal.Logs = require('./js/modules/logs'); window.Signal.OS = require('./js/modules/os'); window.Signal.Backup = require('./js/modules/backup');