Compare commits
No commits in common. "f8be28744cf3eb3f38c6e7a849c488b62bb4574a" and "41a8d1e3e2c90837765b7ecbf0e2ade9e5082a26" have entirely different histories.
f8be28744c
...
41a8d1e3e2
4
app.go
4
app.go
@ -84,10 +84,6 @@ func (app *App) ResetTimer() {
|
|||||||
app.nextAlarm = time.AfterFunc(time.Until(*na), func() {
|
app.nextAlarm = time.AfterFunc(time.Until(*na), func() {
|
||||||
app.nextAlarm = nil
|
app.nextAlarm = nil
|
||||||
reveil.RemoveOldAlarmsSingle(app.db)
|
reveil.RemoveOldAlarmsSingle(app.db)
|
||||||
|
|
||||||
// Rearm timer for the next time
|
|
||||||
app.ResetTimer()
|
|
||||||
|
|
||||||
err := player.WakeUp(app.cfg, routines)
|
err := player.WakeUp(app.cfg, routines)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err.Error())
|
log.Println(err.Error())
|
||||||
|
@ -12,8 +12,9 @@
|
|||||||
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
|
"format": "prettier --ignore-path .gitignore --write --plugin-search-dir=. ."
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-static": "^1.0.0",
|
"@sveltejs/adapter-auto": "^1.0.0-next.18",
|
||||||
"@sveltejs/kit": "^1.0.0",
|
"@sveltejs/adapter-static": "^1.0.0-next.26",
|
||||||
|
"@sveltejs/kit": "^1.0.0-next.260",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||||
"@typescript-eslint/parser": "^5.0.0",
|
"@typescript-eslint/parser": "^5.0.0",
|
||||||
"bootstrap": "^5.1.3",
|
"bootstrap": "^5.1.3",
|
||||||
|
@ -9,15 +9,11 @@ export class AlarmRepeated {
|
|||||||
this.id = id;
|
this.id = id;
|
||||||
this.weekday = weekday;
|
this.weekday = weekday;
|
||||||
this.time = time;
|
this.time = time;
|
||||||
this.routines = routines == null ? [] : routines;
|
this.routines = routines;
|
||||||
this.ignore_exceptions = ignore_exceptions;
|
this.ignore_exceptions = ignore_exceptions;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
this.excepts = excepts;
|
this.excepts = excepts;
|
||||||
this.next_time = next_time;
|
this.next_time = next_time;
|
||||||
|
|
||||||
if (this.routines.length < 1) {
|
|
||||||
this.routines.push("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete() {
|
async delete() {
|
||||||
|
@ -8,12 +8,8 @@ export class AlarmSingle {
|
|||||||
update({ id, time, routines, comment }) {
|
update({ id, time, routines, comment }) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.time = new Date(time);
|
this.time = new Date(time);
|
||||||
this.routines = routines == null ? [] : routines;
|
this.routines = routines;
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
|
|
||||||
if (this.routines.length < 1) {
|
|
||||||
this.routines.push("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete() {
|
async delete() {
|
||||||
|
80
ui/src/service-worker.ts
Normal file
80
ui/src/service-worker.ts
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/// <reference lib="webworker" />
|
||||||
|
|
||||||
|
import { build, files, timestamp } from '$service-worker';
|
||||||
|
|
||||||
|
const worker = (self as unknown) as ServiceWorkerGlobalScope;
|
||||||
|
const FILES = `cache${timestamp}`;
|
||||||
|
|
||||||
|
// `build` is an array of all the files generated by the bundler,
|
||||||
|
// `files` is an array of everything in the `static` directory
|
||||||
|
const to_cache = build.concat(files);
|
||||||
|
const staticAssets = new Set(to_cache);
|
||||||
|
|
||||||
|
worker.addEventListener('install', (event) => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches
|
||||||
|
.open(FILES)
|
||||||
|
.then((cache) => cache.addAll(to_cache))
|
||||||
|
.then(() => {
|
||||||
|
worker.skipWaiting();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
worker.addEventListener('activate', (event) => {
|
||||||
|
event.waitUntil(
|
||||||
|
caches.keys().then(async (keys) => {
|
||||||
|
// delete old caches
|
||||||
|
for (const key of keys) {
|
||||||
|
if (key !== FILES) await caches.delete(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
worker.clients.claim();
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the asset from the network and store it in the cache.
|
||||||
|
* Fall back to the cache if the user is offline.
|
||||||
|
*/
|
||||||
|
async function fetchAndCache(request: Request) {
|
||||||
|
const cache = await caches.open(`offline${timestamp}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(request);
|
||||||
|
cache.put(request, response.clone());
|
||||||
|
return response;
|
||||||
|
} catch (err) {
|
||||||
|
const response = await cache.match(request);
|
||||||
|
if (response) return response;
|
||||||
|
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
worker.addEventListener('fetch', (event) => {
|
||||||
|
if (event.request.method !== 'GET' || event.request.headers.has('range')) return;
|
||||||
|
|
||||||
|
const url = new URL(event.request.url);
|
||||||
|
|
||||||
|
// don't try to handle e.g. data: URIs
|
||||||
|
const isHttp = url.protocol.startsWith('http');
|
||||||
|
const isDevServerRequest =
|
||||||
|
url.hostname === self.location.hostname && url.port !== self.location.port;
|
||||||
|
const isStaticAsset = url.host === self.location.host && staticAssets.has(url.pathname);
|
||||||
|
const skipBecauseUncached = event.request.cache === 'only-if-cached' && !isStaticAsset;
|
||||||
|
|
||||||
|
if (isHttp && !isDevServerRequest && !skipBecauseUncached) {
|
||||||
|
event.respondWith(
|
||||||
|
(async () => {
|
||||||
|
// always serve static files and bundler-generated assets from cache.
|
||||||
|
// if your application has other URLs with data that will never change,
|
||||||
|
// set this variable to true for them and they will only be fetched once.
|
||||||
|
const cachedAsset = isStaticAsset && (await caches.match(event.request));
|
||||||
|
|
||||||
|
return cachedAsset || fetchAndCache(event.request);
|
||||||
|
})()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -11,6 +11,9 @@ const config = {
|
|||||||
adapter: adapter({
|
adapter: adapter({
|
||||||
fallback: '404.html'
|
fallback: '404.html'
|
||||||
}),
|
}),
|
||||||
|
paths: {
|
||||||
|
// base: '{{.urlbase}}',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user