add space status change notification
This commit is contained in:
parent
e21dac9934
commit
213f4138ff
|
@ -35,6 +35,15 @@ const updateBadge = (open) => {
|
|||
});
|
||||
};
|
||||
|
||||
const sendNotification = (open) => {
|
||||
browser.notifications.create('notification-id', {
|
||||
type: 'basic',
|
||||
iconUrl: browser.runtime.getURL('icons/logo.svg'),
|
||||
title: 'Space Status',
|
||||
message: 'Space ist jetzt ' + (open ? 'offen' : 'geschlossen') + '.'
|
||||
});
|
||||
};
|
||||
|
||||
const fetchNewData = () => {
|
||||
fetchCalendar().then((json) => {
|
||||
window.calendar = json;
|
||||
|
@ -43,6 +52,9 @@ const fetchNewData = () => {
|
|||
});
|
||||
|
||||
fetchSpaceApi().then((json) => {
|
||||
if (window.spaceApi.state.open !== json.state.open) {
|
||||
sendNotification(json.state.open)
|
||||
}
|
||||
window.spaceApi = json;
|
||||
updateBadge(window.spaceApi.state.open);
|
||||
}).catch((error) => {
|
||||
|
|
|
@ -24,7 +24,8 @@
|
|||
},
|
||||
"permissions": [
|
||||
"https://usrspace.at/*",
|
||||
"webRequest"
|
||||
"webRequest",
|
||||
"notifications"
|
||||
],
|
||||
"author": "Thomas Rupprecht"
|
||||
//"developer": {
|
||||
|
|
Loading…
Reference in New Issue