implemented page visibility api for cashier status
This commit is contained in:
parent
42c8670d3f
commit
11f17b919a
@ -184,7 +184,6 @@ function statusReconnect() {
|
||||
}
|
||||
|
||||
var status_interval_instance = null;
|
||||
// add page visibility API to startStatusInterval()
|
||||
function startStatusInterval() {
|
||||
if (status_interval_instance) {
|
||||
clearInterval(status_interval_instance);
|
||||
|
||||
@ -15,6 +15,7 @@ function syncUserData(obsName, data) {
|
||||
const dataToSend = Crypto.AES.encrypt(JSON.stringify(data), myPrivKey);
|
||||
return floCloudAPI.sendApplicationData(dataToSend, obsName, { receiverID: myFloID });
|
||||
}
|
||||
// store user data in separate IDB
|
||||
async function organizeSyncedData(obsName) {
|
||||
const fetchedData = await floCloudAPI.requestApplicationData(obsName, { mostRecent: true, senderIDs: [myFloID], receiverID: myFloID });
|
||||
if (fetchedData.length && await compactIDB.readData(obsName, 'lastSyncTime') !== fetchedData[0].time) {
|
||||
|
||||
@ -864,4 +864,13 @@ function randomString(length) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
document.addEventListener("visibilitychange", handleVisibilityChange, false);
|
||||
function handleVisibilityChange() {
|
||||
if (document.visibilityState === "hidden") {
|
||||
// code if page is hidden
|
||||
} else {
|
||||
startStatusInterval()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user