Security: - Token revocation. User gains a TokenVersion counter embedded in both tokens as a "tv" claim; AuthenticateToken rejects a token whose version no longer matches the row. Logout bumps it, so logging out now kills outstanding tokens rather than only clearing cookies. Costs one primary-key SELECT per authenticated request, which is the price of having revocation at all. - Spotify OAuth CSRF. The fixed SPOTIFY_AUTH_STATE constant is replaced by a per-request one-shot nonce, verified and consumed on callback. - Private chat attachments. Attachments on private messages are written to /backend/uploads/private/ and served at /uploads/private/, gated by the same nginx auth_request admin check used for /hasura/ and /notes/. Private uploads are rejected from non-admin callers. - The icecast admin UI (/radio/admin/) is behind the admin gate; listener traffic is untouched. - Store caches are mutex-guarded, so -race is clean. Bugs: - The email pipeline no longer drops emails permanently on transient failure. Failures record an attempt counter and are retried up to 3 times; the fetch window rewinds to the oldest retryable email's ReceivedAt, without which a retry could never re-fetch it. - Rowing duplicate detection distinguishes ErrRecordNotFound from a real DB error, so a transient failure no longer causes a duplicate insert plus a paid Claude call. - DeletePost propagates its delete error instead of reporting success. - RecentlyPlayed populates the cache it reads. - main.go exits non-zero if r.Run fails, so a port conflict is visible. - Python: the scan truncation flag is set on every deadline path; timed_out is reported by the worker rather than inferred from the clock; date validation uses Europe/London rather than server-local time. - Vue: Time.vue and Radio.vue intervals are cleared on unmount; Feed.vue guards a missing author; Timer.vue gets an explicit state machine and compares total elapsed seconds; Elle.vue's comma-operator call and per-frame console.log are fixed. Simplification: - One TTLCache replaces three near-identical cache implementations, with the differing eviction rules as explicit parameters. - run_scan's transport index no longer uses one object as both ordering record and live output; its three phases are separate functions. - _price_hotels submits all work to a single pool, so the nested-executor deadlock hazard is gone by construction. - The NDJSON event generators share one implementation. - IMAP FETCH responses pair each line with its literal in the type, so callers no longer hand-skip alternate entries. - Shared helpers for slice-of-pointers, markdown fences and auth cookies. - Vue: useHotelSearch, createMirrorStore, useRotation, useCreateForm, useLinkAttrs, ListWidget and LinkTableItems replace duplicated blocks. - nginx dev config's duplicated :80/:443 bodies share one partial. Infra: certbot passes --deploy-hook touching a sentinel that nginx's watcher reloads on, so renewed certs are served without a restart, and the watcher also removes the manual restart after first issuance. db is gated on service_healthy, autoheal is pinned, and the unused envsubst entries are dropped. Verified: go build/vet, npx vite build, py_compile, docker compose config for both overlays, bash -n on all scripts, and an envsubst render of every nginx template (no leftover placeholders, runtime vars preserved, braces balanced). Co-Authored-By: Claude Opus 5 <[email protected]>
139 lines
3.3 KiB
Vue
139 lines
3.3 KiB
Vue
<script setup>
|
|
/**
|
|
* Countdown widget with minute/second sliders and a sound on completion.
|
|
*
|
|
* `state` is an explicit state machine — "idle" (sliders), "running",
|
|
* "paused" and "finished" — one screen per state. Completion is decided by
|
|
* comparing total elapsed seconds with the total target, so it does not depend
|
|
* on the minute and second fields crossing their targets independently.
|
|
*/
|
|
import Button from "@/components/input/Button.vue";
|
|
import Header from "@/components/text/Header.vue";
|
|
|
|
import { ref, onUnmounted } from "vue";
|
|
|
|
const timer = ref(null);
|
|
|
|
/** "idle" | "running" | "paused" | "finished" */
|
|
const state = ref("idle");
|
|
|
|
const minutesInput = ref(0);
|
|
const secondsInput = ref(0);
|
|
|
|
const minutes = ref(0);
|
|
const seconds = ref(0);
|
|
|
|
const audio = new Audio("/sound/auughhh.mp3");
|
|
|
|
function tick() {
|
|
seconds.value++;
|
|
if (seconds.value === 60) {
|
|
minutes.value++;
|
|
seconds.value = 0;
|
|
}
|
|
|
|
const elapsed = minutes.value * 60 + seconds.value;
|
|
const target = Number(minutesInput.value) * 60 + Number(secondsInput.value);
|
|
|
|
if (elapsed >= target) {
|
|
state.value = "finished";
|
|
playFinishedSound();
|
|
clearInterval(timer.value);
|
|
}
|
|
}
|
|
|
|
function startTimer() {
|
|
state.value = "running";
|
|
timer.value = setInterval(tick, 1000);
|
|
}
|
|
|
|
function pauseTimer() {
|
|
if (state.value === "finished") return;
|
|
|
|
if (state.value === "paused") {
|
|
timer.value = setInterval(tick, 1000);
|
|
state.value = "running";
|
|
} else {
|
|
clearInterval(timer.value);
|
|
state.value = "paused";
|
|
}
|
|
}
|
|
|
|
/** Back to the slider screen, ready to set a new countdown. */
|
|
function resetTimer() {
|
|
state.value = "idle";
|
|
clearInterval(timer.value);
|
|
minutes.value = 0;
|
|
seconds.value = 0;
|
|
}
|
|
|
|
onUnmounted(() => {
|
|
clearInterval(timer.value);
|
|
});
|
|
|
|
function playFinishedSound() {
|
|
audio.play();
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="timer-root flex flex-col gap-1 p-1 items-center">
|
|
<Header>Timer</Header>
|
|
<div v-if="state === 'idle'" class="flex flex-col">
|
|
<div class="flex flex-row p-2 place-content-around">
|
|
<input
|
|
class="w-2/3"
|
|
v-model="minutesInput"
|
|
type="range"
|
|
min="0"
|
|
max="59"
|
|
aria-label="Minutes"
|
|
/>
|
|
<p>{{ minutesInput }}m</p>
|
|
</div>
|
|
<div class="flex flex-row p-2 place-content-around">
|
|
<input
|
|
class="w-2/3"
|
|
v-model="secondsInput"
|
|
type="range"
|
|
min="0"
|
|
max="59"
|
|
aria-label="Seconds"
|
|
/>
|
|
<p>{{ secondsInput }}s</p>
|
|
</div>
|
|
<Button @click="startTimer">Proceed</Button>
|
|
</div>
|
|
<div v-if="state === 'finished'" class="flex flex-col">
|
|
<h1>Timer finished!</h1>
|
|
<Button @click="resetTimer">Reset</Button>
|
|
</div>
|
|
<div v-if="state === 'paused'" class="flex flex-col">
|
|
<h1>Paused</h1>
|
|
<Button @click="resetTimer">Reset</Button>
|
|
</div>
|
|
<div v-if="state === 'running'" class="flex flex-col">
|
|
<p>
|
|
{{ minutes.toString().padStart(2, "0") }}:{{
|
|
seconds.toString().padStart(2, "0")
|
|
}}
|
|
</p>
|
|
<p>
|
|
{{ minutesInput.toString().padStart(2, "0") }}:{{
|
|
secondsInput.toString().padStart(2, "0")
|
|
}}
|
|
</p>
|
|
<Button @click="pauseTimer">Pause</Button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
@media (max-width: 850px) {
|
|
.timer-root {
|
|
padding: 2px;
|
|
gap: 2px;
|
|
}
|
|
}
|
|
</style>
|