From ef761fb8369103dc99e7856efc5dd03050c9ffb9 Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Fri, 24 Mar 2023 09:57:18 +0200 Subject: [PATCH] feat(client): user_cache_queue --- client/src/main.rs | 3 +++ client/src/plugins/networking/systems/events/receive/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/src/main.rs b/client/src/main.rs index cb630e0..89ae73b 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -47,6 +47,8 @@ pub enum GameState { #[derive(Resource)] pub struct Global { pub users_cache: Vec, + /// stores ids of users currently in queue to be gotten + pub users_cache_queue: Vec, } #[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") diff --git a/client/src/plugins/networking/systems/events/receive/mod.rs b/client/src/plugins/networking/systems/events/receive/mod.rs index 7e6ad90..f6a366b 100644 --- a/client/src/plugins/networking/systems/events/receive/mod.rs +++ b/client/src/plugins/networking/systems/events/receive/mod.rs @@ -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); } } } -- 2.44.1