Repository: hovancik/stretchly
Pull request #573 (2020-04-28 13:13:38)

Show Paused icon when Breaks are paused in Natural break


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0030e12..5a6ad07 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 ## [Unreleased]
 
 ## Fixed
-- multi-line status messages in Tray (Mac, Windows) 
+- multi-line status messages in Tray (Mac, Windows)
+
+## Added
+- show Paused icon when Breaks are paused in Natural break
 
 ## [0.99.2] - 2020-04-27
 ### Removed
diff --git a/app/breaksPlanner.js b/app/breaksPlanner.js
index 35e4ea0..6a32a9a 100644
--- a/app/breaksPlanner.js
+++ b/app/breaksPlanner.js
@@ -32,7 +32,7 @@ class BreaksPlanner extends EventEmitter {
       }
     })
 
-    this.naturalBreaksManager.on('naturalBreakFinished', (idleTime) => {
+    this.naturalBreaksManager.on('naturalBreakFinished', () => {
       if (!this.isPaused && this.scheduler.reference !== 'finishMicrobreak' && this.scheduler.reference !== 'finishBreak' && !this.dndManager.isOnDnd) {
         this.reset()
         this.emit('updateToolTip')
diff --git a/app/main.js b/app/main.js
index 957e3f3..4c3976c 100644
--- a/app/main.js
+++ b/app/main.js
@@ -164,7 +164,7 @@ function createTrayIcon () {
 
 function trayIconPath () {
   const params = {
-    paused: breakPlanner.isPaused,
+    paused: breakPlanner.isPaused || breakPlanner.naturalBreaksManager.isSchedulerCleared,
     monochrome: settings.get('useMonochromeTrayIcon'),
     inverted: settings.get('useMonochromeInvertedTrayIcon'),
     darkMode: nativeTheme.shouldUseDarkColors,
diff --git a/app/utils/naturalBreaksManager.js b/app/utils/naturalBreaksManager.js
index 5321866..ab4841f 100644
--- a/app/utils/naturalBreaksManager.js
+++ b/app/utils/naturalBreaksManager.js
@@ -7,6 +7,7 @@ class NaturalBreaksManager extends EventEmitter {
     this.usingNaturalBreaks = settings.get('naturalBreaks')
     this.timer = null
     this.isOnNaturalBreak = false
+    this.isSchedulerCleared = false
     if (this.usingNaturalBreaks) {
       this.start()
     }
@@ -20,6 +21,7 @@ class NaturalBreaksManager extends EventEmitter {
   stop () {
     this.usingNaturalBreaks = false
     this.isOnNaturalBreak = false
+    this.isSchedulerCleared = false
     clearTimeout(this.timer)
     this.timer = null
   }
@@ -42,10 +44,12 @@ class NaturalBreaksManager extends EventEmitter {
       if (this.isOnNaturalBreak && idleTime < 20000) {
         this.isOnNaturalBreak = false
         if (lastIdleTime > this.settings.get('naturalBreaksInactivityResetTime')) {
-          this.emit('naturalBreakFinished', idleTime)
+          this.isSchedulerCleared = false
+          this.emit('naturalBreakFinished')
         }
       }
       if (this.isOnNaturalBreak && idleTime > this.settings.get('naturalBreaksInactivityResetTime')) {
+        this.isSchedulerCleared = true
         this.emit('clearBreakScheduler')
       }
       lastIdleTime = idleTime


Test patch:
diff --git a/test/naturalBreaksManager.js b/test/naturalBreaksManager.js
index 25ca559..c9e3b00 100644
--- a/test/naturalBreaksManager.js
+++ b/test/naturalBreaksManager.js
@@ -16,6 +16,7 @@ describe('naturalBreaksManager', function () {
 
   it('should be running with default settings', () => {
     naturalBreaksManager.isOnNaturalBreak.should.be.equal(false)
+    naturalBreaksManager.isSchedulerCleared.should.be.equal(false)
     naturalBreaksManager.usingNaturalBreaks.should.be.equal(true)
   })
 
@@ -25,6 +26,7 @@ describe('naturalBreaksManager', function () {
     naturalBreaksManager = null
     naturalBreaksManager = new NaturalBreaksManager(settings)
     naturalBreaksManager.isOnNaturalBreak.should.be.equal(false)
+    naturalBreaksManager.isSchedulerCleared.should.be.equal(false)
     naturalBreaksManager.usingNaturalBreaks.should.be.equal(false)
   })
 
@@ -34,6 +36,7 @@ describe('naturalBreaksManager', function () {
     naturalBreaksManager = null
     naturalBreaksManager = new NaturalBreaksManager(settings)
     naturalBreaksManager.isOnNaturalBreak.should.be.equal(false)
+    naturalBreaksManager.isSchedulerCleared.should.be.equal(false)
     naturalBreaksManager.usingNaturalBreaks.should.be.equal(true)
   })
 
@@ -41,12 +44,14 @@ describe('naturalBreaksManager', function () {
     naturalBreaksManager.stop()
     naturalBreaksManager.start()
     naturalBreaksManager.isOnNaturalBreak.should.be.equal(false)
+    naturalBreaksManager.isSchedulerCleared.should.be.equal(false)
     naturalBreaksManager.usingNaturalBreaks.should.be.equal(true)
   })
 
   it('should stop when stop()', () => {
     naturalBreaksManager.stop()
     naturalBreaksManager.usingNaturalBreaks.should.be.equal(false)
+    naturalBreaksManager.isSchedulerCleared.should.be.equal(false)
     naturalBreaksManager.isOnNaturalBreak.should.be.equal(false)
     naturalBreaksManager.idleTime.should.be.equal(0)
   })