pub fn add_tip_to_remote_tips(&mut self, tip: Tip, save: bool) -> Result<()> {
        let game_key = GAME_SELECTED.read().unwrap().get_game_key_name();

        // Add the new tip.
        match self.remote_tips.tips.get_mut(&game_key) {
            Some(game_tips) => match game_tips.get_mut(tip.get_ref_path()) {
                Some(tips) => tips.push(tip),
                None => { game_tips.insert(tip.get_ref_path().to_owned(), vec![tip]); }
            }
            None => {
                let mut game_tips = HashMap::new();
                game_tips.insert(tip.get_ref_path().to_owned(), vec![tip]);
                self.remote_tips.tips.insert(game_key, game_tips);
            }
        }

        if save {
            let mut file_path = get_config_path()?.join(TIPS_REMOTE_FOLDER);

            // Make sure the path exists to avoid problems with updating schemas.
            DirBuilder::new().recursive(true).create(&file_path)?;

            file_path.push(TIPS_REMOTE_FILE);
            let mut file = File::create(&file_path)?;
            file.write_all(serde_json::to_string_pretty(&self.remote_tips)?.as_bytes())?;
        }

        Ok(())
    }
/// This function adds a tip to the remote tips and saves them.
This function adds a tip to the remote tips and saves them.
This function adds a tip to the remote tips and saves them .
pub fn add_tip_to_remote_tips(&mut self, tip: Tip, save: bool) -> Result<()> {
        let game_key = GAME_SELECTED.read().unwrap().get_game_key_name();
        // Add the new tip.
        match self.remote_tips.tips.get_mut(&game_key) {
            Some(game_tips) => match game_tips.get_mut(tip.get_ref_path()) {
                Some(tips) => tips.push(tip),
                None => { game_tips.insert(tip.get_ref_path().to_owned(), vec![tip]); }
            }
            None => {
                let mut game_tips = HashMap::new();
                game_tips.insert(tip.get_ref_path().to_owned(), vec![tip]);
                self.remote_tips.tips.insert(game_key, game_tips);
            }
        }
        if save {
            let mut file_path = get_config_path()?.join(TIPS_REMOTE_FOLDER);
            // Make sure the path exists to avoid problems with updating schemas.
            DirBuilder::new().recursive(true).create(&file_path)?;
            file_path.push(TIPS_REMOTE_FILE);
            let mut file = File::create(&file_path)?;
            file.write_all(serde_json::to_string_pretty(&self.remote_tips)?.as_bytes())?;
        }
        Ok(())
    }
pub fn add_tip_to_remote_tips ( & mut self , tip : Tip , save : bool ) -> Result < ( ) > { let game_key = GAME_SELECTED . read ( ) . unwrap ( ) . get_game_key_name ( ) ; // Add the new tip. match self . remote_tips . tips . get_mut ( & game_key ) { Some ( game_tips ) => match game_tips . get_mut ( tip . get_ref_path ( ) ) { Some ( tips ) => tips . push ( tip ) , None => { game_tips . insert ( tip . get_ref_path ( ) . to_owned ( ) , vec ! [ tip ] ) ; } } None => { let mut game_tips = HashMap :: new ( ) ; game_tips . insert ( tip . get_ref_path ( ) . to_owned ( ) , vec ! [ tip ] ) ; self . remote_tips . tips . insert ( game_key , game_tips ) ; } } if save { let mut file_path = get_config_path ( ) ? . join ( TIPS_REMOTE_FOLDER ) ; // Make sure the path exists to avoid problems with updating schemas. DirBuilder :: new ( ) . recursive ( true ) . create ( & file_path ) ? ; file_path . push ( TIPS_REMOTE_FILE ) ; let mut file = File :: create ( & file_path ) ? ; file . write_all ( serde_json :: to_string_pretty ( & self . remote_tips ) ? . as_bytes ( ) ) ? ; } Ok ( ( ) ) }
This function adds a tip to the remote tips and saves them.
This function adds a tip to the remote tips and saves them .
&mut self
tip
Tip
save
bool
&mut self
tip
Tip
save
bool