[WIP] New UI Logic

This commit is contained in:
Alex Emmet 2026-02-18 10:30:41 +01:00
commit 6db4e806f8
26 changed files with 815 additions and 674 deletions

View file

@ -160,7 +160,7 @@ impl CommunityConnection {
let user_pub_key: PublicKey = match PublicKey::from_bytes(&user_public_key_bytes) {
Some(key) => key,
None => {
__ => {
self.send_error_response(&cv.get_id(), CommunicationType::error_invalid_user_id)
.await;
return;
@ -178,7 +178,7 @@ impl CommunityConnection {
let shared_secret = match community_private_key.to_diffie_hellman(&user_pub_key) {
Some(secret) => secret,
None => {
_ => {
self.send_error_response(&cv.get_id(), CommunicationType::error)
.await;
return;
@ -223,7 +223,7 @@ impl CommunityConnection {
async fn handle_challenge_response(self: Arc<Self>, cv: CommunicationValue) {
let client_challenge_response_b64 = match cv.get_data(DataTypes::challenge) {
Some(data) => data.to_string(),
None => {
_ => {
self.send_error_response(&cv.get_id(), CommunicationType::error)
.await;
return;
@ -273,7 +273,7 @@ impl CommunityConnection {
let shared_secret = match community_private_key.to_diffie_hellman(&user_pub_key) {
Some(secret) => secret,
None => {
_ => {
self.send_error_response(&cv.get_id(), CommunicationType::error)
.await;
return;

View file

@ -1,5 +1,5 @@
use crate::communities::community::{self, Community};
use crate::gui::log_panel;
use crate::log;
use crate::util::file_util;
use once_cell::sync::Lazy;
use std::collections::HashMap;
@ -35,7 +35,7 @@ pub async fn load_communities() {
if let Some(community) = community::load(&name).await {
add_community(community).await;
} else {
log_panel::log_message(format!("failed to load the {} community", &name));
log!("failed to load the {} community", &name);
}
}
}

View file

@ -4,7 +4,7 @@ use crate::{
interactables::interactable::Interactable,
},
data::communication::{CommunicationType, CommunicationValue, DataTypes},
gui::log_panel::log_message,
log,
util::file_util::{get_children, load_file, save_file},
};
use async_trait::async_trait;
@ -37,7 +37,7 @@ impl TextChat {
);
if let Err(e) = fs::create_dir_all(user_dir) {
log_message(format!("Failed to create chat directory: {}", e));
log!("Failed to create chat directory: {}", e);
return;
}
@ -56,16 +56,15 @@ impl TextChat {
break;
}
} else {
log_message(format!("Failed to parse existing JSON file: {}", file_name));
log!("Failed to parse existing JSON file: {}", file_name);
}
} else {
// New file, use empty array
break;
}
chunk_index += 1;
if chunk_index > 1000 {
log_message(format!("Too many message chunks. Aborting add."));
log!("Too many message chunks. Aborting add.");
return;
}
}
@ -77,12 +76,12 @@ impl TextChat {
};
if let Err(e) = message_chunk.push(json_obj) {
log_message(format!("Failed to push new message into JSON array: {}", e));
log!("Failed to push new message into JSON array: {}", e);
return;
}
let file_name = format!("msgs_{}.json", chunk_index);
log_message(format!("Saving message to {}/{}", user_dir, file_name));
log!("Saving message to {}/{}", user_dir, file_name);
save_file(&user_dir, &file_name, &message_chunk.dump());
}
pub fn get_messages(&self, loaded_messages: i64, amount: i64) -> JsonValue {