implement a more consistent login mask with a stable layout and improved error messages
This commit is contained in:
parent
f7e470ca58
commit
97d69f37e9
5 changed files with 352 additions and 78 deletions
|
|
@ -10,7 +10,31 @@ use std::time::Duration;
|
|||
use tokio::net::UnixStream;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::common;
|
||||
use crate::{common, fl};
|
||||
|
||||
/// Convert greetd error descriptions to user-friendly localized messages
|
||||
fn greetd_error_to_message(error_type: greetd_ipc::ErrorType, description: &str) -> String {
|
||||
use greetd_ipc::ErrorType;
|
||||
|
||||
match error_type {
|
||||
ErrorType::AuthError => {
|
||||
// For authentication errors, check description for specific error types
|
||||
if description.contains("PERM_DENIED") {
|
||||
fl!("auth-error-denied")
|
||||
} else if description.contains("MAXTRIES") {
|
||||
fl!("auth-error-maxtries")
|
||||
} else if description.contains("ACCT_EXPIRED") || description.contains("USER_UNKNOWN") {
|
||||
fl!("auth-error-account")
|
||||
} else {
|
||||
fl!("auth-error-credentials")
|
||||
}
|
||||
}
|
||||
ErrorType::Error => {
|
||||
// For generic errors, show a generic message
|
||||
fl!("auth-error-default")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn subscription() -> Subscription<Message> {
|
||||
struct GreetdSubscription;
|
||||
|
|
@ -89,10 +113,9 @@ pub fn subscription() -> Subscription<Message> {
|
|||
}
|
||||
},
|
||||
greetd_ipc::Response::Error {
|
||||
error_type: _,
|
||||
error_type,
|
||||
description,
|
||||
} => {
|
||||
//TODO: use error_type?
|
||||
match request {
|
||||
greetd_ipc::Request::CancelSession => {
|
||||
// Do not send errors for cancel session to gui
|
||||
|
|
@ -105,7 +128,12 @@ pub fn subscription() -> Subscription<Message> {
|
|||
break;
|
||||
}
|
||||
_ => {
|
||||
_ = sender.send(Message::Error(description)).await;
|
||||
_ = sender
|
||||
.send(Message::Error(greetd_error_to_message(
|
||||
error_type,
|
||||
&description,
|
||||
)))
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue