mirror of
https://github.com/LizardByte/Sunshine.git
synced 2024-11-16 23:10:13 +00:00
feat(apps): order apps alphabetically (#3223)
Some checks are pending
CI / GitHub Env Debug (push) Waiting to run
CI / Setup Release (push) Waiting to run
CI / Setup Flatpak Matrix (push) Waiting to run
CI / Linux Flatpak (push) Blocked by required conditions
CI / Linux ${{ matrix.type }} (--appimage-build, 22.04, AppImage) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (macos, 13) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (macos, 14) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (ubuntu, latest) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (ubuntu, latest, true) (push) Blocked by required conditions
CI / Macports (macOS-${{ matrix.os_version }}) (13, true) (push) Blocked by required conditions
CI / Macports (macOS-${{ matrix.os_version }}) (14) (push) Blocked by required conditions
CI / Windows (push) Blocked by required conditions
CI Docker / Check Dockerfiles (push) Waiting to run
CI Docker / Setup Release (push) Blocked by required conditions
CI Docker / Docker${{ matrix.tag }} (push) Blocked by required conditions
CodeQL / Get language matrix (push) Waiting to run
CodeQL / Analyze (${{ matrix.name }}) (push) Blocked by required conditions
localize / Update Localization (push) Waiting to run
Build GH-Pages / update_pages (push) Waiting to run
Some checks are pending
CI / GitHub Env Debug (push) Waiting to run
CI / Setup Release (push) Waiting to run
CI / Setup Flatpak Matrix (push) Waiting to run
CI / Linux Flatpak (push) Blocked by required conditions
CI / Linux ${{ matrix.type }} (--appimage-build, 22.04, AppImage) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (macos, 13) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (macos, 14) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (ubuntu, latest) (push) Blocked by required conditions
CI / Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }}${{ matrix.release == true && ' (Release)' || '' }}) (ubuntu, latest, true) (push) Blocked by required conditions
CI / Macports (macOS-${{ matrix.os_version }}) (13, true) (push) Blocked by required conditions
CI / Macports (macOS-${{ matrix.os_version }}) (14) (push) Blocked by required conditions
CI / Windows (push) Blocked by required conditions
CI Docker / Check Dockerfiles (push) Waiting to run
CI Docker / Setup Release (push) Blocked by required conditions
CI Docker / Docker${{ matrix.tag }} (push) Blocked by required conditions
CodeQL / Get language matrix (push) Waiting to run
CodeQL / Analyze (${{ matrix.name }}) (push) Blocked by required conditions
localize / Update Localization (push) Waiting to run
Build GH-Pages / update_pages (push) Waiting to run
This commit is contained in:
parent
434b7e06ce
commit
1839d59492
@ -393,18 +393,35 @@ namespace confighttp {
|
|||||||
// Unfortunately Boost PT does not allow to directly edit the array, copy should do the trick
|
// Unfortunately Boost PT does not allow to directly edit the array, copy should do the trick
|
||||||
pt::ptree newApps;
|
pt::ptree newApps;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto &kv : apps_node) {
|
for (const auto &[k, v] : apps_node) {
|
||||||
if (i == index) {
|
if (i == index) {
|
||||||
newApps.push_back(std::make_pair("", inputTree));
|
newApps.push_back(std::make_pair("", inputTree));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
newApps.push_back(std::make_pair("", kv.second));
|
newApps.push_back(std::make_pair("", v));
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
fileTree.erase("apps");
|
fileTree.erase("apps");
|
||||||
fileTree.push_back(std::make_pair("apps", newApps));
|
fileTree.push_back(std::make_pair("apps", newApps));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort the apps array by name
|
||||||
|
std::vector<pt::ptree> apps_vector;
|
||||||
|
for (const auto &[k, v] : fileTree.get_child("apps")) {
|
||||||
|
apps_vector.push_back(v);
|
||||||
|
}
|
||||||
|
std::ranges::sort(apps_vector, [](const pt::ptree &a, const pt::ptree &b) {
|
||||||
|
return a.get<std::string>("name") < b.get<std::string>("name");
|
||||||
|
});
|
||||||
|
|
||||||
|
pt::ptree sorted_apps;
|
||||||
|
for (const auto &app : apps_vector) {
|
||||||
|
sorted_apps.push_back(std::make_pair("", app));
|
||||||
|
}
|
||||||
|
fileTree.erase("apps");
|
||||||
|
fileTree.add_child("apps", sorted_apps);
|
||||||
|
|
||||||
pt::write_json(config::stream.file_apps, fileTree);
|
pt::write_json(config::stream.file_apps, fileTree);
|
||||||
}
|
}
|
||||||
catch (std::exception &e) {
|
catch (std::exception &e) {
|
||||||
@ -447,9 +464,9 @@ namespace confighttp {
|
|||||||
// Unfortunately Boost PT does not allow to directly edit the array, copy should do the trick
|
// Unfortunately Boost PT does not allow to directly edit the array, copy should do the trick
|
||||||
pt::ptree newApps;
|
pt::ptree newApps;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (const auto &kv : apps_node) {
|
for (const auto &[k, v] : apps_node) {
|
||||||
if (i++ != index) {
|
if (i++ != index) {
|
||||||
newApps.push_back(std::make_pair("", kv.second));
|
newApps.push_back(std::make_pair("", v));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fileTree.erase("apps");
|
fileTree.erase("apps");
|
||||||
@ -591,11 +608,11 @@ namespace confighttp {
|
|||||||
try {
|
try {
|
||||||
// TODO: Input Validation
|
// TODO: Input Validation
|
||||||
pt::read_json(ss, inputTree);
|
pt::read_json(ss, inputTree);
|
||||||
for (const auto &kv : inputTree) {
|
for (const auto &[k, v] : inputTree) {
|
||||||
std::string value = inputTree.get<std::string>(kv.first);
|
std::string value = inputTree.get<std::string>(k);
|
||||||
if (value.length() == 0 || value.compare("null") == 0) continue;
|
if (value.length() == 0 || value.compare("null") == 0) continue;
|
||||||
|
|
||||||
configStream << kv.first << " = " << value << std::endl;
|
configStream << k << " = " << value << std::endl;
|
||||||
}
|
}
|
||||||
file_handler::write_file(config::sunshine.config_file.c_str(), configStream.str());
|
file_handler::write_file(config::sunshine.config_file.c_str(), configStream.str());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user