Play your Steam library's Windows games on a jailbroken PS5.
C++
Add Refresh library to the Library's sort sheet
Leonardo Lobato76bacfa03b5e
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cppindex ace99bf..59318a6 100644--- a/src/homebrew/simulation.cpp+++ b/src/homebrew/simulation.cpp@@ -455,7 +455,7 @@ std::string action_label(const std::string& key) {{"sort-name", "Name"}, {"sort-recent-played", "Recently played"}, {"sort-recent-added", "Recently added"},{"sort-playtime", "Playtime"}, {"sort-install-size", "Install size"}, {"filter-installed", "Installed"},{"filter-genre-adventure", "Adventure"}, {"filter-controller-full", "Full controller support"},- {"filter-compat-playable", "Playable"}, {"filters-reset", "Reset filters"}, {"advance-clock", "Advance fixture clock"},+ {"filter-compat-playable", "Playable"}, {"filters-reset", "Reset filters"}, {"refresh-library", "Refresh library"}, {"advance-clock", "Advance fixture clock"},{"inject-download-failed", "Inject download failure"}, {"inject-verification-failed", "Inject verification failure"},{"inject-uninstall-failed", "Inject uninstall failure"},{"inject-storage-disconnect", "Disconnect storage"}, {"inject-controller-disconnect", "Disconnect controller"},@@ -3217,6 +3217,7 @@ void Simulation::rebuild_view() {}else if (action_key == "quit-to-home") item.dangerous = true; // the dialog's primary actionelse if (action_key == "saves-delete-confirm" || action_key == "saves-leftover-confirm") item.dangerous = true;+ else if (action_key == "refresh-library") item.enabled = !state_.library_loading && !state_.library_syncing;else if (action_key == "installed-sort") {item.title = "Sort by";item.value = installed_by_played_ ? "Last played" : "Size";@@ -6051,6 +6052,18 @@ void Simulation::activate() {state_.navigation.route = Route::Home;if (live()) queue_service_action(ServiceAction::RefreshLibrary);}+ else if (action_name == "refresh-library") {+ // As Sync now, but the Library stays on screen. Offline or with an expired sign-in, the+ // controller restores the saved sign-in first.+ close_modal();+ if (live()) {+ state_.library_syncing = true;+ state_.library_loading = true;+ queue_service_action(ServiceAction::RefreshLibrary);+ } else {+ state_.account.last_sync = state_.clock_ticks;+ }+ }else if (action_name == "account-recover") {state_.navigation.modals.clear();open_sign_in();@@ -6375,12 +6388,12 @@ bool Simulation::action(const std::string& logical_action) {[](const Game& game) { return game.added_at.has_value(); });std::vector<std::string> actions = live()? (dated ? std::vector<std::string>{"sort-name", "sort-recent-played", "sort-recent-added", "sort-playtime",- "filter-compat-playable", "filters-reset", "cancel"}+ "filter-compat-playable", "filters-reset", "refresh-library", "cancel"}: std::vector<std::string>{"sort-name", "sort-recent-played", "sort-playtime", "filter-compat-playable",- "filters-reset", "cancel"})+ "filters-reset", "refresh-library", "cancel"}): std::vector<std::string>{"sort-name", "sort-recent-played", "sort-recent-added", "sort-playtime", "sort-install-size","filter-installed", "filter-genre-adventure", "filter-controller-full", "filter-compat-playable",- "filters-reset", "cancel"};+ "filters-reset", "refresh-library", "cancel"};open_modal({"filters", "Sort and filters", state_.navigation.focus_key, std::move(actions), 0, false});}}diff --git a/tests/homebrew_account_test.cpp b/tests/homebrew_account_test.cppindex 6ae172c..6bf53a3 100644--- a/tests/homebrew_account_test.cpp+++ b/tests/homebrew_account_test.cpp@@ -54,7 +54,8 @@ class Backend final : public AuthBackend {if (cancel && !ignore_cancel) return {AuthError::kCanceled,{}};return {error,error == AuthError::kNone ? std::optional<StoredSession>(Session()) : std::nullopt};}- AuthResult Restore(const StoredSession& s,const std::atomic<bool>&) override { return {error,error == AuthError::kNone ? std::optional<StoredSession>(s) : std::nullopt}; }+ std::atomic<int> restores{0};+ AuthResult Restore(const StoredSession& s,const std::atomic<bool>&) override { ++restores; return {error,error == AuthError::kNone ? std::optional<StoredSession>(s) : std::nullopt}; }// Password sign-in by account name: "wrong" is refused, "email-user" needs an email code ("WRONG" is// rejected), "approve" waits for approval (or an app code); any other name signs in.std::atomic<int> credential_calls{0};@@ -503,6 +504,25 @@ void LicenseChangesRefreshTheLibrary() {assert(library_backend.calls==0 && model.state().account.authentication==AuthState::Offline);}}+// Refresh library in Sort and filters, offline: as Sync now, the saved sign-in is restored first.+void OfflineRefreshFromTheLibraryReconnects() {+ Repository repo;repo.value=Session();CacheFixture cache;cache.value=LibrarySnapshot{};+ cache.value->games={{42,"Cached synthetic game",{},{},{}}};+ Simulation model({}, {},ModelMode::Live);Backend backend;backend.error=AuthError::kNetwork;+ LibraryBackendFixture library_backend;LibraryService library_service(library_backend,repo,&cache);+ Controller controller(model,backend,repo,&library_service);+ Wait(controller,[&]{return model.state().account.authentication==AuthState::Offline && model.state().games.size()==1 &&+ !model.state().library_loading;});+ assert(backend.restores==1 && library_backend.calls==0);+ backend.error=AuthError::kNone;+ assert(model.action("r1") && model.state().navigation.route==Route::Library);+ if (model.state().navigation.library_rail_focused) assert(model.action("right"));+ assert(model.action("triangle"));+ Choose(model,"refresh-library");+ Wait(controller,[&]{return model.state().account.authentication==AuthState::SignedIn && library_backend.calls==1 &&+ !model.state().library_loading;});+ assert(backend.restores==2 && model.state().games.front().title=="Connected synthetic game");+}void RepeatedClearPreservesFirstIntent() {for(bool switching:{false,true}) {Repository repo;repo.value=Session();CacheFixture cache;@@ -555,4 +575,4 @@ void SlowLicenseCheckShowsAfterAFewSeconds() {}std::filesystem::remove_all(root);}-int main() { PasswordSignInWithGuardCode(); PasswordFailuresAndCancel(); SlowLicenseCheckShowsAfterAFewSeconds(); CanceledStorageRetryKeepsSavedSessionIntent(); RevokedSessionCleanupRetriesAfterStorageRecovery(); StorageFailureKeepsVisibleAccount(); StorageFailureRetriesSavedSession(); ChallengeAndCancel(); AuthenticationRestoreAndSignOut(); FailedClearDoesNotSwitch(); SignInAgainKeepsTheAccount(); ExitHonorsClearWithoutStartingNewQr(); StorageFailureAndRevocation(); ConnectedLibraryAndOfflineRestart(); LicenseChangesRefreshTheLibrary(); ShutdownClearsLibraryBeforeSession(); RepeatedClearPreservesFirstIntent(); }+int main() { PasswordSignInWithGuardCode(); PasswordFailuresAndCancel(); SlowLicenseCheckShowsAfterAFewSeconds(); CanceledStorageRetryKeepsSavedSessionIntent(); RevokedSessionCleanupRetriesAfterStorageRecovery(); StorageFailureKeepsVisibleAccount(); StorageFailureRetriesSavedSession(); ChallengeAndCancel(); AuthenticationRestoreAndSignOut(); FailedClearDoesNotSwitch(); SignInAgainKeepsTheAccount(); ExitHonorsClearWithoutStartingNewQr(); StorageFailureAndRevocation(); ConnectedLibraryAndOfflineRestart(); LicenseChangesRefreshTheLibrary(); OfflineRefreshFromTheLibraryReconnects(); ShutdownClearsLibraryBeforeSession(); RepeatedClearPreservesFirstIntent(); }diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cppindex 794bc0b..b39e2af 100644--- a/tests/homebrew_library_model_test.cpp+++ b/tests/homebrew_library_model_test.cpp@@ -866,6 +866,29 @@ void live_filters_only_use_available_facts() {"newest acquisition first, undated last");}+// Sort and filters offers Refresh library: it asks the controller for Steam's current list and the+// Library stays on screen. While a refresh runs, the row waits.+void live_sort_sheet_refreshes_the_library() {+ auto model=make_live();+ model.UpdateAccount({AuthState::SignedIn,"123","Synthetic",{},{},true});+ check(model.UpdateLibrary({{game(42,"Synthetic")},false,{},false,false,{}}),"library loaded");+ model.TakeServiceActions();+ check(model.action("r1") && model.action("triangle"),"live filter modal opens");+ const auto* row=find_row(model,"refresh-library");+ check(row!=nullptr && row->title=="Refresh library" && row->enabled,"the sheet offers Refresh library");+ activate(model,"refresh-library");+ const auto actions=model.TakeServiceActions();+ check(actions.size()==1 && actions.front()==ServiceAction::RefreshLibrary,"Refresh library asks for a refresh");+ check(model.state().navigation.modals.empty() && model.state().navigation.route==Route::Library &&+ model.state().library_syncing && model.state().library_loading &&+ model.state().account.authentication==AuthState::SignedIn,"the Library stays while it refreshes");+ check(model.action("triangle"),"filter modal opens while refreshing");+ row=find_row(model,"refresh-library");+ check(row!=nullptr && !row->enabled,"a refresh in progress is not started again");+ check(model.action("focus:refresh-library") && model.action("cross") && model.TakeServiceActions().empty(),+ "the disabled row asks for nothing");+}+void live_uninstall_removes_title_and_keeps_saves() {using playden::homebrew::InstallRequestKind;using playden::homebrew::LiveRuntimeGame;@@ -2061,6 +2084,7 @@ int main() {live_saves_tab();live_saves_upload_all();live_filters_only_use_available_facts();+ live_sort_sheet_refreshes_the_library();live_empty_filter_keeps_the_signed_in_account();projects_only_owned_facts_and_delivery_status();loading_and_failure_preserve_last_good_snapshot();