1
0

make basic ui remember one session

This commit is contained in:
Adrian Wannenmacher 2026-02-17 00:38:53 +01:00
parent ad9f9035a1
commit ff04d19185
Signed by: tfld
GPG Key ID: 19D986ECB1E492D5

View File

@ -2,11 +2,36 @@
import Session from "../models/session.js";
import SessionView from "./session.js";
import WbDb from "../data/db.js";
import SessionRepo from "../data/session_repo.js";
export default class App {
#session = new Session();
#session = null;
constructor() {
let db = WbDb.get();
if (db.open)
this.#dbReady();
else
db.addEventListener(WbDb.EVENT_CHANGE, this.#dbReady.bind(this));
}
async #dbReady() {
let sessions = await SessionRepo.getAll();
if (sessions.length === 0) {
this.#session = new Session();
SessionRepo.put(this.#session);
} else
this.#session = sessions[0];
m.redraw();
}
view() {
if (this.#session === null) {
return m("p", "Warte auf Datenbank.");
}
return m(SessionView, { model: this.#session });
}
}