mirror of
https://github.com/Blah-IM/blahrs.git
synced 2025-05-01 08:41:09 +00:00
Impl default config for testing frontend
This commit is contained in:
parent
5d15900436
commit
42a778bef2
2 changed files with 12 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,5 +3,6 @@
|
||||||
*.key
|
*.key
|
||||||
|
|
||||||
config.toml
|
config.toml
|
||||||
|
/pages/default.json
|
||||||
result
|
result
|
||||||
result-*
|
result-*
|
||||||
|
|
|
@ -9,6 +9,7 @@ let roomUrl = '';
|
||||||
let roomUuid = null;
|
let roomUuid = null;
|
||||||
let feed = null;
|
let feed = null;
|
||||||
let keypair = null;
|
let keypair = null;
|
||||||
|
let defaultConfig = {};
|
||||||
|
|
||||||
function bufToHex(buf) {
|
function bufToHex(buf) {
|
||||||
return [...new Uint8Array(buf)]
|
return [...new Uint8Array(buf)]
|
||||||
|
@ -307,12 +308,22 @@ async function postChat(text) {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = async (_) => {
|
window.onload = async (_) => {
|
||||||
|
try {
|
||||||
|
const resp = await fetch('./default.json');
|
||||||
|
if (resp.ok) {
|
||||||
|
defaultConfig = await resp.json();
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
if (!await loadKeypair()) {
|
if (!await loadKeypair()) {
|
||||||
await generateKeypair();
|
await generateKeypair();
|
||||||
}
|
}
|
||||||
if (keypair !== null) {
|
if (keypair !== null) {
|
||||||
userPubkeyDisplay.value = await getUserPubkey();
|
userPubkeyDisplay.value = await getUserPubkey();
|
||||||
}
|
}
|
||||||
|
if (roomUrlInput.value === '' && defaultConfig.room_url) {
|
||||||
|
roomUrlInput.value = defaultConfig.room_url;
|
||||||
|
}
|
||||||
await connectRoom(roomUrlInput.value);
|
await connectRoom(roomUrlInput.value);
|
||||||
};
|
};
|
||||||
roomUrlInput.onchange = async (e) => {
|
roomUrlInput.onchange = async (e) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue