keep opinions of updated games and make sure games are sorted
This commit is contained in:
parent
86683d410f
commit
74941a8abc
@ -124,6 +124,19 @@ async fn update_game(
|
||||
if let Some(existing) = games.iter_mut().find(|g| {
|
||||
(g.remote_id == game.remote_id && g.source == game.source) || (g.title == game.title)
|
||||
}) {
|
||||
if existing.title != game.title {
|
||||
// Update title for every opinion
|
||||
for person in user_list.lock().await.iter_mut() {
|
||||
let opinion = person
|
||||
.person
|
||||
.opinion
|
||||
.iter_mut()
|
||||
.find(|o| o.title == existing.title);
|
||||
if let Some(opinion) = opinion {
|
||||
opinion.title = game.title.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
existing.title = game.title.clone();
|
||||
existing.source = game.source;
|
||||
existing.min_players = game.min_players;
|
||||
@ -133,6 +146,9 @@ async fn update_game(
|
||||
|
||||
r_existing = Some(existing.clone());
|
||||
}
|
||||
|
||||
games.sort_unstable_by(|g1, g2| g1.title.cmp(&g2.title));
|
||||
|
||||
let users = user_list.lock().await;
|
||||
save_state(&games, &users);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user