It acutally works just fine now yay
This commit is contained in:
parent
f3b4755821
commit
0077989253
11
app.js
11
app.js
@ -100,7 +100,7 @@ async function initialize() {
|
|||||||
config = JSON.parse(fs.readFileSync("./config.json", 'utf8'));
|
config = JSON.parse(fs.readFileSync("./config.json", 'utf8'));
|
||||||
console.log("Read config from file:", config)
|
console.log("Read config from file:", config)
|
||||||
config.rooms.forEach(room => {
|
config.rooms.forEach(room => {
|
||||||
addRoomToList(room);
|
addRoomToListWithoutWritingToConfig(room);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,6 +252,15 @@ function addRoomToList(topic) {
|
|||||||
writeConfigToFile("./config.json");
|
writeConfigToFile("./config.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addRoomToListWithoutWritingToConfig(topic) {
|
||||||
|
const roomList = document.querySelector('#room-list');
|
||||||
|
const roomItem = document.createElement('li');
|
||||||
|
roomItem.textContent = truncateHash(topic);
|
||||||
|
roomItem.dataset.topic = topic;
|
||||||
|
roomItem.addEventListener('click', () => switchRoom(topic));
|
||||||
|
roomList.appendChild(roomItem);
|
||||||
|
}
|
||||||
|
|
||||||
function switchRoom(topic) {
|
function switchRoom(topic) {
|
||||||
const topicBuffer = b4a.from(topic, 'hex');
|
const topicBuffer = b4a.from(topic, 'hex');
|
||||||
joinSwarm(topicBuffer);
|
joinSwarm(topicBuffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user