|
@@ -299,7 +299,7 @@ pub fn alert<S>(siv: &mut Cursive, title: S, text: S)
|
|
|
where
|
|
where
|
|
|
S: Into<String>,
|
|
S: Into<String>,
|
|
|
{
|
|
{
|
|
|
- let language = get_appdata(siv).language;
|
|
|
|
|
|
|
+ let language = get_appdata(siv).persistent_data.language;
|
|
|
|
|
|
|
|
keybind_setup_close_once(siv);
|
|
keybind_setup_close_once(siv);
|
|
|
|
|
|
|
@@ -317,7 +317,7 @@ pub fn copyable<S>(siv: &mut Cursive, title: S, text: S)
|
|
|
where
|
|
where
|
|
|
S: Into<String> + Clone,
|
|
S: Into<String> + Clone,
|
|
|
{
|
|
{
|
|
|
- let language = get_appdata(siv).language;
|
|
|
|
|
|
|
+ let language = get_appdata(siv).persistent_data.language;
|
|
|
|
|
|
|
|
keybind_setup_close_once(siv);
|
|
keybind_setup_close_once(siv);
|
|
|
|
|
|
|
@@ -345,7 +345,7 @@ pub fn error<S>(siv: &mut Cursive, text: S)
|
|
|
where
|
|
where
|
|
|
S: Into<String>,
|
|
S: Into<String>,
|
|
|
{
|
|
{
|
|
|
- let language = get_appdata(siv).language;
|
|
|
|
|
|
|
+ let language = get_appdata(siv).persistent_data.language;
|
|
|
alert(siv, Labels::Error.localize(language), text.into());
|
|
alert(siv, Labels::Error.localize(language), text.into());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -380,8 +380,8 @@ pub fn keybind_close_manual_end(siv: &mut Cursive, close_all: bool) {
|
|
|
|
|
|
|
|
pub fn visual_update(siv: &mut Cursive) {
|
|
pub fn visual_update(siv: &mut Cursive) {
|
|
|
let appdata = get_appdata(siv);
|
|
let appdata = get_appdata(siv);
|
|
|
- let current_channel = appdata.current_channel;
|
|
|
|
|
- let language = get_appdata(siv).language;
|
|
|
|
|
|
|
+ let current_channel = appdata.persistent_data.current_channel;
|
|
|
|
|
+ let language = get_appdata(siv).persistent_data.language;
|
|
|
|
|
|
|
|
// --- Messages ---
|
|
// --- Messages ---
|
|
|
|
|
|
|
@@ -496,7 +496,7 @@ pub fn visual_update(siv: &mut Cursive) {
|
|
|
|view: &mut NamedView<Panel<TextView>>| {
|
|
|view: &mut NamedView<Panel<TextView>>| {
|
|
|
view.get_mut()
|
|
view.get_mut()
|
|
|
.get_inner_mut()
|
|
.get_inner_mut()
|
|
|
- .set_content(appdata_c.current_channel);
|
|
|
|
|
|
|
+ .set_content(appdata_c.persistent_data.current_channel);
|
|
|
|
|
|
|
|
view.get_mut().set_title(Labels::Channel.localize(language));
|
|
view.get_mut().set_title(Labels::Channel.localize(language));
|
|
|
},
|
|
},
|
|
@@ -507,7 +507,7 @@ pub fn visual_update(siv: &mut Cursive) {
|
|
|
siv.call_on_name(
|
|
siv.call_on_name(
|
|
|
CURRENT_USERNAME_PANEL_ID,
|
|
CURRENT_USERNAME_PANEL_ID,
|
|
|
|view: &mut NamedView<Panel<TextView>>| {
|
|
|view: &mut NamedView<Panel<TextView>>| {
|
|
|
- view.get_mut().get_inner_mut().set_content(appdata.username);
|
|
|
|
|
|
|
+ view.get_mut().get_inner_mut().set_content(appdata.persistent_data.username);
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|
|
|
|
|
|
|
@@ -581,7 +581,7 @@ pub fn visual_update(siv: &mut Cursive) {
|
|
|
|
|
|
|
|
pub fn change_language(siv: &mut Cursive, language: Language) {
|
|
pub fn change_language(siv: &mut Cursive, language: Language) {
|
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
|
- appdata.language = language;
|
|
|
|
|
|
|
+ appdata.persistent_data.language = language;
|
|
|
})
|
|
})
|
|
|
.expect("Failed to set language.");
|
|
.expect("Failed to set language.");
|
|
|
|
|
|
|
@@ -598,7 +598,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
let mut view: SelectView<String> = SelectView::new();
|
|
let mut view: SelectView<String> = SelectView::new();
|
|
|
view.set_on_submit(move |siv, channel_id: &str| {
|
|
view.set_on_submit(move |siv, channel_id: &str| {
|
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
|
- appdata.current_channel = channel_id.to_string();
|
|
|
|
|
|
|
+ appdata.persistent_data.current_channel = channel_id.to_string();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
visual_update(siv);
|
|
visual_update(siv);
|
|
@@ -614,7 +614,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
let channels_new_button = Button::new("", move |siv| {
|
|
let channels_new_button = Button::new("", move |siv| {
|
|
|
keybind_setup_close_once(siv);
|
|
keybind_setup_close_once(siv);
|
|
|
|
|
|
|
|
- let language = get_appdata(siv).language;
|
|
|
|
|
|
|
+ let language = get_appdata(siv).persistent_data.language;
|
|
|
|
|
|
|
|
siv.add_layer(
|
|
siv.add_layer(
|
|
|
cursive::views::Dialog::new()
|
|
cursive::views::Dialog::new()
|
|
@@ -637,7 +637,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
// Valid
|
|
// Valid
|
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
|
appdata.local_channels.push(input.to_string());
|
|
appdata.local_channels.push(input.to_string());
|
|
|
- appdata.current_channel = input.to_string();
|
|
|
|
|
|
|
+ appdata.persistent_data.current_channel = input.to_string();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
save_appdata(siv);
|
|
save_appdata(siv);
|
|
@@ -700,13 +700,13 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
// Language selector
|
|
// Language selector
|
|
|
let language_button = Button::new("", move |siv| {
|
|
let language_button = Button::new("", move |siv| {
|
|
|
// NOTE: This must match the order in the SelectView
|
|
// NOTE: This must match the order in the SelectView
|
|
|
- let current_language_index = match get_appdata(siv).language {
|
|
|
|
|
|
|
+ let current_language_index = match get_appdata(siv).persistent_data.language {
|
|
|
Language::English => 0,
|
|
Language::English => 0,
|
|
|
Language::Dutch => 1,
|
|
Language::Dutch => 1,
|
|
|
Language::Japanese => 2,
|
|
Language::Japanese => 2,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- let language = get_appdata(siv).language;
|
|
|
|
|
|
|
+ let language = get_appdata(siv).persistent_data.language;
|
|
|
|
|
|
|
|
keybind_setup_close_once(siv);
|
|
keybind_setup_close_once(siv);
|
|
|
|
|
|
|
@@ -736,15 +736,15 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
|
|
|
|
|
// Current username panel
|
|
// Current username panel
|
|
|
let current_username_panel = {
|
|
let current_username_panel = {
|
|
|
- let current_username = get_appdata(siv).username.clone();
|
|
|
|
|
|
|
+ let current_username = get_appdata(siv).persistent_data.username.clone();
|
|
|
let view = TextView::new(current_username);
|
|
let view = TextView::new(current_username);
|
|
|
Panel::new(view).with_name(CURRENT_USERNAME_PANEL_ID)
|
|
Panel::new(view).with_name(CURRENT_USERNAME_PANEL_ID)
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// Set username
|
|
// Set username
|
|
|
let username_button = Button::new("", move |siv| {
|
|
let username_button = Button::new("", move |siv| {
|
|
|
- let current_name = get_appdata(siv).username.clone();
|
|
|
|
|
- let language = get_appdata(siv).language;
|
|
|
|
|
|
|
+ let current_name = get_appdata(siv).persistent_data.username.clone();
|
|
|
|
|
+ let language = get_appdata(siv).persistent_data.language;
|
|
|
|
|
|
|
|
keybind_setup_close_once(siv);
|
|
keybind_setup_close_once(siv);
|
|
|
|
|
|
|
@@ -767,7 +767,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
if message::is_valid_username(&input) {
|
|
if message::is_valid_username(&input) {
|
|
|
// Valid
|
|
// Valid
|
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
|
- appdata.username = input.to_string();
|
|
|
|
|
|
|
+ appdata.persistent_data.username = input.to_string();
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
save_appdata(siv);
|
|
save_appdata(siv);
|
|
@@ -775,7 +775,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
keybind_close_manual_end(siv, false);
|
|
keybind_close_manual_end(siv, false);
|
|
|
} else {
|
|
} else {
|
|
|
// Invalid
|
|
// Invalid
|
|
|
- let language = get_appdata(siv).language;
|
|
|
|
|
|
|
+ let language = get_appdata(siv).persistent_data.language;
|
|
|
keybind_close_manual_end(siv, false); // NOTE: Error dialogue overwrites this one, so end it here beforehand.
|
|
keybind_close_manual_end(siv, false); // NOTE: Error dialogue overwrites this one, so end it here beforehand.
|
|
|
error(siv, Labels::InvalidUsernameExplination.localize(language));
|
|
error(siv, Labels::InvalidUsernameExplination.localize(language));
|
|
|
}
|
|
}
|
|
@@ -791,7 +791,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
// Refresh button
|
|
// Refresh button
|
|
|
let refresh_button = Button::new("", move |siv| {
|
|
let refresh_button = Button::new("", move |siv| {
|
|
|
if let Err(e) = actions::load_messages(siv) {
|
|
if let Err(e) = actions::load_messages(siv) {
|
|
|
- let language = get_appdata(siv).language;
|
|
|
|
|
|
|
+ let language = get_appdata(siv).persistent_data.language;
|
|
|
error(siv, Labels::FailedToLoadMessages(e).localize(language));
|
|
error(siv, Labels::FailedToLoadMessages(e).localize(language));
|
|
|
}
|
|
}
|
|
|
visual_update(siv);
|
|
visual_update(siv);
|
|
@@ -802,7 +802,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
let blocked_words_list_button = {
|
|
let blocked_words_list_button = {
|
|
|
Button::new("", move |siv| {
|
|
Button::new("", move |siv| {
|
|
|
let appdata = get_appdata(siv);
|
|
let appdata = get_appdata(siv);
|
|
|
- let language = appdata.language;
|
|
|
|
|
|
|
+ let language = appdata.persistent_data.language;
|
|
|
|
|
|
|
|
let wordslist_id = utils::new_id();
|
|
let wordslist_id = utils::new_id();
|
|
|
let wordslist_id_clone = wordslist_id.clone();
|
|
let wordslist_id_clone = wordslist_id.clone();
|
|
@@ -810,7 +810,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
let mut wordslist_view =
|
|
let mut wordslist_view =
|
|
|
SelectView::<String>::new().on_submit(move |siv, word: &str| {
|
|
SelectView::<String>::new().on_submit(move |siv, word: &str| {
|
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
|
- appdata.blocked_phrases.retain(|x| x != word);
|
|
|
|
|
|
|
+ appdata.persistent_data.blocked_phrases.retain(|x| x != word);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
siv.call_on_name(&wordslist_id_clone, |view: &mut NamedView<SelectView>| {
|
|
siv.call_on_name(&wordslist_id_clone, |view: &mut NamedView<SelectView>| {
|
|
@@ -824,7 +824,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
save_appdata(siv);
|
|
save_appdata(siv);
|
|
|
visual_update(siv);
|
|
visual_update(siv);
|
|
|
});
|
|
});
|
|
|
- wordslist_view.add_all_str(&appdata.blocked_phrases);
|
|
|
|
|
|
|
+ wordslist_view.add_all_str(&appdata.persistent_data.blocked_phrases);
|
|
|
|
|
|
|
|
let typingarea_id = utils::new_id();
|
|
let typingarea_id = utils::new_id();
|
|
|
let typing_area = EditView::new().with_name(&typingarea_id);
|
|
let typing_area = EditView::new().with_name(&typingarea_id);
|
|
@@ -838,12 +838,12 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
.map(|x| x.to_string())
|
|
.map(|x| x.to_string())
|
|
|
.unwrap_or("".to_string());
|
|
.unwrap_or("".to_string());
|
|
|
|
|
|
|
|
- if get_appdata(siv).blocked_phrases.contains(&text) || text.is_empty() {
|
|
|
|
|
|
|
+ if get_appdata(siv).persistent_data.blocked_phrases.contains(&text) || text.is_empty() {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
|
- appdata.blocked_phrases.push(text.clone());
|
|
|
|
|
|
|
+ appdata.persistent_data.blocked_phrases.push(text.clone());
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
siv.call_on_name(
|
|
siv.call_on_name(
|
|
@@ -882,7 +882,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
// Server settings
|
|
// Server settings
|
|
|
let server_settings_button = Button::new("", |siv| {
|
|
let server_settings_button = Button::new("", |siv| {
|
|
|
let appdata = get_appdata(siv);
|
|
let appdata = get_appdata(siv);
|
|
|
- let language = appdata.language;
|
|
|
|
|
|
|
+ let language = appdata.persistent_data.language;
|
|
|
|
|
|
|
|
keybind_setup_close_once(siv);
|
|
keybind_setup_close_once(siv);
|
|
|
|
|
|
|
@@ -900,7 +900,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
.child(DummyView.fixed_width(1))
|
|
.child(DummyView.fixed_width(1))
|
|
|
.child(
|
|
.child(
|
|
|
EditView::new()
|
|
EditView::new()
|
|
|
- .content(appdata.api_endpoint)
|
|
|
|
|
|
|
+ .content(appdata.persistent_data.api_endpoint)
|
|
|
.with_name(SERVER_SETTINGS_ADDRESS_FIELD_ID)
|
|
.with_name(SERVER_SETTINGS_ADDRESS_FIELD_ID)
|
|
|
.min_width(SERVER_SETTINGS_FIELD_SIZE.0)
|
|
.min_width(SERVER_SETTINGS_FIELD_SIZE.0)
|
|
|
.max_height(SERVER_SETTINGS_FIELD_SIZE.1),
|
|
.max_height(SERVER_SETTINGS_FIELD_SIZE.1),
|
|
@@ -915,7 +915,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
.child(DummyView.fixed_width(1))
|
|
.child(DummyView.fixed_width(1))
|
|
|
.child(
|
|
.child(
|
|
|
EditView::new()
|
|
EditView::new()
|
|
|
- .content(appdata.api_refresh_rate.to_string())
|
|
|
|
|
|
|
+ .content(appdata.persistent_data.api_refresh_rate.to_string())
|
|
|
.with_name(SERVER_SETTINGS_REFRESH_FIELD_ID)
|
|
.with_name(SERVER_SETTINGS_REFRESH_FIELD_ID)
|
|
|
.min_width(SERVER_SETTINGS_FIELD_SIZE.0)
|
|
.min_width(SERVER_SETTINGS_FIELD_SIZE.0)
|
|
|
.max_height(SERVER_SETTINGS_FIELD_SIZE.1),
|
|
.max_height(SERVER_SETTINGS_FIELD_SIZE.1),
|
|
@@ -930,7 +930,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
.child(DummyView.fixed_width(1))
|
|
.child(DummyView.fixed_width(1))
|
|
|
.child(
|
|
.child(
|
|
|
EditView::new()
|
|
EditView::new()
|
|
|
- .content(appdata.api_password.to_string())
|
|
|
|
|
|
|
+ .content(appdata.persistent_data.api_password.to_string())
|
|
|
.with_name(SERVER_SETTINGS_PASSWORD_FIELD_ID)
|
|
.with_name(SERVER_SETTINGS_PASSWORD_FIELD_ID)
|
|
|
.min_width(SERVER_SETTINGS_FIELD_SIZE.0)
|
|
.min_width(SERVER_SETTINGS_FIELD_SIZE.0)
|
|
|
.max_height(SERVER_SETTINGS_FIELD_SIZE.1),
|
|
.max_height(SERVER_SETTINGS_FIELD_SIZE.1),
|
|
@@ -957,16 +957,16 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
.expect("Failed to retrieve server settings password input.");
|
|
.expect("Failed to retrieve server settings password input.");
|
|
|
|
|
|
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
siv.with_user_data(|appdata: &mut Appdata| {
|
|
|
- appdata.api_endpoint = input_addr.to_string();
|
|
|
|
|
|
|
+ appdata.persistent_data.api_endpoint = input_addr.to_string();
|
|
|
|
|
|
|
|
let mut password = input_password.to_string();
|
|
let mut password = input_password.to_string();
|
|
|
if password.is_empty() {
|
|
if password.is_empty() {
|
|
|
password = DEFAULT_PASSWORD.to_string();
|
|
password = DEFAULT_PASSWORD.to_string();
|
|
|
}
|
|
}
|
|
|
- appdata.api_password = password;
|
|
|
|
|
|
|
+ appdata.persistent_data.api_password = password;
|
|
|
|
|
|
|
|
if let Ok(rate) = input_refresh.parse() {
|
|
if let Ok(rate) = input_refresh.parse() {
|
|
|
- appdata.api_refresh_rate = rate;
|
|
|
|
|
|
|
+ appdata.persistent_data.api_refresh_rate = rate;
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -984,7 +984,7 @@ pub fn setup_ui(siv: &mut Cursive) -> LinearLayout {
|
|
|
|
|
|
|
|
let info_button = Button::new("", move |siv| {
|
|
let info_button = Button::new("", move |siv| {
|
|
|
let appdata = get_appdata(siv);
|
|
let appdata = get_appdata(siv);
|
|
|
- let language = appdata.language;
|
|
|
|
|
|
|
+ let language = appdata.persistent_data.language;
|
|
|
|
|
|
|
|
alert(siv, Labels::Information.localize(language), "Rei <rain@skuld.network>".to_string());
|
|
alert(siv, Labels::Information.localize(language), "Rei <rain@skuld.network>".to_string());
|
|
|
})
|
|
})
|