11import Ember from 'ember' ;
2- import { padStart } from 'lodash/string' ;
2+ import { padStart } from 'lodash/string' ;
33
44const {
55 computed,
6- computed : { notEmpty } ,
6+ computed : { notEmpty} ,
77 run : { cancel, later} ,
8- inject : { service }
8+ inject : { service}
99} = Ember ;
1010
1111export default Ember . Service . extend ( {
1212 ipcRenderer : service ( ) ,
13+ lastMessage : service ( ) ,
1314 minutes : 0 ,
1415 seconds : 0 ,
1516 firstTick : null ,
@@ -21,11 +22,11 @@ export default Ember.Service.extend({
2122 return this . _format ( this . get ( 'duration' ) / 60 ) ;
2223 } ) ,
2324
24- second : computed ( 'duration' , function ( ) {
25+ second : computed ( 'duration' , function ( ) {
2526 return this . _format ( this . get ( 'duration' ) % 60 ) ;
2627 } ) ,
2728
28- duration : computed ( 'lastTick' , function ( ) {
29+ duration : computed ( 'lastTick' , function ( ) {
2930 let start = this . get ( 'firstTick' ) ,
3031 end = this . get ( 'lastTick' ) ;
3132
@@ -47,8 +48,7 @@ export default Ember.Service.extend({
4748 } ,
4849
4950 pause ( ) {
50- cancel ( this . get ( 'nextTick' ) ) ;
51- this . set ( 'nextTick' , null ) ;
51+ this . _pause ( ) ;
5252 this . get ( 'ipcRenderer' ) . setLastTick ( this . get ( 'lastTick' ) ) ;
5353 } ,
5454
@@ -86,8 +86,15 @@ export default Ember.Service.extend({
8686 _pause ( ) {
8787 cancel ( this . get ( 'nextTick' ) ) ;
8888 this . set ( 'nextTick' , null ) ;
89+ this . _notifyLastTick ( { minute : this . get ( 'minute' ) , second : this . get ( 'second' ) } ) ;
90+ this . reset ( ) ;
91+
8992 } ,
9093 _currentTime ( ) {
91- return new Date ( Math . floor ( new Date ( ) / 1000 ) * 1000 )
94+ return new Date ( Math . floor ( new Date ( ) / 1000 ) * 1000 )
95+ } ,
96+
97+ _notifyLastTick ( lastDuration ) {
98+ this . get ( 'lastMessage' ) . setMsg ( { lastDuration : `${ lastDuration . minute } :${ lastDuration . second } ` } )
9299 }
93100} ) ;
0 commit comments