File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -137,13 +137,8 @@ window.TogglButton = {
137
137
} ) ;
138
138
}
139
139
if ( resp . data . time_entries ) {
140
- resp . data . time_entries . some ( function ( timeEntry ) {
141
- if ( timeEntry . duration < 0 ) {
142
- entry = timeEntry ;
143
- return true ;
144
- }
145
- return false ;
146
- } ) ;
140
+ const { time_entries : timeEntries } = resp . data ;
141
+ entry = timeEntries . find ( te => te . duration < 0 ) || null ;
147
142
}
148
143
149
144
if ( TogglButton . hasWorkspaceBeenRevoked ( resp . data . workspaces ) ) {
@@ -580,6 +575,11 @@ window.TogglButton = {
580
575
} ) ;
581
576
} ,
582
577
578
+ latestEntry : function ( ) {
579
+ const timeEntries = TogglButton . $user . time_entries || [ null ] ;
580
+ return timeEntries [ timeEntries . length - 1 ] ;
581
+ } ,
582
+
583
583
checkPomodoroAlarm : async function ( entry ) {
584
584
const duration = new Date ( ) - new Date ( entry . start ) ;
585
585
const pomodoroInterval = await db . get ( 'pomodoroInterval' ) ;
@@ -2042,10 +2042,8 @@ window.TogglButton = {
2042
2042
startAutomatically &&
2043
2043
! ! TogglButton . $user
2044
2044
) {
2045
- const lastEntryString = await db . get ( 'latestStoppedEntry' ) ;
2046
- if ( lastEntryString ) {
2047
- const lastEntry = JSON . parse ( lastEntryString ) ;
2048
- TogglButton . $latestStoppedEntry = lastEntry ;
2045
+ TogglButton . $latestStoppedEntry = TogglButton . latestEntry ( ) ;
2046
+ if ( TogglButton . $latestStoppedEntry ) {
2049
2047
TogglButton . createTimeEntry ( TogglButton . $latestStoppedEntry , null ) ;
2050
2048
TogglButton . hideNotification ( 'remind-to-track-time' ) ;
2051
2049
}
You can’t perform that action at this time.
0 commit comments