Skip to content

Commit

Permalink
Merge pull request RocketChat#228 from vitamindck/develop
Browse files Browse the repository at this point in the history
set "available" status from system idle time
  • Loading branch information
rodrigok committed Oct 11, 2016
2 parents a25805e + 25dfd12 commit 6d9c79a
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
7 changes: 3 additions & 4 deletions app/app.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import './branding/branding.js';
import { start } from './scripts/start';
import { remote } from 'electron';

var app = remote.app;

Bugsnag.metaData = {
// platformId: app.process.platform,
// platformArch: app.process.arch,
// electronVersion: app.process.versions.electron,
version: app.getVersion()
// platformVersion: cordova.platformVersion
// build: appInfo.build
// platformVersion: cordova.platformVersion
// build: appInfo.build
};

Bugsnag.appVersion = app.getVersion();

window.$ = window.jQuery = require('./vendor/jquery-1.12.0');
start();
start();
10 changes: 10 additions & 0 deletions app/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ const toaster = new Toaster();
// in config/env_xxx.json file.
import env from './env';

/* serverside system idle integration */
var ffi = require('ffi'),
idle = require('@paulcbetts/system-idle-time');

var mainWindow;

if (process.platform !== 'darwin') {
Expand Down Expand Up @@ -136,3 +140,9 @@ app.on('ready', function () {
app.on('window-all-closed', function () {
app.quit();
});

/* system idle time synchronous event process */
ipcMain.on('getSystemIdleTime', function(event) {
/* why does this fire twice?!?!? */
event.returnValue = idle.getIdleTime();
});
9 changes: 7 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
"productName": "Rocket.Chat+",
"identifier": "chat.rocket",
"description": "Rocket.Chat Native Cross-Platform Desktop Application via Electron.",
"version": "1.3.1",
"version": "1.3.3",
"build": "15",
"author": "Rocket.Chat Support <support@rocket.chat>",
"copyright": "© 2016, Rocket.Chat",
"main": "background.js",
"dependencies": {
"@paulcbetts/system-idle-time": "^1.0.4",
"ffi": "^2.1.0",
"electron-notification-shim": "^1.1.0",
"electron-toaster": "^2.0.1",
"fs-jetpack": "^0.7.0"
Expand All @@ -19,5 +21,8 @@
"MAS": "3rd Party Mac Developer Application: Konecty Informatica Ltda (DX85ENM22A)",
"MASInstaller": "3rd Party Mac Developer Installer: Konecty Informatica Ltda (DX85ENM22A)"
},
"LSApplicationCategoryType": "public.app-category.productivity"
"LSApplicationCategoryType": "public.app-category.productivity",
"scripts": {
"postinstall": "node ../tasks/rebuild_native_modules"
}
}
13 changes: 13 additions & 0 deletions app/scripts/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,16 @@ window.addEventListener('contextmenu', function(event){
menu.popup(remote.getCurrentWindow());
}, 0);
}, false);

/* userPresence away timer based on system idle time */
function getSystemIdleTime() {
return IPC.sendSync('getSystemIdleTime');
}

setInterval(function(){
try {
if(getSystemIdleTime() < UserPresence.awayTime) {
UserPresence.setOnline()
}
} catch(e) {}
},1e3)
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"devDependencies": {
"asar": "^0.10.0",
"electron-prebuilt": "0.36.10",
"electron-rebuild": "^1.2.0",
"fs-jetpack": "^0.7.0",
"gulp": "^3.9.0",
"gulp-less": "^3.0.3",
Expand All @@ -14,8 +15,8 @@
"electron-notification-shim": "^1.1.0"
},
"optionalDependencies": {
"appdmg": "^0.3.2",
"rcedit": "^0.4.0"
"appdmg": "^0.4.5",
"rcedit": "^0.6.0"
},
"scripts": {
"postinstall": "cd app && npm install",
Expand Down

0 comments on commit 6d9c79a

Please sign in to comment.