diff --git a/.gitignore b/.gitignore index a64d2d2..639968e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ chats.json config.json .vscode/ __pycache__/ -.venv/ \ No newline at end of file +.venv/ +build/ +dist/ +p2pchat.spec \ No newline at end of file diff --git a/main.py b/main.py index 4ebef6c..f3b0fb3 100644 --- a/main.py +++ b/main.py @@ -15,7 +15,7 @@ import ipaddress import pyperclip import requests -HOLE_PUNCH_TEST = ("0.0.0.0", 41234) +HOLE_PUNCH_TEST = ("195.201.227.193", 41234) class SetupApp(App): @@ -787,23 +787,21 @@ class ChatApp(App): self.sock.settimeout(None) self.connected = True if self.other_name != chat["name"]: - with open("chats.json", "r") as f: - current_chats_config = json.load(f) + # with open("chats.json", "r") as f: + # current_chats_config = json.load(f) self.call_from_thread( self.add_message, "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: - if ( - file_config["key"] == local_config["key"] - and file_config["ip"] == local_config["ip"] - ): - file_config["name"] = self.other_name - local_config["name"] = self.other_name - break + for local_config in self.chats: + if ( + local_config["key"] == chat["key"] + and local_config["ip"] == chat["ip"] + ): + local_config["name"] = self.other_name + break with open("chats.json", "w") as f: - json.dump(current_chats_config, f) + json.dump(self.chats, f) index = self.chats.index(local_config) self.call_from_thread( lambda: list(self.query_one("#contacts").query("ListItem"))[index]