Impl default config for testing frontend

This commit is contained in:
oxalica 2024-08-31 20:04:37 -04:00
parent 5d15900436
commit 42a778bef2
2 changed files with 12 additions and 0 deletions

1
.gitignore vendored
View file

@ -3,5 +3,6 @@
*.key
config.toml
/pages/default.json
result
result-*

View file

@ -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) => {