forked from jsnbuchanan/crowd-funder-for-time-pwa
WIP: fixing askPermission chain
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user