|
@@ -1,4 +1,7 @@
|
|
|
use cli_clipboard::ClipboardProvider as _;
|
|
use cli_clipboard::ClipboardProvider as _;
|
|
|
|
|
+use client_shared::message::{self, MessageSanitized};
|
|
|
|
|
+use client_shared::{DEFAULT_PASSWORD, MAX_MESSAGE_LENGTH, MAX_USERNAME_LENGTH};
|
|
|
|
|
+use client_shared::ui::Language;
|
|
|
use cursive::view::{Nameable as _, Resizable as _};
|
|
use cursive::view::{Nameable as _, Resizable as _};
|
|
|
use cursive::views::{
|
|
use cursive::views::{
|
|
|
Button, Dialog, DummyView, EditView, LinearLayout, NamedView, Panel, ScrollView, SelectView,
|
|
Button, Dialog, DummyView, EditView, LinearLayout, NamedView, Panel, ScrollView, SelectView,
|
|
@@ -8,10 +11,8 @@ use cursive::{event, Cursive};
|
|
|
use utils::hash::Hashable as _;
|
|
use utils::hash::Hashable as _;
|
|
|
|
|
|
|
|
use crate::actions::{self, NetworkError};
|
|
use crate::actions::{self, NetworkError};
|
|
|
-use crate::message::MessageSanitized;
|
|
|
|
|
use crate::{
|
|
use crate::{
|
|
|
- get_appdata, message, save_appdata, Appdata, DEFAULT_PASSWORD, MAX_MESSAGE_LENGTH,
|
|
|
|
|
- MAX_USERNAME_LENGTH,
|
|
|
|
|
|
|
+ get_appdata, save_appdata, Appdata
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
pub const USERS_PANEL_ID: &str = "users_view_id";
|
|
pub const USERS_PANEL_ID: &str = "users_view_id";
|
|
@@ -39,7 +40,7 @@ pub const INFO_BUTTON_ID: &str = "INFO_BUTTON_ID";
|
|
|
|
|
|
|
|
pub const DIALOGUE_MIN_SIZE: (u16, u16) = (20, 5);
|
|
pub const DIALOGUE_MIN_SIZE: (u16, u16) = (20, 5);
|
|
|
pub const SERVER_SETTINGS_FIELD_SIZE: (usize, usize) = (60, 1);
|
|
pub const SERVER_SETTINGS_FIELD_SIZE: (usize, usize) = (60, 1);
|
|
|
-pub const USER_PANEL_SIZE: usize = crate::MAX_USERNAME_LENGTH + 2;
|
|
|
|
|
|
|
+pub const USER_PANEL_SIZE: usize = MAX_USERNAME_LENGTH + 2;
|
|
|
|
|
|
|
|
#[allow(unused)]
|
|
#[allow(unused)]
|
|
|
pub enum Labels {
|
|
pub enum Labels {
|
|
@@ -83,13 +84,6 @@ pub enum Labels {
|
|
|
QuitButton,
|
|
QuitButton,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#[derive(Debug, Clone, Copy)]
|
|
|
|
|
-pub enum Language {
|
|
|
|
|
- English,
|
|
|
|
|
- Dutch,
|
|
|
|
|
- Japanese,
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
impl Labels {
|
|
impl Labels {
|
|
|
// TODO (low): Double check the translations
|
|
// TODO (low): Double check the translations
|
|
|
pub fn localize<'a>(&self, language: Language) -> String {
|
|
pub fn localize<'a>(&self, language: Language) -> String {
|
|
@@ -146,7 +140,7 @@ impl Labels {
|
|
|
]
|
|
]
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- NetworkError::InvalidUrl => {
|
|
|
|
|
|
|
+ NetworkError::UrlError(_) => {
|
|
|
reason_buf = [
|
|
reason_buf = [
|
|
|
"Invalid URL.".to_string(),
|
|
"Invalid URL.".to_string(),
|
|
|
"Ongeldig URL.".to_string(),
|
|
"Ongeldig URL.".to_string(),
|
|
@@ -188,7 +182,7 @@ impl Labels {
|
|
|
format!("ステータスコード: {code}"),
|
|
format!("ステータスコード: {code}"),
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
- NetworkError::InvalidUrl => {
|
|
|
|
|
|
|
+ NetworkError::UrlError(_) => {
|
|
|
reason_buf = [
|
|
reason_buf = [
|
|
|
"Invalid URL.".to_string(),
|
|
"Invalid URL.".to_string(),
|
|
|
"Ongeldig URL.".to_string(),
|
|
"Ongeldig URL.".to_string(),
|
|
@@ -388,7 +382,7 @@ pub fn visual_update(siv: &mut Cursive) {
|
|
|
|
|
|
|
|
// --- Messages ---
|
|
// --- Messages ---
|
|
|
|
|
|
|
|
- let mut messages: Vec<message::MessageSanitized> = appdata
|
|
|
|
|
|
|
+ let mut messages: Vec<MessageSanitized> = appdata
|
|
|
.messages
|
|
.messages
|
|
|
.clone()
|
|
.clone()
|
|
|
.values()
|
|
.values()
|
|
@@ -399,7 +393,7 @@ pub fn visual_update(siv: &mut Cursive) {
|
|
|
|
|
|
|
|
// Remove blocked phrases
|
|
// Remove blocked phrases
|
|
|
for message in messages.iter_mut() {
|
|
for message in messages.iter_mut() {
|
|
|
- message.remove_blocked_phrases(siv);
|
|
|
|
|
|
|
+ message.remove_blocked_phrases(&appdata.persistent_data.blocked_phrases, appdata.persistent_data.blocked_phrases_censor_char);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
siv.call_on_name(
|
|
siv.call_on_name(
|
|
@@ -648,7 +642,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
appdata.persistent_data.current_channel = input.to_string();
|
|
appdata.persistent_data.current_channel = input.to_string();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- save_appdata(siv);
|
|
|
|
|
|
|
+ save_appdata(get_appdata(siv));
|
|
|
visual_update(siv);
|
|
visual_update(siv);
|
|
|
keybind_close_manual_end(siv, false);
|
|
keybind_close_manual_end(siv, false);
|
|
|
} else {
|
|
} else {
|
|
@@ -778,7 +772,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
appdata.persistent_data.username = input.to_string();
|
|
appdata.persistent_data.username = input.to_string();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- save_appdata(siv);
|
|
|
|
|
|
|
+ save_appdata(get_appdata(siv));
|
|
|
visual_update(siv);
|
|
visual_update(siv);
|
|
|
keybind_close_manual_end(siv, false);
|
|
keybind_close_manual_end(siv, false);
|
|
|
} else {
|
|
} else {
|
|
@@ -835,7 +829,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
view.get_mut().remove_item(idx);
|
|
view.get_mut().remove_item(idx);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- save_appdata(siv);
|
|
|
|
|
|
|
+ save_appdata(get_appdata(siv));
|
|
|
visual_update(siv);
|
|
visual_update(siv);
|
|
|
});
|
|
});
|
|
|
wordslist_view.add_all_str(&appdata.persistent_data.blocked_phrases);
|
|
wordslist_view.add_all_str(&appdata.persistent_data.blocked_phrases);
|
|
@@ -867,7 +861,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- save_appdata(siv);
|
|
|
|
|
|
|
+ save_appdata(get_appdata(siv));
|
|
|
visual_update(siv);
|
|
visual_update(siv);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -984,7 +978,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- save_appdata(siv);
|
|
|
|
|
|
|
+ save_appdata(get_appdata(siv));
|
|
|
visual_update(siv);
|
|
visual_update(siv);
|
|
|
keybind_close_manual_end(siv, false);
|
|
keybind_close_manual_end(siv, false);
|
|
|
})
|
|
})
|