From 42a778bef29a5c43cff87a490ca30a0574734d5b Mon Sep 17 00:00:00 2001 From: oxalica Date: Sat, 31 Aug 2024 20:04:37 -0400 Subject: [PATCH] Impl default config for testing frontend --- .gitignore | 1 + pages/main.js | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 9942df7..79708db 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ *.key config.toml +/pages/default.json result result-* diff --git a/pages/main.js b/pages/main.js index fa8f53e..6e614e0 100644 --- a/pages/main.js +++ b/pages/main.js @@ -9,6 +9,7 @@ let roomUrl = ''; let roomUuid = null; let feed = null; let keypair = null; +let defaultConfig = {}; function bufToHex(buf) { return [...new Uint8Array(buf)] @@ -307,12 +308,22 @@ async function postChat(text) { } window.onload = async (_) => { + try { + const resp = await fetch('./default.json'); + if (resp.ok) { + defaultConfig = await resp.json(); + } + } catch (e) {} + if (!await loadKeypair()) { await generateKeypair(); } if (keypair !== null) { userPubkeyDisplay.value = await getUserPubkey(); } + if (roomUrlInput.value === '' && defaultConfig.room_url) { + roomUrlInput.value = defaultConfig.room_url; + } await connectRoom(roomUrlInput.value); }; roomUrlInput.onchange = async (e) => {