feat(demo): add story 1 — Sorano: Rock and Time

This commit is contained in:
2026-06-20 21:19:57 +02:00
parent 42ed59a6b3
commit 8f87155c1d
5508 changed files with 1595740 additions and 124 deletions
@@ -0,0 +1,51 @@
import { config } from 'grav-config';
import { userFeedbackError } from './response';
import { showSessionExpiredModal } from './session-expired';
const MAX_SAFE_DELAY = 2147483647;
class KeepAlive {
constructor() {
this.active = false;
}
start() {
let timeout = config.admin_timeout / 1.5 * 1000;
this.timer = setInterval(() => this.fetch(), Math.min(timeout, MAX_SAFE_DELAY));
this.active = true;
}
stop() {
clearInterval(this.timer);
this.active = false;
}
checkOnce() {
let data = new FormData();
data.append('admin-nonce', config.admin_nonce);
return fetch(`${config.base_url_relative}/task${config.param_sep}keepAlive`, {
credentials: 'same-origin',
headers: {
'Accept': 'application/json'
},
method: 'post',
body: data
})
.then((response) => {
if (response && (response.status === 401 || response.status === 403)) {
return false;
}
return true;
})
.catch(() => false);
}
fetch() {
return this.checkOnce().then((ok) => {
if (!ok) { showSessionExpiredModal(); }
}).catch(userFeedbackError);
}
}
export default new KeepAlive();