Conversation
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" | ||
|
|
||
| [[package]] |
There was a problem hiding this comment.
Tenhle commit neni v imperativu :D
| //only for display purpose | ||
| let app_folder_path_string = app_folder_path.to_str().unwrap_or(""); | ||
|
|
||
| let empty_config: String = format!( |
There was a problem hiding this comment.
Máš po ruce serde, tohle by mělo bejt:
- vytvoření Default instance
- modifikace tý instance (nastavíš app_folder_path -- tvoje současný řešení neni úplně ideální, protože jak se to serializuje když app_folder_path_string obsahuje uvozovky? :D nevalidní config)
- serde ron serializace tý instance
Tohle řešení je taky fragile, protože si musíš vzpomenout ho updatovat když přidáš nový fieldy
| )" | ||
| ); | ||
|
|
||
| std::fs::write(&config_file_path, empty_config.clone()) |
There was a problem hiding this comment.
Ten .clone je skoro určitě zbytečnej, mělo by stačit &empty_config
| ); | ||
|
|
||
| std::fs::write(&config_file_path, empty_config.clone()) | ||
| .unwrap_or_else(|_| error_of_fail_back_system(app)); |
There was a problem hiding this comment.
fail_back -> fallback?
| } | ||
|
|
||
| pub fn create_empty_config(app: AppHandle) -> PathBuf { | ||
| let app_folder_path = create_app_folder_path(app.clone()); |
There was a problem hiding this comment.
app.clone() je podezřelý, jestli to nemutuješ, tak by imo mělo stačit &app a aby create_app_folder() bral &AppHandle
| }); | ||
| } | ||
|
|
||
| pub fn export_other_mail_list(&mut self) -> Vec<Person> { |
There was a problem hiding this comment.
tohle se jmenuje export_.... ale v podstatě to dělá jenom jiný view na data, klidně by se to mohlo jmenovat třeba recipients()
| [lib] | ||
| # The `_lib` suffix may seem redundant but it is necessary | ||
| # to make the lib name unique and wouldn't conflict with the bin name. | ||
| # This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519 |
| pub fn sender_name(&self) -> &str { | ||
| &self.sender_name | ||
| } | ||
| pub fn save_sender_name(&mut self, text: String) { |
There was a problem hiding this comment.
Tyhle metody by všechny měly bejt set_XXX místo save_XXX, save implikuje že to ukladas na dosk
| pub fn error_pick_file(app: tauri::AppHandle) { | ||
| let error_message: String = "Došlo k chybě při výběru souboru.".to_string(); | ||
|
|
||
| let _ = send_error_mail(error_message, app.clone()); |
There was a problem hiding this comment.
error_message by neměl bejt vynucenej String. Pokud je interně potřeba aby to byl String, tak si to konvertuj na začátku send_error_mail
| pub fn file_is_valid(&self) -> bool { | ||
| self.files.is_some() | ||
| } |
| hx-post="command:close_settings_password" | ||
| hx-trigger="click" | ||
| hx-target="#overlay-password" | ||
| hx-swap="outerHTML" |
There was a problem hiding this comment.
chybí jedna úroveň odsazení, aby bylo vidět že to jsou atributy k buttonu
| placeholder="Heslo" | ||
| name="text" |
| app_state.mail.lock().clear(); | ||
| app_state.other_mail_list.lock().clear(); |
There was a problem hiding this comment.
Proč otvírání settings clearuje mail listy? 🤔
| let mail_list = app_state.mail_list.lock(); | ||
|
|
||
| let markup: Markup = html! { | ||
| @for i in 0..24 { |
There was a problem hiding this comment.
odkud se bere magické číslo 24? buď by to měl bejt výraz kterej se odvozuje např. od dýlky nějakýho fieldu na mail_listu, nebo zadefinovaná konstanta
| let mail_list = app_state.mail_list.lock(); | ||
|
|
||
| let markup: Markup = html! { | ||
| @for i in 24..29 { |
There was a problem hiding this comment.
další suspicious magická čísla
| }; | ||
|
|
||
| if file_picker_text.len() > 28 { | ||
| let shortened_text: String = file_picker_text.chars().take(27).collect(); |
There was a problem hiding this comment.
proč 28? magický číslo :D
| let path_string = path.first().expect("path should exist").to_string(); | ||
|
|
||
| let file_name = path_string | ||
| .split_terminator("/") | ||
| .last() | ||
| .expect("file name should exist"); |
There was a problem hiding this comment.
Path ti umí vyextrahovat filename, tohle je zbytečný, myslim že ta metoda je doslova .filename() :D
| mod backend { | ||
| pub mod config; | ||
| pub mod error_handling; | ||
| pub mod mail_list_utils; | ||
| pub mod mail_sender; | ||
| pub mod other_mail_utils; | ||
| } |
There was a problem hiding this comment.
tohle typicky děláš jako backend.rs nebo backend/mod.rs spíš než inline module
| mail_list: Mutex<MailList>, | ||
| other_mail_list: Mutex<OtherMailList>, | ||
| settings_current_person_id: Mutex<Option<usize>>, | ||
| config: Mutex<Config>, |
There was a problem hiding this comment.
config má bejt editovatelnej z vnitřku aplikace?
| @@ -0,0 +1,5261 @@ | |||
| var htmx = (function() { | |||
There was a problem hiding this comment.
Tenhle soubor neni tvůj zdroják, nepatří pod src/ ---- lepší nápad by byl to mít buď v nějaký static/assets složce nebo importovat HTMX přes CDN.
HTMX je tvoje závislost, když to pojmenuješ prostě htmx.js, víš na jaký verzi HTMX závisíš?
No description provided.