From 737982ac20983fccdc7235c6c5896c2ef1859bee Mon Sep 17 00:00:00 2001 From: code002lover Date: Tue, 23 Dec 2025 16:56:39 +0100 Subject: [PATCH] fix bug and better return value on existing games --- backend/src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main.rs b/backend/src/main.rs index eb88964..3b7efaf 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -78,14 +78,14 @@ async fn add_game( let mut games = game_list.lock().await; let mut game = game.into_inner(); - if games.iter().any(|g| { + game.title = game.title.trim().to_string(); + + if let Some(existing) = games.iter().find(|g| { g.title == game.title || (g.remote_id == game.remote_id && g.source == game.source) }) { - return None; + return Some(existing.clone()); } - game.title = game.title.trim().to_string(); - games.push(game.clone()); games.sort_unstable_by(|g1, g2| g1.title.cmp(&g2.title));