1
0
watterblock/ui/session.js
Adrian Wannenmacher de0fc8c917
enable history navigation
The previous implementation only looked at the URL (and state) during
initialization. This allowed users to open a specific session via URL
(e.g. when reloading the page).

History navigation, however, was completely ignored. I.e. if the user
pressed the back button the URL would change, but the content would
remain the same.

This has now been corrected.
2026-03-01 02:28:47 +01:00

48 lines
1.3 KiB
JavaScript

"use strict";
import Session from "/models/session.js";
import GameView from "/ui/game.js";
import RoundView from "/ui/round.js";
export default class SessionView {
/** @param {{ attrs: { model: Session } }} param The session model to use. */
view({ attrs: { model } }) {
let res = model.result;
return m("article.session-view", [
m(m.route.Link, { href: "/", selector: "button" }, "Zruck"),
m("table", [
m("thead", [
m("tr", [
m("th", ["se", " ", "•".repeat(res.theirPoints)]),
m("th", ["mia", " ", "•".repeat(res.ourPoints)]),
]),
]),
model.games.map((g) => m(GameView, { model: g })),
model.currentGame !== null
? m(GameView, { model: model.currentGame })
: null,
]),
m(".spacer"),
model.currentGame !== null
? model.currentGame.currentRound !== null
? m(RoundView, { model: model.currentGame.currentRound })
: null
: m(".continue", [
m("button",
{
onclick: () => {
model.anotherGame();
window.scrollTo({
top: document.body.scrollHeight,
behavior: "smooth",
});
},
},
"no a spiel"),
]),
]);
}
}