|
@ -384,61 +384,56 @@ async function getSettingById(id) { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function setMostRecentNotified(id) { |
|
|
async function setMostRecentNotified(id) { |
|
|
try { |
|
|
try { |
|
|
const db = await openIndexedDB("TimeSafari"); |
|
|
const db = await openIndexedDB("TimeSafari"); |
|
|
const transaction = db.transaction("settings", "readwrite"); |
|
|
const transaction = db.transaction("settings", "readwrite"); |
|
|
const store = transaction.objectStore("settings"); |
|
|
const store = transaction.objectStore("settings"); |
|
|
|
|
|
|
|
|
const data = await getRecord(store, 1); |
|
|
const data = await getRecord(store, 1); |
|
|
if (data) { |
|
|
if (data) { |
|
|
data["lastNotifiedClaimId"] = id; |
|
|
data["lastNotifiedClaimId"] = id; |
|
|
await updateRecord(store, data); |
|
|
await updateRecord(store, data); |
|
|
} else { |
|
|
} else { |
|
|
console.error("Record not found"); |
|
|
console.error("Record not found"); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
transaction.oncomplete = () => db.close(); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error("Database error: " + error.message); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
transaction.oncomplete = () => db.close(); |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.error("Database error: " + error.message); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function openIndexedDB(dbName) { |
|
|
function openIndexedDB(dbName) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
const request = indexedDB.open(dbName); |
|
|
const request = indexedDB.open(dbName); |
|
|
request.onerror = () => reject(request.error); |
|
|
request.onerror = () => reject(request.error); |
|
|
request.onsuccess = () => resolve(request.result); |
|
|
request.onsuccess = () => resolve(request.result); |
|
|
request.onupgradeneeded = (event) => { |
|
|
request.onupgradeneeded = (event) => { |
|
|
const db = event.target.result; |
|
|
const db = event.target.result; |
|
|
if (!db.objectStoreNames.contains("settings")) { |
|
|
if (!db.objectStoreNames.contains("settings")) { |
|
|
db.createObjectStore("settings"); |
|
|
db.createObjectStore("settings"); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getRecord(store, key) { |
|
|
function getRecord(store, key) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
const request = store.get(key); |
|
|
const request = store.get(key); |
|
|
request.onsuccess = () => resolve(request.result); |
|
|
request.onsuccess = () => resolve(request.result); |
|
|
request.onerror = () => reject(request.error); |
|
|
request.onerror = () => reject(request.error); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function updateRecord(store, data) { |
|
|
function updateRecord(store, data) { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
const request = store.put(data); |
|
|
const request = store.put(data); |
|
|
request.onsuccess = () => resolve(request.result); |
|
|
request.onsuccess = () => resolve(request.result); |
|
|
request.onerror = () => reject(request.error); |
|
|
request.onerror = () => reject(request.error); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function fetchAllAccounts() { |
|
|
async function fetchAllAccounts() { |
|
|
return new Promise((resolve, reject) => { |
|
|
return new Promise((resolve, reject) => { |
|
|
let openRequest = indexedDB.open("TimeSafariAccounts"); |
|
|
let openRequest = indexedDB.open("TimeSafariAccounts"); |
|
@ -531,7 +526,7 @@ async function getNotificationCount() { |
|
|
} |
|
|
} |
|
|
const most_recent_notified = claims[0]["id"]; |
|
|
const most_recent_notified = claims[0]["id"]; |
|
|
await setMostRecentNotified(most_recent_notified); |
|
|
await setMostRecentNotified(most_recent_notified); |
|
|
return "TEST"; |
|
|
return "TEST"; |
|
|
} else { |
|
|
} else { |
|
|
console.error(response.status); |
|
|
console.error(response.status); |
|
|
} |
|
|
} |
|
|