background/background.js
/* 
  Task to run at midnight to create new sessions for the new day
*/
Task to run at midnight to create new sessions for the new day
Task to run at midnight to create new sessions for the new day
async function midnightTask() {
  await writeCacheToStorage();
  let now = new Date();
  let midnight = new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 0, 0, 0);
  let msTillMidnight = midnight.getTime() - now.getTime(); 
  let midnightTimeout = setTimeout(midnightTask, msTillMidnight);
}
async function midnightTask ( ) { await writeCacheToStorage ( ) ; let now = new Date ( ) ; let midnight = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) + 1 , 0 , 0 , 0 ) ; let msTillMidnight = midnight . getTime ( ) - now . getTime ( ) ; let midnightTimeout = setTimeout ( midnightTask , msTillMidnight ) ; }
Task to run at midnight to create new sessions for the new day
Task to run at midnight to create new sessions for the new day
// Write cache to storage at midnight // difference in milliseconds //console.log(`Midnight task will run in ${msTillMidnight / 1000 / 60} minutes`);