Skip to content

Commit 6344ce4

Browse files
committed
Added quit button and fixed issue with timer finish
1 parent 43e1f0c commit 6344ce4

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

Diff for: src/libs/timer.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,18 @@ function Timer() {
1717
var time = object.getCurrentTime();
1818

1919
if (time.minutes >= 25) {
20-
object.stop(true);
20+
object.stop(false);
2121
return;
2222
}
2323

2424
object.emit('update', time);
2525
}
2626

2727
object.stop = function(interrupt) {
28+
if (interrupt === typeof 'undefined' || interrupt == null) {
29+
interrupt = true;
30+
}
31+
2832
clearInterval(interval);
2933
object.emit('stop', interrupt);
3034
}

Diff for: src/script.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,21 @@ var menuTray = null,
1515
menuItems = {
1616
'start': {
1717
label: 'Start',
18-
click: timer.start
18+
click: function() {
19+
timer.start()
20+
}
1921
},
2022
'stop': {
2123
label: 'Stop',
22-
click: timer.stop
24+
click: function () {
25+
timer.stop()
26+
},
27+
},
28+
'quit': {
29+
label: 'Quit Application',
30+
click: function () {
31+
app.quit()
32+
},
2333
}
2434
};
2535

@@ -34,11 +44,11 @@ app.on('ready', function(){
3444
function init() {
3545
menuTray = new tray(path.join(__dirname, 'assets/img/pomodoro-w.png'));
3646
menuTray.setTitle('');
37-
menuTray.setContextMenu(menu.buildFromTemplate([menuItems.start]));
47+
menuTray.setContextMenu(menu.buildFromTemplate([menuItems.start, menuItems.quit]));
3848

3949
timer.on('start', function() {
4050
window.webContents.send('play-sound', path.join(__dirname, 'assets/sound/windup.mp3'));
41-
menuTray.setContextMenu(menu.buildFromTemplate([menuItems.stop]));
51+
menuTray.setContextMenu(menu.buildFromTemplate([menuItems.stop, menuItems.quit]));
4252
});
4353

4454
timer.on('stop', function(interrupted) {
@@ -51,7 +61,7 @@ function init() {
5161
sound: path.join(__dirname, 'assets/sound/bell.mp3') });
5262
}
5363

54-
menuTray.setContextMenu(menu.buildFromTemplate([menuItems.start]));
64+
menuTray.setContextMenu(menu.buildFromTemplate([menuItems.start, menuItems.quit]));
5565
});
5666

5767
timer.on('update', function(data) {

0 commit comments

Comments
 (0)