Skip to content

Commit

Permalink
qml: FirmwareUpdate: Sort firmware by version
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
  • Loading branch information
patrickelectric committed Apr 20, 2023
1 parent cc70609 commit 8979c86
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion qml/FirmwareUpdate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,22 @@ RowLayout {
PingComboBox {
id: fwCombo

function sortPingFiles(firmwares) {
return Object.keys(firmwares).sort((first, second) => {
const regex = /Ping[-_](V\d+\.\d+)/i;
const firstMatch = first.match(regex);
const secondMatch = second.match(regex);
const firstVersion = firstMatch ? firstMatch[1] : "V0.0";
const secondVersion = secondMatch ? secondMatch[1] : "V0.0";
return secondVersion.localeCompare(firstVersion, undefined, {
"numeric": true,
"sensitivity": 'base'
});
});
}

visible: automaticUpdateCB.currentIndex === 0
model: ping && ping.firmwaresAvailable ? Object.keys(ping.firmwaresAvailable) : []
model: ping && ping.firmwaresAvailable ? sortPingFiles(ping.firmwaresAvailable) : []
Layout.minimumWidth: 220
}

Expand Down

0 comments on commit 8979c86

Please sign in to comment.