feat(autosearch) : add debouncing to fetch wikidata suggestions in ItemsList component
This commit is contained in:
parent
443c7a7e0c
commit
e57a4bbf65
1 changed files with 18 additions and 1 deletions
|
@ -599,8 +599,25 @@ pub fn ItemsList(
|
|||
<EditableCell
|
||||
value=item.name.clone()
|
||||
on_input=move |value| {
|
||||
// Update the item's name field
|
||||
update_item(index, "name", value.clone());
|
||||
fetch_wikidata_suggestions(format!("name-{}", index), value);
|
||||
|
||||
// Log the current suggestions
|
||||
log!("Current suggestions: {:?}", wikidata_suggestions.get().get(&format!("name-{}", index)));
|
||||
|
||||
// Debounce the API request by 500ms
|
||||
spawn_local(async move {
|
||||
gloo_timers::future::sleep(std::time::Duration::from_millis(500)).await;
|
||||
spawn_local(async move {
|
||||
fetch_wikidata_suggestions(format!("name-{}", index), value.clone());
|
||||
set_show_suggestions.update(|suggestions| {
|
||||
suggestions.insert(format!("name-{}", index), true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Log the current suggestions again after the API request
|
||||
log!("Current suggestions after API request: {:?}", wikidata_suggestions.get().get(&format!("name-{}", index)));
|
||||
}
|
||||
key=Arc::new(format!("name-{}", index))
|
||||
focused_cell=focused_cell
|
||||
|
|
Loading…
Add table
Reference in a new issue