diff --git a/README.md b/README.md index b1196abf..37cb7db0 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ apt install linux-Miru-*.deb ## **Building and Development** -*dont* +*good luck* Dependencies: - Node 16 or above diff --git a/common/App.svelte b/common/App.svelte index c165b999..8c44adcc 100644 --- a/common/App.svelte +++ b/common/App.svelte @@ -14,6 +14,35 @@ IPC.on('schedule', () => { page.set('schedule') }) + + let ignoreNext = false + function addPage (value, type) { + if (ignoreNext) { + ignoreNext = false + return + } + history.pushState({ type, value }, '', './?id=' + Math.trunc(Math.random() * Number.MAX_SAFE_INTEGER).toString()) + } + page.subscribe((value) => { + addPage(value, 'page') + }) + view.subscribe((value) => { + addPage(value, 'view') + }) + + addPage('home', 'page') + + window.addEventListener('popstate', e => { + const { state } = e + if (!state) return + ignoreNext = true + view.set(null) + if (state.type === 'page') { + page.set(state.value) + } else { + view.set(state.value) + } + })