WIP: fixing askPermission chain

This commit is contained in:
Matthew Raymer
2023-11-12 04:26:05 -05:00
parent 9b3d2b4c52
commit 7906aab36e
3 changed files with 107 additions and 39 deletions

View File

@@ -27,5 +27,6 @@ self.addEventListener('message', event => {
if (event.data && event.data.type === 'SEND_LOCAL_DATA') {
self.secret = event.data.data;
console.log('Data stored in service worker:', self.secret);
event.ports[0].postMessage({ success: true });
}
});

View File

@@ -7,12 +7,14 @@ function validateBase64(s) {
}
}
function decodeBase64(s) {
validateBase64(s);
var i, d = atob(s), b = new Uint8Array(d.length);
for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i);
return b;
};
}
async function getSettingById(id) {
return new Promise((resolve, reject) => {
@@ -40,6 +42,7 @@ async function getSettingById(id) {
});
}
function getAllAccounts() {
return new Promise((resolve, reject) => {
let openRequest = indexedDB.open('TimeSafariAccounts');
@@ -82,12 +85,13 @@ async function getNotificationCount() {
let secret = null;
if ('secret' in self) {
secret = self.secret;
const secretUint8Array = decodeBase64(secret);
const secretUint8Array = self.decodeBase64(secret);
/**
const settings = await getSettingById(1);
const activeDid = settings['activeDid'];
const accounts = await fetchAllAccounts();
/**
let result = null;
for (var i = 0; i < accounts.length; i++) {
let account = accounts[i];
@@ -107,3 +111,4 @@ async function getNotificationCount() {
}
self.getNotificationCount = getNotificationCount;
self.decodeBase64 = decodeBase64