You've already forked AstralRinth
forked from didirus/AstralRinth
Initial bug fixes (#127)
* Initial bug fixes * fix compile error on non-mac * Fix even more bugs * Fix more * fix more * fix build * fix build * address review comments
This commit is contained in:
@@ -13,7 +13,9 @@ impl AuthTask {
|
||||
AuthTask(None)
|
||||
}
|
||||
|
||||
pub async fn begin_auth(&mut self) -> crate::Result<url::Url> {
|
||||
pub async fn begin_auth() -> crate::Result<url::Url> {
|
||||
let state = crate::State::get().await?;
|
||||
|
||||
// Creates a channel to receive the URL
|
||||
let (tx, rx) = tokio::sync::oneshot::channel::<url::Url>();
|
||||
let task = tokio::spawn(crate::auth::authenticate(tx));
|
||||
@@ -29,16 +31,20 @@ impl AuthTask {
|
||||
};
|
||||
|
||||
// Flow is going, store in state and return
|
||||
self.0 = Some(task);
|
||||
let mut write = state.auth_flow.write().await;
|
||||
write.0 = Some(task);
|
||||
|
||||
Ok(url)
|
||||
}
|
||||
|
||||
pub async fn await_auth_completion(
|
||||
&mut self,
|
||||
) -> crate::Result<Credentials> {
|
||||
pub async fn await_auth_completion() -> crate::Result<Credentials> {
|
||||
// Gets the task handle from the state, replacing with None
|
||||
let task = mem::replace(&mut self.0, None);
|
||||
let task = {
|
||||
let state = crate::State::get().await?;
|
||||
let mut write = state.auth_flow.write().await;
|
||||
|
||||
mem::replace(&mut write.0, None)
|
||||
};
|
||||
|
||||
// Waits for the task to complete, and returns the credentials
|
||||
let credentials = task
|
||||
@@ -49,13 +55,20 @@ impl AuthTask {
|
||||
Ok(credentials)
|
||||
}
|
||||
|
||||
pub async fn cancel(&mut self) {
|
||||
pub async fn cancel() -> crate::Result<()> {
|
||||
// Gets the task handle from the state, replacing with None
|
||||
let task = mem::replace(&mut self.0, None);
|
||||
let task = {
|
||||
let state = crate::State::get().await?;
|
||||
let mut write = state.auth_flow.write().await;
|
||||
|
||||
mem::replace(&mut write.0, None)
|
||||
};
|
||||
if let Some(task) = task {
|
||||
// Cancels the task
|
||||
task.abort();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -403,14 +403,6 @@ impl Profile {
|
||||
}
|
||||
}
|
||||
|
||||
emit_profile(
|
||||
self.uuid,
|
||||
self.path.clone(),
|
||||
&self.metadata.name,
|
||||
ProfilePayloadType::Synced,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
|
||||
@@ -196,6 +196,7 @@ pub enum ProjectMetadata {
|
||||
authors: Vec<String>,
|
||||
version: Option<String>,
|
||||
icon: Option<PathBuf>,
|
||||
project_type: Option<String>,
|
||||
},
|
||||
Unknown,
|
||||
}
|
||||
@@ -484,6 +485,7 @@ pub async fn infer_data_from_files(
|
||||
.unwrap_or_default(),
|
||||
version: pack.version.clone(),
|
||||
icon,
|
||||
project_type: Some("mod".to_string()),
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -544,6 +546,7 @@ pub async fn infer_data_from_files(
|
||||
authors: pack.author_list.unwrap_or_default(),
|
||||
version: pack.version,
|
||||
icon,
|
||||
project_type: Some("mod".to_string()),
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -612,6 +615,7 @@ pub async fn infer_data_from_files(
|
||||
.collect(),
|
||||
version: Some(pack.version),
|
||||
icon,
|
||||
project_type: Some("mod".to_string()),
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -687,6 +691,7 @@ pub async fn infer_data_from_files(
|
||||
.unwrap_or_default(),
|
||||
version: Some(pack.version),
|
||||
icon,
|
||||
project_type: Some("mod".to_string()),
|
||||
},
|
||||
},
|
||||
);
|
||||
@@ -735,6 +740,7 @@ pub async fn infer_data_from_files(
|
||||
authors: Vec::new(),
|
||||
version: None,
|
||||
icon,
|
||||
project_type: None,
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
@@ -118,17 +118,12 @@ pub enum Theme {
|
||||
/// Minecraft memory settings
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
|
||||
pub struct MemorySettings {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub minimum: Option<u32>,
|
||||
pub maximum: u32,
|
||||
}
|
||||
|
||||
impl Default for MemorySettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
minimum: None,
|
||||
maximum: 2048,
|
||||
}
|
||||
Self { maximum: 2048 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user