bugfix (wow this code is trash

This commit is contained in:
2026-06-18 15:52:21 -04:00
parent 245ba2980d
commit b32f9b9ed9
2 changed files with 15 additions and 14 deletions

3
.gitignore vendored
View File

@@ -3,3 +3,6 @@ config.json
.vscode/ .vscode/
__pycache__/ __pycache__/
.venv/ .venv/
build/
dist/
p2pchat.spec

24
main.py
View File

@@ -15,7 +15,7 @@ import ipaddress
import pyperclip import pyperclip
import requests import requests
HOLE_PUNCH_TEST = ("0.0.0.0", 41234) HOLE_PUNCH_TEST = ("195.201.227.193", 41234)
class SetupApp(App): class SetupApp(App):
@@ -787,23 +787,21 @@ class ChatApp(App):
self.sock.settimeout(None) self.sock.settimeout(None)
self.connected = True self.connected = True
if self.other_name != chat["name"]: if self.other_name != chat["name"]:
with open("chats.json", "r") as f: # with open("chats.json", "r") as f:
current_chats_config = json.load(f) # current_chats_config = json.load(f)
self.call_from_thread( self.call_from_thread(
self.add_message, self.add_message,
"system: other user has new name, updating... (only you can see this)", "system: other user has new name, updating... (only you can see this)",
) )
for file_config in current_chats_config: for local_config in self.chats:
for local_config in self.chats: if (
if ( local_config["key"] == chat["key"]
file_config["key"] == local_config["key"] and local_config["ip"] == chat["ip"]
and file_config["ip"] == local_config["ip"] ):
): local_config["name"] = self.other_name
file_config["name"] = self.other_name break
local_config["name"] = self.other_name
break
with open("chats.json", "w") as f: with open("chats.json", "w") as f:
json.dump(current_chats_config, f) json.dump(self.chats, f)
index = self.chats.index(local_config) index = self.chats.index(local_config)
self.call_from_thread( self.call_from_thread(
lambda: list(self.query_one("#contacts").query("ListItem"))[index] lambda: list(self.query_one("#contacts").query("ListItem"))[index]