Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.14.0 #245

Merged
merged 4 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ members = ["proc-macros", "core", "tauri-app"]
resolver = "2"

[workspace.package]
version = "0.13.1"
version = "0.14.0"
authors = ["Raicuparta"]
license = "GPL-3.0-or-later"
repository = "https://github.com/Raicuparta/rai-pal"
Expand Down
39 changes: 25 additions & 14 deletions backend/tauri-app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ fn refresh_game_mods_and_exe(installed_game: &InstalledGame, handle: &AppHandle)
{
let mut installed_games = installed_games_state.get_data()?;
installed_games.insert(refreshed_game.id.clone(), refreshed_game.clone());
update_installed_games_state(handle, &installed_game.provider, installed_games);
update_installed_games_state(handle, &installed_game.provider, &installed_games);
}

Ok(())
Expand Down Expand Up @@ -394,7 +394,7 @@ async fn fetch_remote_games() -> Result<Vec<RemoteGame>> {
fn update_installed_games_state(
handle: &AppHandle,
provider_id: &ProviderId,
installed_games: HashMap<String, InstalledGame>,
installed_games: &HashMap<String, InstalledGame>,
) {
if let Some(mutex) = handle.app_state().installed_games.get(provider_id) {
update_state(installed_games.clone(), mutex);
Expand All @@ -405,7 +405,7 @@ fn update_installed_games_state(
fn update_owned_games_state(
handle: &AppHandle,
provider_id: &ProviderId,
owned_games: HashMap<String, OwnedGame>,
owned_games: &HashMap<String, OwnedGame>,
) {
if let Some(mutex) = handle.app_state().owned_games.get(provider_id) {
update_state(owned_games.clone(), mutex);
Expand All @@ -429,23 +429,34 @@ async fn get_provider_games(handle: AppHandle, provider_id: ProviderId) -> Resul
} else {
installed_games = cache.data.installed_games.clone();
owned_games = cache.data.owned_games.clone();
update_installed_games_state(&handle, &provider_id, installed_games.clone());
update_owned_games_state(&handle, &provider_id, owned_games.clone());
update_installed_games_state(&handle, &provider_id, &installed_games);
update_owned_games_state(&handle, &provider_id, &owned_games);
}

let provider = provider::get_provider(provider_id)?;

provider
.get_games(
let mut owned_count = 0;
let mut installed_count = 0;
// Sending to frontend too often makes things slow,
// especially for very large libraries where I'm cloning the entire game map every time I push it.
// So we send the game lists in batches!
const BATCH_SIZE: usize = 500;

provider.get_games(
|game: InstalledGame| {
installed_count += 1;
installed_games_without_cache.insert(game.id.clone(), game.clone());
installed_games.insert(game.id.clone(), game);
update_installed_games_state(&handle, &provider_id, installed_games.clone());
if (installed_count % BATCH_SIZE) == 0 {
update_installed_games_state(&handle, &provider_id, &installed_games);
}
},
|game: OwnedGame| {
owned_count += 1;
owned_games_without_cache.insert(game.global_id.clone(), game.clone());
owned_games.insert(game.global_id.clone(), game);
update_owned_games_state(&handle, &provider_id, owned_games.clone());
if (owned_count % BATCH_SIZE) == 0 {
update_owned_games_state(&handle, &provider_id, &owned_games);
}
},
)
.await
Expand All @@ -455,8 +466,8 @@ async fn get_provider_games(handle: AppHandle, provider_id: ProviderId) -> Resul
log::warn!("Failed to get games for provider {provider_id}. User might just not have it. Error: {err}");
});

update_installed_games_state(&handle, &provider_id, installed_games_without_cache.clone());
update_owned_games_state(&handle, &provider_id, owned_games_without_cache.clone());
update_installed_games_state(&handle, &provider_id, &installed_games_without_cache);
update_owned_games_state(&handle, &provider_id, &owned_games_without_cache);

cache
.set_data(ProviderData {
Expand Down Expand Up @@ -486,7 +497,7 @@ async fn add_game(path: PathBuf, handle: AppHandle) -> Result {
{
let mut installed_games = installed_games_state.get_data()?;
installed_games.insert(installed_game.id.clone(), installed_game.clone());
update_installed_games_state(&handle, &installed_game.provider, installed_games);
update_installed_games_state(&handle, &installed_game.provider, &installed_games);
}

handle.emit_safe(events::SelectInstalledGame(installed_game.id.clone()));
Expand All @@ -508,7 +519,7 @@ async fn remove_game(installed_game: InstalledGame, handle: AppHandle) -> Result
{
let mut installed_games = installed_games_state.get_data()?;
installed_games.remove(&installed_game.id);
update_installed_games_state(&handle, &installed_game.provider, installed_games);
update_installed_games_state(&handle, &installed_game.provider, &installed_games);
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $version = [regex]::Match($msiName, '.+_(.+)_.+_.+').Groups[1].Value
$signature = Get-Content -Path "$msiFolder/*.sig" -Raw

# Read changelog from environment variable.
$changelog = $env:RAI_PAL_CHANGELOG -or "Someone forgot to include a changelog."
$changelog = $env:RAI_PAL_CHANGELOG ?? "Someone forgot to include a changelog."

# Create json that's used by Rai Pal for checking updates.
$updaterJson = ConvertTo-Json -InputObjec @{
Expand Down
Loading