@@ -19,6 +19,9 @@ const CONFIGURATION_KEY = `${ExperimentalTasksSettings.SectionName}.${Experiment
1919// keep a local copy of the tasks with their toast id
2020const currentTasks: TaskInfoWithToastId [] = $state ([]);
2121
22+ // stores a list of long-duration tasks (60+ seconds) that have been completed and showed
23+ const showedAgainTasks: TaskInfoWithToastId [] = $state ([]);
24+
2225// is that the configuration is enabled or not, will be updated by configuration
2326let enabled = $state (false );
2427
@@ -50,11 +53,23 @@ function handleTasks(tasks: TaskInfo[]): void {
5053 // replace the task in the currentTasks
5154 currentTasks .splice (currentTasks .indexOf (currentTask ), 1 , { ... taskInfo , toastId: currentTask .toastId });
5255 toast .set (currentTask .toastId , createToastOptions (taskInfo ));
56+
57+ const time = Date .now ();
58+ // The task is completed, was running for at least 60s and is not in already showed tasks
59+ if (
60+ taskInfo .state === ' completed' &&
61+ time >= taskInfo .started + 60000 &&
62+ ! showedAgainTasks .find (currentTask => currentTask .id === taskInfo .id )
63+ ) {
64+ displayNewToast (taskInfo );
65+ }
66+ showedAgainTasks .push (currentTask );
5367 }
5468 }
5569
5670 // remove from currentTasks all the items from deletedTasks
5771 for (const taskInfo of toDeleteTasks ) {
72+ showedAgainTasks .splice (showedAgainTasks .indexOf (taskInfo ), 1 );
5873 currentTasks .splice (currentTasks .indexOf (taskInfo ), 1 );
5974 toast .pop (taskInfo .toastId );
6075 }
@@ -73,7 +88,6 @@ function createToastOptions(taskInfo: TaskInfo): SvelteToastOptions {
7388 sendIdTo: ' toastId' ,
7489 },
7590 dismissable: false ,
76- initial: 0 ,
7791 };
7892}
7993
0 commit comments