@@ -57,6 +57,7 @@ export interface AnnotationSlice {
57
57
numberOfAnnotationsCreated : number ;
58
58
numberOfAnnotationsChanged : number ;
59
59
numberOfAnnotationsDeleted : number ;
60
+ numberOfCommentsTouched : number ;
60
61
}
61
62
62
63
// Initial state -------------------------------------------------------------------------------------------------------
@@ -88,6 +89,7 @@ export const initialAnnotationSlice: AnnotationSlice = {
88
89
numberOfAnnotationsCreated : 0 ,
89
90
numberOfAnnotationsChanged : 0 ,
90
91
numberOfAnnotationsDeleted : 0 ,
92
+ numberOfCommentsTouched : 0 ,
91
93
} ;
92
94
93
95
// Thunks --------------------------------------------------------------------------------------------------------------
@@ -616,12 +618,6 @@ const annotationsSlice = createSlice({
616
618
updateQueue ( state ) ;
617
619
} ,
618
620
upsertValueAnnotation ( state , action : PayloadAction < ValueAnnotation > ) {
619
- updateCreationOrChangedCount (
620
- state ,
621
- state . annotations . valueAnnotations [ action . payload . target ] ,
622
- action . payload ,
623
- ) ;
624
-
625
621
if ( action . payload . variant === 'required' || action . payload . variant === 'omitted' ) {
626
622
// @ts -ignore
627
623
delete action . payload . defaultValue ;
@@ -634,6 +630,12 @@ const annotationsSlice = createSlice({
634
630
action . payload . defaultValue = parseFloat ( action . payload . defaultValue ) ;
635
631
}
636
632
633
+ updateCreationOrChangedCount (
634
+ state ,
635
+ state . annotations . valueAnnotations [ action . payload . target ] ,
636
+ action . payload ,
637
+ ) ;
638
+
637
639
state . annotations . valueAnnotations [ action . payload . target ] = withAuthorAndReviewers (
638
640
state . annotations . valueAnnotations [ action . payload . target ] ,
639
641
action . payload ,
@@ -644,8 +646,6 @@ const annotationsSlice = createSlice({
644
646
} ,
645
647
upsertValueAnnotations ( state , action : PayloadAction < ValueAnnotation [ ] > ) {
646
648
action . payload . forEach ( ( annotation ) => {
647
- updateCreationOrChangedCount ( state , state . annotations . valueAnnotations [ annotation . target ] , annotation ) ;
648
-
649
649
if ( annotation . variant === 'required' || annotation . variant === 'omitted' ) {
650
650
// @ts -ignore
651
651
delete annotation . defaultValue ;
@@ -658,6 +658,8 @@ const annotationsSlice = createSlice({
658
658
annotation . defaultValue = parseFloat ( annotation . defaultValue ) ;
659
659
}
660
660
661
+ updateCreationOrChangedCount ( state , state . annotations . valueAnnotations [ annotation . target ] , annotation ) ;
662
+
661
663
state . annotations . valueAnnotations [ annotation . target ] = withAuthorAndReviewers (
662
664
state . annotations . valueAnnotations [ annotation . target ] ,
663
665
annotation ,
@@ -735,6 +737,10 @@ const updateCreationOrChangedCount = function (
735
737
} else {
736
738
state . numberOfAnnotationsCreated ++ ;
737
739
}
740
+
741
+ if ( ( oldAnnotation ?. comment ?? '' ) !== newAnnotation . comment ) {
742
+ state . numberOfCommentsTouched ++ ;
743
+ }
738
744
} ;
739
745
740
746
const withAuthorAndReviewers = function < T extends Annotation > (
@@ -1025,3 +1031,5 @@ export const selectNumberOfAnnotationsChanged = (state: RootState): number =>
1025
1031
selectAnnotationSlice ( state ) . numberOfAnnotationsChanged ;
1026
1032
export const selectNumberOfAnnotationsDeleted = ( state : RootState ) : number =>
1027
1033
selectAnnotationSlice ( state ) . numberOfAnnotationsDeleted ;
1034
+ export const selectNumberOfCommentsTouched = ( state : RootState ) : number =>
1035
+ selectAnnotationSlice ( state ) . numberOfCommentsTouched ;
0 commit comments