@@ 47,6 47,8 @@ pub enum GameState {
#[derive(Resource)]
pub struct Global {
pub users_cache: Vec<UserPub>,
+ /// stores ids of users currently in queue to be gotten
+ pub users_cache_queue: Vec<String>,
}
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
@@ 100,6 102,7 @@ fn main() {
app.insert_resource(Global {
users_cache: vec![],
+ users_cache_queue: vec![],
})
.insert_resource(cfg::CfgDirs(
directories::ProjectDirs::from("com", "liljamo", "deckbuilder")
@@ 103,9 103,9 @@ pub fn message_events(
}
DataRequestType::PubUserDetails => {
// TODO: handle possible error
- global
- .users_cache
- .push(response.users.unwrap().get(0).unwrap().clone());
+ let user = response.users.unwrap().get(0).unwrap().clone();
+ global.users_cache_queue.retain(|id| id != &user.id);
+ global.users_cache.push(user);
}
}
}