background/background.js
/* 
  Write all cache entries to local storage and reset creation date. 
  This is useful when clocks changes from 23:59:59 to 00:00:00 thus seperating dates.
*/
Write all cache entries to local storage and reset creation date.
This is useful when clocks changes from 23:59:59 to 00:00:00 thus seperating dates.
Write all cache entries to local storage and reset creation date . This is useful when clocks changes from 23 : 59 : 59 to 00 : 00 : 00 thus seperating dates .
async function writeCacheToStorage(flush = false) {
  if (_sessionCache.length === 0) {
    return;
  }
  for (let i = 0; i < _sessionCache.length; i++) {
    const session = _sessionCache[i];
    const duration = Math.round((new Date() - session.created));
    await activity_add(session.hostname, session.created.toJSON(), duration);
    if (flush === true) {
      _sessionCache.splice(i, 1);
    } else {
      _sessionCache[i].created = new Date();
    }
  }
}
async function writeCacheToStorage ( flush = false ) { if ( _sessionCache . length === 0 ) { return ; } for ( let i = 0 ; i < _sessionCache . length ; i ++ ) { const session = _sessionCache [ i ] ; const duration = Math . round ( ( new Date ( ) - session . created ) ) ; await activity_add ( session . hostname , session . created . toJSON ( ) , duration ) ; if ( flush === true ) { _sessionCache . splice ( i , 1 ) ; } else { _sessionCache [ i ] . created = new Date ( ) ; } } }
Write all cache entries to local storage and reset creation date.
Write all cache entries to local storage and reset creation date .
//console.log("Session written to storage: " + session.hostname, duration);