mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-10 19:16:55 +02:00
chore: apply rustfmt formatting updates
This commit is contained in:
@@ -1095,13 +1095,9 @@ async fn cmd_get_http_authentication_config<R: Runtime>(
|
|||||||
|
|
||||||
// Convert HashMap<String, JsonPrimitive> to serde_json::Value for rendering
|
// Convert HashMap<String, JsonPrimitive> to serde_json::Value for rendering
|
||||||
let values_json: serde_json::Value = serde_json::to_value(&values)?;
|
let values_json: serde_json::Value = serde_json::to_value(&values)?;
|
||||||
let rendered_json = render_json_value(
|
let rendered_json =
|
||||||
values_json,
|
render_json_value(values_json, environment_chain, &cb, &RenderOptions::return_empty())
|
||||||
environment_chain,
|
.await?;
|
||||||
&cb,
|
|
||||||
&RenderOptions::return_empty(),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
// Convert back to HashMap<String, JsonPrimitive>
|
// Convert back to HashMap<String, JsonPrimitive>
|
||||||
let rendered_values: HashMap<String, JsonPrimitive> = serde_json::from_value(rendered_json)?;
|
let rendered_values: HashMap<String, JsonPrimitive> = serde_json::from_value(rendered_json)?;
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use tauri::{AppHandle, Emitter, Manager, Runtime, WebviewWindow};
|
use tauri::{AppHandle, Emitter, Manager, Runtime, WebviewWindow};
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
use yaak_api::yaak_api_client;
|
||||||
use yaak_common::platform::get_os_str;
|
use yaak_common::platform::get_os_str;
|
||||||
use yaak_models::util::UpdateSource;
|
use yaak_models::util::UpdateSource;
|
||||||
use yaak_api::yaak_api_client;
|
|
||||||
|
|
||||||
// Check for updates every hour
|
// Check for updates every hour
|
||||||
const MAX_UPDATE_CHECK_SECONDS: u64 = 60 * 60;
|
const MAX_UPDATE_CHECK_SECONDS: u64 = 60 * 60;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use tauri::{
|
|||||||
};
|
};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
use yaak_api::yaak_api_client;
|
||||||
use yaak_models::models::Plugin;
|
use yaak_models::models::Plugin;
|
||||||
use yaak_models::util::UpdateSource;
|
use yaak_models::util::UpdateSource;
|
||||||
use yaak_plugins::api::{
|
use yaak_plugins::api::{
|
||||||
@@ -31,7 +32,6 @@ use yaak_plugins::events::{Color, Icon, PluginContext, ShowToastRequest};
|
|||||||
use yaak_plugins::install::{delete_and_uninstall, download_and_install};
|
use yaak_plugins::install::{delete_and_uninstall, download_and_install};
|
||||||
use yaak_plugins::manager::PluginManager;
|
use yaak_plugins::manager::PluginManager;
|
||||||
use yaak_plugins::plugin_meta::get_plugin_meta;
|
use yaak_plugins::plugin_meta::get_plugin_meta;
|
||||||
use yaak_api::yaak_api_client;
|
|
||||||
|
|
||||||
static EXITING: AtomicBool = AtomicBool::new(false);
|
static EXITING: AtomicBool = AtomicBool::new(false);
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ use std::fs;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tauri::{AppHandle, Emitter, Manager, Runtime, Url};
|
use tauri::{AppHandle, Emitter, Manager, Runtime, Url};
|
||||||
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind};
|
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind};
|
||||||
|
use yaak_api::yaak_api_client;
|
||||||
use yaak_models::util::generate_id;
|
use yaak_models::util::generate_id;
|
||||||
use yaak_plugins::events::{Color, ShowToastRequest};
|
use yaak_plugins::events::{Color, ShowToastRequest};
|
||||||
use yaak_plugins::install::download_and_install;
|
use yaak_plugins::install::download_and_install;
|
||||||
use yaak_plugins::manager::PluginManager;
|
use yaak_plugins::manager::PluginManager;
|
||||||
use yaak_api::yaak_api_client;
|
|
||||||
|
|
||||||
pub(crate) async fn handle_deep_link<R: Runtime>(
|
pub(crate) async fn handle_deep_link<R: Runtime>(
|
||||||
app_handle: &AppHandle<R>,
|
app_handle: &AppHandle<R>,
|
||||||
|
|||||||
@@ -153,11 +153,8 @@ pub fn app_menu<R: Runtime>(app_handle: &AppHandle<R>) -> tauri::Result<Menu<R>>
|
|||||||
.build(app_handle)?,
|
.build(app_handle)?,
|
||||||
&MenuItemBuilder::with_id("dev.reset_size".to_string(), "Reset Size")
|
&MenuItemBuilder::with_id("dev.reset_size".to_string(), "Reset Size")
|
||||||
.build(app_handle)?,
|
.build(app_handle)?,
|
||||||
&MenuItemBuilder::with_id(
|
&MenuItemBuilder::with_id("dev.reset_size_16x9".to_string(), "Resize to 16x9")
|
||||||
"dev.reset_size_16x9".to_string(),
|
.build(app_handle)?,
|
||||||
"Resize to 16x9",
|
|
||||||
)
|
|
||||||
.build(app_handle)?,
|
|
||||||
&MenuItemBuilder::with_id(
|
&MenuItemBuilder::with_id(
|
||||||
"dev.reset_size_16x10".to_string(),
|
"dev.reset_size_16x10".to_string(),
|
||||||
"Resize to 16x10",
|
"Resize to 16x10",
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ use std::ops::Add;
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tauri::{AppHandle, Emitter, Manager, Runtime, WebviewWindow, is_dev};
|
use tauri::{AppHandle, Emitter, Manager, Runtime, WebviewWindow, is_dev};
|
||||||
use ts_rs::TS;
|
use ts_rs::TS;
|
||||||
|
use yaak_api::yaak_api_client;
|
||||||
use yaak_common::platform::get_os_str;
|
use yaak_common::platform::get_os_str;
|
||||||
use yaak_models::db_context::DbContext;
|
use yaak_models::db_context::DbContext;
|
||||||
use yaak_models::query_manager::QueryManager;
|
use yaak_models::query_manager::QueryManager;
|
||||||
use yaak_models::util::UpdateSource;
|
use yaak_models::util::UpdateSource;
|
||||||
use yaak_api::yaak_api_client;
|
|
||||||
|
|
||||||
/// Extension trait for accessing the QueryManager from Tauri Manager types.
|
/// Extension trait for accessing the QueryManager from Tauri Manager types.
|
||||||
/// This is needed temporarily until all crates are refactored to not use Tauri.
|
/// This is needed temporarily until all crates are refactored to not use Tauri.
|
||||||
@@ -159,10 +159,8 @@ pub async fn deactivate_license<R: Runtime>(window: &WebviewWindow<R>) -> Result
|
|||||||
let app_version = window.app_handle().package_info().version.to_string();
|
let app_version = window.app_handle().package_info().version.to_string();
|
||||||
let client = yaak_api_client(&app_version)?;
|
let client = yaak_api_client(&app_version)?;
|
||||||
let path = format!("/licenses/activations/{}/deactivate", activation_id);
|
let path = format!("/licenses/activations/{}/deactivate", activation_id);
|
||||||
let payload = DeactivateLicenseRequestPayload {
|
let payload =
|
||||||
app_platform: get_os_str().to_string(),
|
DeactivateLicenseRequestPayload { app_platform: get_os_str().to_string(), app_version };
|
||||||
app_version,
|
|
||||||
};
|
|
||||||
let response = client.post(build_url(&path)).json(&payload).send().await?;
|
let response = client.post(build_url(&path)).json(&payload).send().await?;
|
||||||
|
|
||||||
if response.status().is_client_error() {
|
if response.status().is_client_error() {
|
||||||
@@ -189,10 +187,8 @@ pub async fn deactivate_license<R: Runtime>(window: &WebviewWindow<R>) -> Result
|
|||||||
|
|
||||||
pub async fn check_license<R: Runtime>(window: &WebviewWindow<R>) -> Result<LicenseCheckStatus> {
|
pub async fn check_license<R: Runtime>(window: &WebviewWindow<R>) -> Result<LicenseCheckStatus> {
|
||||||
let app_version = window.app_handle().package_info().version.to_string();
|
let app_version = window.app_handle().package_info().version.to_string();
|
||||||
let payload = CheckActivationRequestPayload {
|
let payload =
|
||||||
app_platform: get_os_str().to_string(),
|
CheckActivationRequestPayload { app_platform: get_os_str().to_string(), app_version };
|
||||||
app_version,
|
|
||||||
};
|
|
||||||
let activation_id = get_activation_id(window.app_handle()).await;
|
let activation_id = get_activation_id(window.app_handle()).await;
|
||||||
|
|
||||||
let settings = window.db().get_settings();
|
let settings = window.db().get_settings();
|
||||||
|
|||||||
@@ -74,15 +74,31 @@ impl Display for HttpResponseEvent {
|
|||||||
};
|
};
|
||||||
write!(f, "* Redirect {} -> {} ({})", status, url, behavior_str)
|
write!(f, "* Redirect {} -> {} ({})", status, url, behavior_str)
|
||||||
}
|
}
|
||||||
HttpResponseEvent::SendUrl { method, scheme, username, password, host, port, path, query, fragment } => {
|
HttpResponseEvent::SendUrl {
|
||||||
|
method,
|
||||||
|
scheme,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
path,
|
||||||
|
query,
|
||||||
|
fragment,
|
||||||
|
} => {
|
||||||
let auth_str = if username.is_empty() && password.is_empty() {
|
let auth_str = if username.is_empty() && password.is_empty() {
|
||||||
String::new()
|
String::new()
|
||||||
} else {
|
} else {
|
||||||
format!("{}:{}@", username, password)
|
format!("{}:{}@", username, password)
|
||||||
};
|
};
|
||||||
let query_str = if query.is_empty() { String::new() } else { format!("?{}", query) };
|
let query_str =
|
||||||
let fragment_str = if fragment.is_empty() { String::new() } else { format!("#{}", fragment) };
|
if query.is_empty() { String::new() } else { format!("?{}", query) };
|
||||||
write!(f, "> {} {}://{}{}:{}{}{}{}", method, scheme, auth_str, host, port, path, query_str, fragment_str)
|
let fragment_str =
|
||||||
|
if fragment.is_empty() { String::new() } else { format!("#{}", fragment) };
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"> {} {}://{}{}:{}{}{}{}",
|
||||||
|
method, scheme, auth_str, host, port, path, query_str, fragment_str
|
||||||
|
)
|
||||||
}
|
}
|
||||||
HttpResponseEvent::ReceiveUrl { version, status } => {
|
HttpResponseEvent::ReceiveUrl { version, status } => {
|
||||||
write!(f, "< {} {}", version_to_str(version), status)
|
write!(f, "< {} {}", version_to_str(version), status)
|
||||||
@@ -122,7 +138,17 @@ impl From<HttpResponseEvent> for yaak_models::models::HttpResponseEventData {
|
|||||||
RedirectBehavior::DropBody => "drop_body".to_string(),
|
RedirectBehavior::DropBody => "drop_body".to_string(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
HttpResponseEvent::SendUrl { method, scheme, username, password, host, port, path, query, fragment } => {
|
HttpResponseEvent::SendUrl {
|
||||||
|
method,
|
||||||
|
scheme,
|
||||||
|
username,
|
||||||
|
password,
|
||||||
|
host,
|
||||||
|
port,
|
||||||
|
path,
|
||||||
|
query,
|
||||||
|
fragment,
|
||||||
|
} => {
|
||||||
D::SendUrl { method, scheme, username, password, host, port, path, query, fragment }
|
D::SendUrl { method, scheme, username, password, host, port, path, query, fragment }
|
||||||
}
|
}
|
||||||
HttpResponseEvent::ReceiveUrl { version, status } => {
|
HttpResponseEvent::ReceiveUrl { version, status } => {
|
||||||
@@ -546,7 +572,10 @@ impl<S> SizedBody<S> {
|
|||||||
|
|
||||||
impl<S> HttpBody for SizedBody<S>
|
impl<S> HttpBody for SizedBody<S>
|
||||||
where
|
where
|
||||||
S: futures_util::Stream<Item = std::result::Result<Bytes, std::io::Error>> + Send + Unpin + 'static,
|
S: futures_util::Stream<Item = std::result::Result<Bytes, std::io::Error>>
|
||||||
|
+ Send
|
||||||
|
+ Unpin
|
||||||
|
+ 'static,
|
||||||
{
|
{
|
||||||
type Data = Bytes;
|
type Data = Bytes;
|
||||||
type Error = std::io::Error;
|
type Error = std::io::Error;
|
||||||
|
|||||||
@@ -37,10 +37,9 @@ impl From<SendableBodyWithMeta> for SendableBody {
|
|||||||
fn from(value: SendableBodyWithMeta) -> Self {
|
fn from(value: SendableBodyWithMeta) -> Self {
|
||||||
match value {
|
match value {
|
||||||
SendableBodyWithMeta::Bytes(b) => SendableBody::Bytes(b),
|
SendableBodyWithMeta::Bytes(b) => SendableBody::Bytes(b),
|
||||||
SendableBodyWithMeta::Stream { data, content_length } => SendableBody::Stream {
|
SendableBodyWithMeta::Stream { data, content_length } => {
|
||||||
data,
|
SendableBody::Stream { data, content_length: content_length.map(|l| l as u64) }
|
||||||
content_length: content_length.map(|l| l as u64),
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user