Skip to content
Open
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
10 changes: 5 additions & 5 deletions main/interface/appstore_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,12 @@ std::vector<std::string> split_csv_paths(const std::string &value)
std::string sort_rule_label(SortRule rule)
{
switch (rule) {
case SortRule::New: return "new";
case SortRule::Old: return "old";
case SortRule::AtoZ: return "a-z";
case SortRule::ZtoA: return "z-a";
case SortRule::New: return "Newest first";
case SortRule::Old: return "Oldest first";
case SortRule::AtoZ: return "A-Z";
case SortRule::ZtoA: return "Z-A";
case SortRule::Default:
default: return "def";
default: return "Default";
}
}

Expand Down
6 changes: 2 additions & 4 deletions main/ui/catalog_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ void CatalogController::select_adjacent_category(int delta)

void CatalogController::cycle_sort_rule()
{
StoreApp *app = session_.catalog.selected_app();
const std::string selected_id = app ? app->id : "";
switch (session_.catalog.sort_rule()) {
case SortRule::Default: session_.catalog.sort_rule() = SortRule::New; break;
case SortRule::New: session_.catalog.sort_rule() = SortRule::Old; break;
Expand All @@ -112,8 +110,8 @@ void CatalogController::cycle_sort_rule()
}
sort_apps(session_.catalog.apps(), session_.catalog.sort_rule());
session_.catalog.rebuild_visible();
if (!select_visible_app_by_id(selected_id)) session_.catalog.selected_index() = 0;
session_.status.value().clear();
session_.catalog.selected_index() = 0;
session_.status.value() = "Sort: " + sort_rule_label(session_.catalog.sort_rule());
}

void CatalogController::apply_summary(const SummaryData &summary)
Expand Down
1 change: 1 addition & 0 deletions tests/test_appstore_input_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ bool can_upgrade_app(const StoreApp &app)
std::string backend_error_message(const std::string &output) { return output; }
std::string sync_status_message(const std::string &) { return "Catalog synced"; }
void sort_apps(std::vector<StoreApp> &, SortRule) {}
std::string sort_rule_label(SortRule) { return ""; }

} // namespace appstore

Expand Down
1 change: 1 addition & 0 deletions tests/test_appstore_request_coordinator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ std::string one_line(std::string value, size_t max_len)
}
std::string match_key(std::string value) { return value; }
void sort_apps(std::vector<StoreApp> &, SortRule) {}
std::string sort_rule_label(SortRule) { return ""; }
std::vector<std::string> wrap_display_text(std::string text, int) { return {std::move(text)}; }
bool has_blocking_missing(const std::string &missing) { return !missing.empty(); }
std::string missing_install_message(const std::string &) { return "Missing dependencies"; }
Expand Down
8 changes: 7 additions & 1 deletion tests/test_catalog_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ void sort_apps(std::vector<StoreApp> &apps, SortRule rule)
});
}

std::string sort_rule_label(SortRule rule)
{
return rule == SortRule::New ? "Newest first" : "other";
}

} // namespace appstore

int main()
Expand Down Expand Up @@ -83,7 +88,8 @@ int main()
assert(controller.select_visible_app_by_id("b-id"));
controller.cycle_sort_rule();
assert(session.catalog.sort_rule() == appstore::SortRule::New);
assert(session.catalog.selected_app()->id == "b-id");
assert(session.status.value() == "Sort: Newest first");
assert(session.catalog.selected_index() == 0);

controller.open_share_code(1000);
share_code.input() = "aaaa";
Expand Down