Working on Config system (Saving & Loading user data) #3

Merged
snxraven merged 16 commits from MiTask/LinkUp-P2P-Chat:main into main 2024-06-09 03:11:48 -04:00
Showing only changes of commit f3b4755821 - Show all commits

10
app.js
View File

@ -97,7 +97,7 @@ async function initialize() {
const configExists = fs.existsSync("./config.json"); const configExists = fs.existsSync("./config.json");
if (configExists) { if (configExists) {
await readConfigFromFile("./config.json"); 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); addRoomToList(room);
@ -429,12 +429,4 @@ function writeConfigToFile(filePath) {
}); });
} }
async function readConfigFromFile(filePath) {
await fs.readFile(filePath, 'utf8', (err, data) => {
if(err) return console.log("Error while reading config.json! ", err)
data = JSON.parse(data);
config = data;
});
}
initialize(); initialize();