Browse Source

Added grabbing settings

pull/78/head
Matthew Raymer 1 year ago
parent
commit
ceb12ef5bc
  1. 28
      sw_scripts/safari-notifications.js

28
sw_scripts/safari-notifications.js

@ -12,11 +12,39 @@ function decodeBase64(s) {
return b; return b;
}; };
async function getSettingById(id) {
return new Promise((resolve, reject) => {
let openRequest = indexedDB.open('TimeSafari');
openRequest.onupgradeneeded = (event) => {
// Handle database setup if necessary
let db = event.target.result;
if (!db.objectStoreNames.contains('settings')) {
db.createObjectStore('settings', { keyPath: 'id' });
}
};
openRequest.onsuccess = (event) => {
let db = event.target.result;
let transaction = db.transaction('settings', 'readonly');
let objectStore = transaction.objectStore('settings');
let getRequest = objectStore.get(id);
getRequest.onsuccess = () => resolve(getRequest.result);
getRequest.onerror = () => reject(getRequest.error);
};
openRequest.onerror = () => reject(openRequest.error);
});
}
async function getNotificationCount() { async function getNotificationCount() {
let secret = null; let secret = null;
if ('secret' in self) { if ('secret' in self) {
secret = self.secret; secret = self.secret;
const secretUint8Array = decodeBase64(secret); const secretUint8Array = decodeBase64(secret);
const settings = await getSettingById(1);
const activeDid = settings['activeDid'];
} }
return secret; return secret;
} }

Loading…
Cancel
Save