Compare commits

...

4 Commits

Author SHA1 Message Date
MrMasrozYTLIVE
33e0a13f93 Merge branch 'main' of https://git.ssh.surf/snxraven/LinkUp-P2P-Chat 2024-06-09 11:10:02 +03:00
MrMasrozYTLIVE
840b6e2069 Fixed removing rooms 2024-06-09 11:09:58 +03:00
Raven Scott
babde932e7 adding readableTimestamp to messages 2024-06-09 04:09:07 -04:00
Raven Scott
8458430989 adding peers to messages 2024-06-09 04:07:24 -04:00

10
app.js
View File

@ -278,14 +278,15 @@ function leaveRoom() {
if (roomItem) { if (roomItem) {
roomItem.remove(); roomItem.remove();
} }
config.rooms = config.rooms.filter(e => e !== currentRoom.topic);
writeConfigToFile("./config.json");
currentRoom.destroy(); currentRoom.destroy();
currentRoom = null; currentRoom = null;
} }
document.querySelector('#chat').classList.add('hidden'); document.querySelector('#chat').classList.add('hidden');
document.querySelector('#setup').classList.remove('hidden'); document.querySelector('#setup').classList.remove('hidden');
config.rooms = config.rooms.filter(e => e !== currentRoom.topic);
writeConfigToFile("./config.json");
} }
function sendMessage(e) { function sendMessage(e) {
@ -301,7 +302,9 @@ function sendMessage(e) {
message, message,
avatar: config.userAvatar, avatar: config.userAvatar,
topic: b4a.toString(currentRoom.topic, 'hex'), topic: b4a.toString(currentRoom.topic, 'hex'),
peers: [...swarm.connections].map(peer => peer.remotePublicKey.toString('hex')),
timestamp: Date.now(), timestamp: Date.now(),
readableTimestamp: new Date().toLocaleString(), // Added human-readable timestamp
}); });
const peers = [...swarm.connections]; const peers = [...swarm.connections];
@ -438,7 +441,6 @@ function toggleSetupView() {
} }
function writeConfigToFile(filePath) { function writeConfigToFile(filePath) {
console.debug(config)
fs.writeFile(filePath, JSON.stringify(config), (err) => { fs.writeFile(filePath, JSON.stringify(config), (err) => {
if (err) return console.error(err); if (err) return console.error(err);
console.log("File has been created"); console.log("File has been created");