@@ -335,6 +335,11 @@ function ExpandedTaskGroup({sortedTasks, hidePanel}: ExpandedTaskGroupProps) {
335
335
336
336
const markCompletionTimeout = useRef < number | undefined > ( undefined ) ;
337
337
338
+ const unseenDoneTasks = useMemo (
339
+ ( ) => sortedTasks . filter ( task => taskIsDone ( task ) && ! task . completionSeen ) ,
340
+ [ sortedTasks ]
341
+ ) ;
342
+
338
343
function completionTimeout ( time : number ) : Promise < void > {
339
344
window . clearTimeout ( markCompletionTimeout . current ) ;
340
345
return new Promise ( resolve => {
@@ -343,16 +348,16 @@ function ExpandedTaskGroup({sortedTasks, hidePanel}: ExpandedTaskGroupProps) {
343
348
}
344
349
345
350
const markTasksAsSeen = useCallback ( ( ) => {
346
- const unseenDoneTasks = sortedTasks
351
+ const tasksToMarkComplete = sortedTasks
347
352
. filter ( task => taskIsDone ( task ) && ! task . completionSeen )
348
353
. map ( task => ( { ...task , completionSeen : true } ) ) ;
349
354
350
355
if ( isDemoModeActive ( ) ) {
351
- for ( const unseenDoneTask of unseenDoneTasks ) {
352
- updateDemoWalkthroughTask ( unseenDoneTask ) ;
356
+ for ( const task of tasksToMarkComplete ) {
357
+ updateDemoWalkthroughTask ( task ) ;
353
358
}
354
359
} else {
355
- mutateOnboardingTasks . mutate ( unseenDoneTasks ) ;
360
+ mutateOnboardingTasks . mutate ( tasksToMarkComplete ) ;
356
361
}
357
362
} , [ mutateOnboardingTasks , sortedTasks ] ) ;
358
363
@@ -367,11 +372,14 @@ function ExpandedTaskGroup({sortedTasks, hidePanel}: ExpandedTaskGroupProps) {
367
372
) ;
368
373
369
374
useEffect ( ( ) => {
370
- markSeenOnOpen ( ) ;
375
+ if ( unseenDoneTasks . length > 0 ) {
376
+ markSeenOnOpen ( ) ;
377
+ }
378
+
371
379
return ( ) => {
372
380
window . clearTimeout ( markCompletionTimeout . current ) ;
373
381
} ;
374
- } , [ ] ) ; // eslint-disable-line react-hooks/exhaustive-deps
382
+ } , [ unseenDoneTasks , markSeenOnOpen ] ) ;
375
383
376
384
return (
377
385
< Fragment >
0 commit comments