Skip to content

Commit

Permalink
fix: guard metax logic with a cfg feature 🚨
Browse files Browse the repository at this point in the history
  • Loading branch information
kareemmahlees committed Aug 24, 2024
1 parent e32982c commit 59b0933
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
9 changes: 7 additions & 2 deletions apps/core/src-tauri/src/commands/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,17 @@ pub async fn establish_connection(
};

#[allow(unused_mut)]
let mut state = SharedState::new(handler, pool, None);
let mut state = SharedState::new(
handler,
pool,
#[cfg(feature = "metax")]
None,
);

#[cfg(feature = "metax")]
{
let child = spawn_sidecar(app, driver, conn_string);
state.metax = None;
state.metax = Some(child);
}

app.manage(Mutex::new(state));
Expand Down
11 changes: 8 additions & 3 deletions apps/core/src-tauri/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sqlx::AnyPool;
// #[cfg(feature = "metax")]
#[cfg(feature = "metax")]
use tauri_plugin_shell::process::CommandChild;
use tx_handlers::Handler;

Expand All @@ -8,15 +8,20 @@ pub struct SharedState {
pub handler: Box<dyn Handler>,
/// `pool` is passed to the Handler
pub pool: AnyPool,
// #[cfg(feature = "metax")]
#[cfg(feature = "metax")]
pub metax: Option<CommandChild>,
}

impl SharedState {
pub fn new(handler: Box<dyn Handler>, pool: AnyPool, metax: Option<CommandChild>) -> Self {
pub fn new(
handler: Box<dyn Handler>,
pool: AnyPool,
#[cfg(feature = "metax")] metax: Option<CommandChild>,
) -> Self {
Self {
handler,
pool,
#[cfg(feature = "metax")]
metax,
}
}
Expand Down

0 comments on commit 59b0933

Please sign in to comment.