diff --git a/src/components/items_list.rs b/src/components/items_list.rs index 8c605ba..dd3ccdf 100644 --- a/src/components/items_list.rs +++ b/src/components/items_list.rs @@ -38,33 +38,22 @@ pub async fn load_items_from_db(current_url: &str) -> Result, String> // Deserialize into Vec log!("Loading items from DB..."); let db_items = response - .json::>() + .json::>() .await .map_err(|err| format!("Failed to parse items: {:?}", err))?; // log!("Deserialized DB items: {:?}", db_items); // Convert DbItem to Item - let items = db_items - .into_iter() - .map(|db_item| { - // Deserialize `custom_properties` from a JSON string to a HashMap - let custom_properties: HashMap = - serde_json::from_str(&db_item.custom_properties) - .unwrap_or_default(); // Fallback to an empty HashMap if deserialization fails - - log!("Loaded item: {:?}", db_item.id); - log!("Custom properties: {:?}", custom_properties); - - Item { - id: db_item.id, - name: db_item.name, - description: db_item.description, - wikidata_id: db_item.wikidata_id, - custom_properties, - } - }) - .collect(); + let items = db_items.into_iter().map(|db_item| { + Item { + id: db_item.id, + name: db_item.name, + description: db_item.description, + wikidata_id: db_item.wikidata_id, + custom_properties: HashMap::new() // Now populated from joins + } + }).collect(); // log!("Converted items: {:?}", items); Ok(items) } else {