Skip to content

Commit

Permalink
box::pin in run(),clippy (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
thesuzerain authored May 12, 2023
1 parent ee0c91a commit 5cb54b4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
33 changes: 18 additions & 15 deletions theseus/src/api/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,23 +391,26 @@ pub async fn remove_project(
/// failing with an error if no credentials are available
#[tracing::instrument]
pub async fn run(path: &Path) -> crate::Result<Arc<RwLock<MinecraftChild>>> {
let state = State::get().await?;
Box::pin(async move {
let state = State::get().await?;

// Get default account and refresh credentials (preferred way to log in)
let default_account = state.settings.read().await.default_user;
let credentials = if let Some(default_account) = default_account {
refresh(default_account).await?
} else {
// If no default account, try to use a logged in account
let users = auth::users().await?;
let last_account = users.first();
if let Some(last_account) = last_account {
refresh(last_account.id).await?
// Get default account and refresh credentials (preferred way to log in)
let default_account = state.settings.read().await.default_user;
let credentials = if let Some(default_account) = default_account {
refresh(default_account).await?
} else {
return Err(crate::ErrorKind::NoCredentialsError.as_error());
}
};
run_credentials(path, &credentials).await
// If no default account, try to use a logged in account
let users = auth::users().await?;
let last_account = users.first();
if let Some(last_account) = last_account {
refresh(last_account.id).await?
} else {
return Err(crate::ErrorKind::NoCredentialsError.as_error());
}
};
run_credentials(path, &credentials).await
})
.await
}

/// Run Minecraft using a profile, and credentials for authentication
Expand Down
2 changes: 1 addition & 1 deletion theseus_gui/src-tauri/src/api/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub async fn profile_edit(
path: &Path,
edit_profile: EditProfile,
) -> Result<()> {
profile::edit(&path, |prof| {
profile::edit(path, |prof| {
if let Some(metadata) = edit_profile.metadata.clone() {
if let Some(name) = metadata.name {
prof.metadata.name = name
Expand Down
4 changes: 2 additions & 2 deletions theseus_playground/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use dunce::canonicalize;
use theseus::jre::autodetect_java_globals;
use theseus::prelude::*;
use theseus::profile::install;
use theseus::profile_create::profile_create;



use tokio::time::{sleep, Duration};
use tracing_error::ErrorLayer;
Expand Down

0 comments on commit 5cb54b4

Please sign in to comment.