fix bug and better return value on existing games
This commit is contained in:
parent
9543dd78cf
commit
737982ac20
@ -78,14 +78,14 @@ async fn add_game(
|
|||||||
let mut games = game_list.lock().await;
|
let mut games = game_list.lock().await;
|
||||||
let mut game = game.into_inner();
|
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)
|
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.push(game.clone());
|
||||||
|
|
||||||
games.sort_unstable_by(|g1, g2| g1.title.cmp(&g2.title));
|
games.sort_unstable_by(|g1, g2| g1.title.cmp(&g2.title));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user