import { JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY } from '../../common/constants' ; type JobId = string ; const set = ( jobs ) => { sessionStorage . setItem ( JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY , JSON . stringify ( jobs ) ) ; } ; const getAll = ( ) : string [ ] => { const sessionValue = sessionStorage . getItem ( JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY ) ; return sessionValue ? JSON . parse ( sessionValue ) : [ ] ; } ; export const add = ( jobId ) => { const jobs = getAll ( ) ; jobs . push ( jobId ) ; set ( jobs ) ; } ; export const remove = ( jobId ) => { const jobs = getAll ( ) ; const index = jobs . indexOf ( jobId ) ; if ( ! index ) { throw new Error ( 'Unable to find job to remove it' ) ; } jobs . splice ( index , 1 ) ; set ( jobs ) ; } ;