Add feature to disconnect a shortcut (#160)

This commit is contained in:
Philip Kristoffersen
2022-05-27 20:58:22 +02:00
committed by GitHub
parent 835c7ead8d
commit f16646f540
19 changed files with 271 additions and 122 deletions
+1
View File
@@ -8,3 +8,4 @@ pub use synchronization::run_sync;
pub use synchronization::IsBoilRShortcut;
pub use synchronization::SyncProgress;
pub use synchronization::*;
+20 -1
View File
@@ -23,7 +23,7 @@ use std::error::Error;
use crate::{gog::GogPlatform, itch::ItchPlatform, origin::OriginPlatform};
use std::{fs::File, io::Write, path::Path};
const BOILR_TAG: &str = "boilr";
pub const BOILR_TAG: &str = "boilr";
pub enum SyncProgress {
NotStarted,
@@ -34,6 +34,25 @@ pub enum SyncProgress {
Done,
}
pub fn disconnect_shortcut(settings: &Settings, app_id: u32) -> Result<(), String> {
let mut userinfo_shortcuts = get_shortcuts_paths(&settings.steam)
.map_err(|e| format!("Getting shortcut paths failed: {e}"))?;
for user in userinfo_shortcuts.iter_mut() {
let mut shortcut_info = get_shortcuts_for_user(user);
for shortcut in shortcut_info.shortcuts.iter_mut() {
if shortcut.app_id == app_id {
shortcut.dev_kit_game_id = "".to_string();
shortcut.tags.retain(|s| s != BOILR_TAG);
}
}
save_shortcuts(&shortcut_info.shortcuts, Path::new(&shortcut_info.path));
}
Ok(())
}
pub fn run_sync(
settings: &Settings,
sender: &mut Option<Sender<SyncProgress>>,