Skip to content

Commit

Permalink
feat: remove unnecessary mut
Browse files Browse the repository at this point in the history
  • Loading branch information
dancixx committed Dec 10, 2023
1 parent 4623275 commit a1a1d6a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
leptos = { version = "0.5.4", features = ["csr"] }
leptos_devtools = { git = "https://github.com/luoxiaozero/leptos-devtools" }
serde = { version = "1.0.192", features = ["derive"] }
serde-wasm-bindgen = "0.6.1"
wasm-bindgen = { version ="0.2.88", features = ["serde-serialize"] }
Expand Down
2 changes: 1 addition & 1 deletion src/db_connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::store::{db::DBStore, query::QueryState};
pub fn db_connector() -> impl IntoView {
let db = use_context::<DBStore>().unwrap();
let connect = create_action(move |db: &DBStore| {
let mut db_clone = *db;
let db_clone = *db;
async move {
db_clone.connect().await;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use app::*;
use leptos::*;

fn main() {
mount_to_body(app)
leptos_devtools::devtools();
mount_to_body(app)
}

4 changes: 2 additions & 2 deletions src/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use crate::{
use leptos::{html::*, *};

pub fn sidebar() -> impl IntoView {
let mut db = use_context::<DBStore>().unwrap();
let db = use_context::<DBStore>().unwrap();
let select_project_details = create_action(move |(db, project): &(DBStore, String)| {
let mut db_clone = *db;
let db_clone = *db;
let project = project.clone();
async move { db_clone.select_project_details(project).await }
});
Expand Down
8 changes: 4 additions & 4 deletions src/store/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl DBStore {
}
}

pub fn reset(&mut self) {
pub fn reset(&self) {
self.project.set(String::new());
self.db_host.set(String::new());
self.db_port.set(String::new());
Expand All @@ -62,7 +62,7 @@ impl DBStore {
)
}

pub async fn connect(&mut self) {
pub async fn connect(&self) {
self.is_connecting.set(true);
let args = serde_wasm_bindgen::to_value(&InvokePostgresConnectionArgs {
project: self.project.get_untracked(),
Expand All @@ -79,7 +79,7 @@ impl DBStore {
self.is_connecting.set(false);
}

pub async fn select_tables(&mut self, schema: String) -> Result<Vec<(String, bool)>, ()> {
pub async fn select_tables(&self, schema: String) -> Result<Vec<(String, bool)>, ()> {
if let Some(tables) = self.tables.get_untracked().get(&schema) {
if !tables.is_empty() {
return Ok(tables.clone());
Expand All @@ -103,7 +103,7 @@ impl DBStore {
Ok(tables)
}

pub async fn select_project_details(&mut self, project: String) -> Result<(), ()> {
pub async fn select_project_details(&self, project: String) -> Result<(), ()> {
let args = serde_wasm_bindgen::to_value(&InvokePostgresConnectionArgs {
project: project.clone(),
key: String::new(),
Expand Down
2 changes: 1 addition & 1 deletion src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::store::{db::DBStore, editor::EditorState, query::QueryState};
use leptos::{html::*, *};

pub fn tables(schema: String) -> impl IntoView {
let mut db = use_context::<DBStore>().unwrap();
let db = use_context::<DBStore>().unwrap();
let query_store = use_context::<QueryState>().unwrap();
let tables = create_resource(
|| {},
Expand Down

0 comments on commit a1a1d6a

Please sign in to comment.