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