diff --git a/meshchat.py b/meshchat.py index 130b4ea..2d77fe2 100644 --- a/meshchat.py +++ b/meshchat.py @@ -1600,6 +1600,23 @@ def convert_nomadnet_string_data_to_map(self, path_data: str | None): else: print(f"unhandled field: {field}") return data + def convert_nomadnet_field_data_to_map(self, field_data): + data = {} + if field_data is not None or "{}": + try: + json_data = field_data + if isinstance(json_data, dict): + # add the prefixed keys to the result dictionary + data = {f"field_{key}": value for key, value in json_data.items()} + else: + return None + except Exception as e: + print(f"skipping invalid field data: {e}") + + return data + + + # handle data received from websocket client async def on_websocket_data_received(self, client, data): @@ -1675,7 +1692,9 @@ def on_file_download_progress(progress): # get data from websocket client destination_hash = data["nomadnet_page_download"]["destination_hash"] page_path = data["nomadnet_page_download"]["page_path"] - + field_data = data["nomadnet_page_download"]["field_data"] + + combined_data = {} # parse data from page path # example: hash:/page/index.mu`field1=123|field2=456 page_data = None @@ -1685,9 +1704,20 @@ def on_file_download_progress(progress): page_path_to_download = page_path_parts[0] page_data = self.convert_nomadnet_string_data_to_map(page_path_parts[1]) + # Field data + field_data = self.convert_nomadnet_field_data_to_map(field_data) + + # Combine page data and field data + if page_data is not None: + combined_data.update(page_data) + if field_data is not None: + combined_data.update(field_data) + + # convert destination hash to bytes destination_hash = bytes.fromhex(destination_hash) + # handle successful page download def on_page_download_success(page_content): asyncio.run(client.send_str(json.dumps({ @@ -1727,7 +1757,7 @@ def on_page_download_progress(progress): # todo: handle page download progress # download the page - downloader = NomadnetPageDownloader(destination_hash, page_path_to_download, page_data, on_page_download_success, on_page_download_failure, on_page_download_progress) + downloader = NomadnetPageDownloader(destination_hash, page_path_to_download, combined_data, on_page_download_success, on_page_download_failure, on_page_download_progress) await downloader.download() # unhandled type diff --git a/src/frontend/components/App.vue b/src/frontend/components/App.vue index 04f9616..a57b8eb 100644 --- a/src/frontend/components/App.vue +++ b/src/frontend/components/App.vue @@ -1,21 +1,24 @@ + - +
@@ -140,18 +140,18 @@
-
-
+
+
- +
Start a new Call
-
+
- +
-
+
-
My Destination Hash
-
{{ myAudioCallAddressHash || "Unknown" }}
+
My Destination Hash
+
{{ myAudioCallAddressHash || "Unknown" }}
-
-
+
+
@@ -204,7 +204,7 @@
{{ audioCall.remote_destination_hash || "Unknown" }}
-
+
Outgoing Call... Incoming Call...
@@ -231,7 +231,7 @@
-
+