basic url router and navigation bootstrapping
This commit is contained in:
parent
b373a177ec
commit
404de53c75
1 changed files with 20 additions and 0 deletions
20
src/main.js
20
src/main.js
|
@ -22,8 +22,11 @@ import {SessionContainer} from "./matrix/SessionContainer.js";
|
||||||
import {StorageFactory} from "./matrix/storage/idb/StorageFactory.js";
|
import {StorageFactory} from "./matrix/storage/idb/StorageFactory.js";
|
||||||
import {SessionInfoStorage} from "./matrix/sessioninfo/localstorage/SessionInfoStorage.js";
|
import {SessionInfoStorage} from "./matrix/sessioninfo/localstorage/SessionInfoStorage.js";
|
||||||
import {BrawlViewModel} from "./domain/BrawlViewModel.js";
|
import {BrawlViewModel} from "./domain/BrawlViewModel.js";
|
||||||
|
import {Navigation} from "./domain/navigation/Navigation.js";
|
||||||
|
import {URLRouter} from "./domain/navigation/URLRouter.js";
|
||||||
import {BrawlView} from "./ui/web/BrawlView.js";
|
import {BrawlView} from "./ui/web/BrawlView.js";
|
||||||
import {Clock} from "./ui/web/dom/Clock.js";
|
import {Clock} from "./ui/web/dom/Clock.js";
|
||||||
|
import {HashObservable} from "./ui/web/dom/HashObservable.js";
|
||||||
import {OnlineStatus} from "./ui/web/dom/OnlineStatus.js";
|
import {OnlineStatus} from "./ui/web/dom/OnlineStatus.js";
|
||||||
import {CryptoDriver} from "./ui/web/dom/CryptoDriver.js";
|
import {CryptoDriver} from "./ui/web/dom/CryptoDriver.js";
|
||||||
import {WorkerPool} from "./utils/WorkerPool.js";
|
import {WorkerPool} from "./utils/WorkerPool.js";
|
||||||
|
@ -115,6 +118,21 @@ export async function main(container, paths, legacyExtras) {
|
||||||
workerPromise = loadOlmWorker(paths);
|
workerPromise = loadOlmWorker(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const navigation = new Navigation(function allowsChild(parent, child) {
|
||||||
|
const {type} = child;
|
||||||
|
switch (parent?.type) {
|
||||||
|
case undefined:
|
||||||
|
// allowed root segments
|
||||||
|
return type === "login" || type === "session";
|
||||||
|
case "session":
|
||||||
|
return type === "room" || type === "settings";
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const urlRouter = new URLRouter(new HashObservable(), navigation);
|
||||||
|
urlRouter.start();
|
||||||
|
|
||||||
const vm = new BrawlViewModel({
|
const vm = new BrawlViewModel({
|
||||||
createSessionContainer: () => {
|
createSessionContainer: () => {
|
||||||
return new SessionContainer({
|
return new SessionContainer({
|
||||||
|
@ -132,6 +150,8 @@ export async function main(container, paths, legacyExtras) {
|
||||||
sessionInfoStorage,
|
sessionInfoStorage,
|
||||||
storageFactory,
|
storageFactory,
|
||||||
clock,
|
clock,
|
||||||
|
urlRouter,
|
||||||
|
navigation
|
||||||
});
|
});
|
||||||
window.__brawlViewModel = vm;
|
window.__brawlViewModel = vm;
|
||||||
await vm.load();
|
await vm.load();
|
||||||
|
|
Reference in a new issue