Track last use via heartbeat instead of by last startup
This commit is contained in:

committed by
Ken Powers

parent
08dbff803a
commit
fa70fa2ecf
@@ -360,13 +360,18 @@
|
|||||||
await storage.put('indexeddb-delete-needed', true);
|
await storage.put('indexeddb-delete-needed', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentStartup = Date.now();
|
const now = Date.now();
|
||||||
const lastStartup = storage.get('lastStartup');
|
const lastHeartbeat = storage.get('lastHeartbeat');
|
||||||
await storage.put('lastStartup', currentStartup);
|
await storage.put('lastStartup', Date.now());
|
||||||
|
|
||||||
const THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000;
|
const THIRTY_DAYS = 30 * 24 * 60 * 60 * 1000;
|
||||||
|
|
||||||
if (lastStartup > 0 && currentStartup - lastStartup > THIRTY_DAYS) {
|
if (lastHeartbeat > 0 && now - lastHeartbeat > THIRTY_DAYS) {
|
||||||
await unlinkAndDisconnect();
|
await unlinkAndDisconnect();
|
||||||
|
} else {
|
||||||
|
storage.put('lastHeartbeat', Date.now());
|
||||||
|
const TWELVE_HOURS = 12 * 60 * 60 * 1000;
|
||||||
|
setInterval(() => storage.put('lastHeartbeat', Date.now()), TWELVE_HOURS);
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentVersion = window.getVersion();
|
const currentVersion = window.getVersion();
|
||||||
|
Reference in New Issue
Block a user