Skip to content

Commit

Permalink
Reuse search_params.clone() inside callbcak
Browse files Browse the repository at this point in the history
Signed-off-by: carlosthe19916 <[email protected]>
  • Loading branch information
carlosthe19916 authored and ctron committed Sep 7, 2023
1 parent 7b3067d commit ce43012
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions spog/ui/src/components/advisory/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,12 @@ pub fn advisory_search(props: &AdvisorySearchProperties) -> Html {
total.set(state.data().and_then(|d| d.total));

let onsort = {
let search_params_state = search_params.clone();
use_callback(
move |sort_by: (String, bool), search_params| {
if let SearchMode::Simple(simple) = &**search_params {
let mut simple = simple.clone();
simple.set_sort_by(sort_by);
search_params_state.set(SearchMode::Simple(simple));
search_params.set(SearchMode::Simple(simple));
};
},
search_params.clone(),
Expand Down
3 changes: 1 addition & 2 deletions spog/ui/src/components/sbom/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,12 @@ pub fn sbom_search(props: &SbomSearchProperties) -> Html {
total.set(state.data().and_then(|d| d.total));

let onsort = {
let search_params_state = search_params.clone();
use_callback(
move |sort_by: (String, bool), search_params| {
if let SearchMode::Simple(simple) = &**search_params {
let mut simple = simple.clone();
simple.set_sort_by(sort_by);
search_params_state.set(SearchMode::Simple(simple));
search_params.set(SearchMode::Simple(simple));
};
},
search_params.clone(),
Expand Down
3 changes: 1 addition & 2 deletions spog/ui/src/pages/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,12 @@ where
let search = use_hook(search_params.clone(), pagination.clone(), callback);

let onsort = {
let search_params_state = search_params.clone();
use_callback(
move |sort_by: (String, bool), search_params| {
if let SearchMode::Simple(simple) = &**search_params {
let mut simple = simple.clone();
simple.set_sort_by(sort_by);
search_params_state.set(SearchMode::Simple(simple));
search_params.set(SearchMode::Simple(simple));
};
},
search_params.clone(),
Expand Down

0 comments on commit ce43012

Please sign in to comment.