Skip to content

Commit

Permalink
3.6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
MayGo committed Jan 23, 2020
1 parent ab4eeb5 commit 457d232
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
28 changes: 27 additions & 1 deletion electron/app/background-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,49 @@ import { appConstants } from './app-constants';
import { logTrackItemJob } from './jobs/log-track-item-job';
import { statusTrackItemJob } from './jobs/status-track-item-job';
import { appTrackItemJob } from './jobs/app-track-item-job';
import { dialog } from 'electron';

let logger = logManager.getLogger('BackgroundJob');

export class BackgroundJob {
errorDialogIsOpen = false;
interval;
async runAll() {
if (this.interval) {
clearInterval(this.interval);
}

try {
await appTrackItemJob.run();
await statusTrackItemJob.run();
await logTrackItemJob.run();

if (!this.errorDialogIsOpen) {
this.interval = setInterval(this.runAll, appConstants.BACKGROUND_JOB_INTERVAL);
}
} catch (e) {
logger.error('BackgroundJob:', e);

const activeWinError = e.stdout;

if (activeWinError) {
this.errorDialogIsOpen = true;
await dialog.showMessageBox({
message: activeWinError.replace('active-win', 'Tockler'),
});

this.errorDialogIsOpen = false;
this.runAll();
}
}

return true;
}
init() {
logger.info('Environment:' + process.env.NODE_ENV);
logger.info('Running background service.');
setInterval(this.runAll, appConstants.BACKGROUND_JOB_INTERVAL);

this.runAll();
}
}

Expand Down
3 changes: 2 additions & 1 deletion electron/app/jobs/app-track-item-job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export class AppTrackItemJob {
}

this.lastUpdatedItem = updatedItem;
return true;
} catch (error) {
logger.info('Error activeWin', error.message);
throw error;
}
return true;
}

checkIfIsInCorrectState(): void {
Expand Down
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tockler",
"version": "3.6.2",
"version": "3.6.3",
"description": "Automatically track applications usage and working time",
"author": "Maigo Erit <[email protected]>",
"license": "GPL-2.0",
Expand Down

0 comments on commit 457d232

Please sign in to comment.