=stop the timer

This commit is contained in:
Miki 2023-12-05 16:37:01 +01:00
parent 2d95efcaf8
commit 555e7b85ea
9 changed files with 23 additions and 17 deletions

Binary file not shown.

View file

@ -179,20 +179,25 @@ func (stream *PriorityStream) timer() {
Mode: Stop.String(),
}
stream.Message <- msg
log.Printf("stop timer %+v", stream.Duration)
continue
default:
if len(stream.TotalClients) > 0 {
currentTimer := fmt.Sprintf("%v", formatTime(stream.Duration))
if stream.Duration >= 0 {
currentTimer := fmt.Sprintf("%v", formatTime(stream.Duration))
msg := Message{
Duration: currentTimer,
Mode: Time.String(),
msg := Message{
Duration: currentTimer,
Mode: Time.String(),
}
// Send current time to clients message channel
stream.Message <- msg
time.Sleep(time.Second * 1)
stream.Duration = stream.Duration - time.Second
} else {
timer.Stop()
}
// Send current time to clients message channel
stream.Message <- msg
time.Sleep(time.Second * 1)
stream.Duration = stream.Duration - time.Second
}
}
}

View file

@ -1 +1 @@
{"version":"1701788771196"}
{"version":"1701790559207"}

Binary file not shown.

Binary file not shown.

View file

@ -5,17 +5,17 @@
<link rel="icon" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="modulepreload" href="/_app/immutable/entry/start.44f26591.js">
<link rel="modulepreload" href="/_app/immutable/entry/start.f64c2857.js">
<link rel="modulepreload" href="/_app/immutable/chunks/scheduler.9172086d.js">
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.58002853.js">
<link rel="modulepreload" href="/_app/immutable/entry/app.5fcbfdd4.js">
<link rel="modulepreload" href="/_app/immutable/chunks/singletons.2ba34c86.js">
<link rel="modulepreload" href="/_app/immutable/entry/app.f55ac43b.js">
<link rel="modulepreload" href="/_app/immutable/chunks/index.c679962e.js">
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">
<script>
{
__sveltekit_wxhjzu = {
__sveltekit_uz78hc = {
base: "",
env: {}
};
@ -23,8 +23,8 @@
const element = document.currentScript.parentElement;
Promise.all([
import("/_app/immutable/entry/start.44f26591.js"),
import("/_app/immutable/entry/app.5fcbfdd4.js")
import("/_app/immutable/entry/start.f64c2857.js"),
import("/_app/immutable/entry/app.f55ac43b.js")
]).then(([kit, app]) => {
kit.start(app, element);
});

Binary file not shown.

Binary file not shown.

View file

@ -96,7 +96,7 @@
const res = await fetch(`/api/start`, {
method: 'POST',
body: JSON.stringify({
duration: "0m25s",
duration: "0m10s",
mode: 'time'
}),
headers: {
@ -105,6 +105,7 @@
});
console.log(`retval: ${JSON.stringify(res)}`);
start = true;
end = false;
}
async function click(id) {