Added counting of pending notifications
This commit is contained in:
@@ -392,9 +392,9 @@ async function setMostRecentNotified(id) {
|
|||||||
|
|
||||||
const dbName = "TimeSafari";
|
const dbName = "TimeSafari";
|
||||||
const storeName = "settings";
|
const storeName = "settings";
|
||||||
const key = 1; // The ID of the record you want to update
|
const key = 1;
|
||||||
const propertyToUpdate = "lastNotifiedClaimId"; // The property you want to update
|
const propertyToUpdate = "lastNotifiedClaimId";
|
||||||
const newValue = id; // The new value for the property
|
const newValue = id;
|
||||||
|
|
||||||
let request = indexedDB.open(dbName);
|
let request = indexedDB.open(dbName);
|
||||||
|
|
||||||
@@ -527,8 +527,25 @@ async function getNotificationCount() {
|
|||||||
);
|
);
|
||||||
console.error(did, response.status);
|
console.error(did, response.status);
|
||||||
const claims = await response.json();
|
const claims = await response.json();
|
||||||
|
// formulate a message back for notifications
|
||||||
|
let lastNotifiedClaimId = null;
|
||||||
|
if ('lastNotifiedClaimId' in settings) {
|
||||||
|
lastNotifiedClaimId = settings['lastNotifiedClaimId'];
|
||||||
|
}
|
||||||
|
let newClaims = 0;
|
||||||
|
// search for id recent notified -- if it exists if not return everything count
|
||||||
|
for (var i=0; i< response.json()['data'].length; i++) {
|
||||||
|
let claim = response.json()['data'];
|
||||||
|
if (claim['id'] == lastNotifiedClaimId) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
newClaims++;
|
||||||
|
}
|
||||||
|
// make the notification message here
|
||||||
|
|
||||||
// first claim is the most recent (?)
|
// first claim is the most recent (?)
|
||||||
const most_recent_notified = claims[0]['id']
|
const most_recent_notified = claims[0]['id'];
|
||||||
|
await setMostRecentNotified(most_recent_notified);
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user