forked from XimeX/usrspace-browser-addon
use storage api
This commit is contained in:
parent
fc2ad7afad
commit
6b69d7cd6a
|
@ -45,7 +45,7 @@ async function fetchNewData() {
|
|||
await browser.browserAction.setBadgeText({text: badgeText});
|
||||
await browser.browserAction.setBadgeBackgroundColor({color: badgeBgColor});
|
||||
|
||||
const spaceApi = JSON.parse(localStorage.getItem('spaceApi'));
|
||||
const {spaceApi} = await browser.storage.local.get('spaceApi');
|
||||
if (spaceApi && spaceApi.state.open !== spaceApiJson.state.open) {
|
||||
const state = browser.i18n.getMessage(spaceApiJson.state.open ? 'open' : 'closed');
|
||||
await browser.notifications.create('status-change', {
|
||||
|
@ -57,8 +57,10 @@ async function fetchNewData() {
|
|||
}
|
||||
}
|
||||
|
||||
localStorage.setItem('calendar', JSON.stringify(calendarJson));
|
||||
localStorage.setItem('spaceApi', JSON.stringify(spaceApiJson));
|
||||
await browser.storage.local.set({
|
||||
calendar: calendarJson,
|
||||
spaceApi: spaceApiJson,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
|
|
@ -20,8 +20,9 @@
|
|||
"default_locale": "de",
|
||||
"permissions": [
|
||||
"https://www.usrspace.at/*",
|
||||
"webRequest",
|
||||
"notifications"
|
||||
"notifications",
|
||||
"storage",
|
||||
"webRequest"
|
||||
],
|
||||
"author": "Thomas Rupprecht",
|
||||
"homepage_url": "https://gitea.usrspace.at/XimeX/usrspace-browser-addon",
|
||||
|
|
|
@ -49,8 +49,7 @@ async function init() {
|
|||
linkElement.addEventListener('click', linkElementClickListener);
|
||||
});
|
||||
|
||||
const calendar = JSON.parse(localStorage.getItem('calendar'));
|
||||
const spaceApi = JSON.parse(localStorage.getItem('spaceApi'));
|
||||
const {calendar, spaceApi} = await browser.storage.local.get(['calendar', 'spaceApi']);
|
||||
|
||||
if (calendar) {
|
||||
updateNextEvent(calendar);
|
||||
|
|
Loading…
Reference in New Issue