@@ -10,7 +10,7 @@ import * as actions from './entry.actions';
1010
1111@Injectable ( )
1212export class EntryEffects {
13- constructor ( private actions$ : Actions , private entryService : EntryService , private toastrService : ToastrService ) { }
13+ constructor ( private actions$ : Actions , private entryService : EntryService , private toastrService : ToastrService ) { }
1414
1515 @Effect ( )
1616 loadEntriesSummary$ : Observable < Action > = this . actions$ . pipe (
@@ -36,17 +36,16 @@ export class EntryEffects {
3636 map ( ( activeEntry ) => {
3737 if ( activeEntry ) {
3838 const today = new Date ( ) ;
39- const entryStartDate = new Date ( activeEntry . start_date ) ;
39+ const entryStartDate = new Date ( activeEntry . start_date ) ;
4040 const isSameDay = ( today . getDate ( ) === entryStartDate . getDate ( )
41- && today . getMonth ( ) === entryStartDate . getMonth ( )
42- && today . getFullYear ( ) === entryStartDate . getFullYear ( ) ) ;
41+ && today . getMonth ( ) === entryStartDate . getMonth ( )
42+ && today . getFullYear ( ) === entryStartDate . getFullYear ( ) ) ;
4343 if ( isSameDay ) {
4444 return new actions . LoadActiveEntrySuccess ( activeEntry ) ;
4545 } else {
46- const endDate = activeEntry . start_date ;
46+ const endDate = new Date ( activeEntry . start_date ) ;
4747 endDate . setHours ( 23 , 59 , 59 ) ;
48- activeEntry . end_date = endDate . toISOString ( ) ;
49- return new actions . UpdateActiveEntry ( activeEntry ) ;
48+ return new actions . UpdateActiveEntry ( { d : activeEntry . id , end_date : endDate . toISOString ( ) } ) ;
5049 }
5150 }
5251 } ) ,
@@ -119,7 +118,7 @@ export class EntryEffects {
119118 mergeMap ( ( entry ) =>
120119 this . entryService . updateActiveEntry ( entry ) . pipe (
121120 map ( ( entryResponse ) => {
122- if ( entryResponse . end_date ) {
121+ if ( entryResponse . end_date && entry . start_date === null ) {
123122 this . toastrService . success ( INFO_SAVED_SUCCESSFULLY ) ;
124123 }
125124 return new actions . UpdateActiveEntrySuccess ( entryResponse ) ;
0 commit comments