Sort network plug-in versions newest first and mark only the loaded build

Discovered builds were inserted positionally behind the whitelist entry they
anchored to, so an OTA-installed 02.08.01.53 listed below 02.08.01.52. The list
is now built by appending and sorting once, which also drops the per-entry
insertion scans.

"(installed)" tested whether the library was present on disk, so it marked every
version ever selected - switching leaves the previous library in place. The flag
is now is_loaded, resolved against the plug-in actually loaded, and the two
combo populators share one label helper.
This commit is contained in:
SoftFever
2026-07-18 15:52:28 +08:00
parent 8b60291ed9
commit 2804e06cf2
6 changed files with 119 additions and 156 deletions

View File

@@ -205,6 +205,19 @@ void NetworkPluginDownloadDialog::create_update_available_ui(const std::string&
main_sizer->Add(0, 0, 0, wxBOTTOM, FromDIP(20));
}
wxString network_version_label(const NetworkLibraryVersionInfo& ver)
{
wxString label = wxString::FromUTF8(ver.display_name);
if (!ver.suffix.empty())
label = wxString::FromUTF8("\xE2\x94\x94 ") + label;
// Both can apply: the loaded build may also be the highest listed one.
if (ver.is_latest)
label += wxString(" ") + _L("(Latest)");
if (ver.is_loaded)
label += wxString(" ") + _L("(installed)");
return label;
}
void NetworkPluginDownloadDialog::setup_version_selector()
{
m_version_combo = new ComboBox(this, wxID_ANY, wxEmptyString,
@@ -212,24 +225,8 @@ void NetworkPluginDownloadDialog::setup_version_selector()
m_version_combo->SetFont(::Label::Body_13);
m_available_versions = get_all_available_versions();
for (size_t i = 0; i < m_available_versions.size(); ++i) {
const auto& ver = m_available_versions[i];
wxString label;
if (!ver.suffix.empty()) {
label = wxString::FromUTF8("\xE2\x94\x94 ") + wxString::FromUTF8(ver.display_name);
} else {
label = wxString::FromUTF8(ver.display_name);
}
// Same labeling as the Preferences selector: "(Latest)" = highest listed
// version, "(installed)" = library already on disk; both can apply.
if (ver.is_latest) {
label += wxString(" ") + _L("(Latest)");
}
if (ver.is_installed) {
label += wxString(" ") + _L("(installed)");
}
m_version_combo->Append(label);
}
for (const auto& ver : m_available_versions)
m_version_combo->Append(network_version_label(ver));
m_version_combo->SetSelection(0);
}