Skip to content

Commit 20ba02e

Browse files
committed
Fix applying a tune from the archive saying it's the same as current tune
Fix: Fix applying a tune from the Tune Archive saying it's the same as the current tune
1 parent f417d09 commit 20ba02e

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

ui.qml.in

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ Item {
12381238
var result = [];
12391239
for (var i = 0; i < tuneCount; i++) {
12401240
// set the version to the current one to always pass the version check
1241-
result.push({"version": formatVersion, "settings": []});
1241+
result.push({"version": formatVersion, "settings": {}});
12421242
}
12431243

12441244
for (var i in lines) {
@@ -1249,30 +1249,29 @@ Item {
12491249
if (value) {
12501250
var key = currentLine[0];
12511251
var name;
1252-
var type;
12531252

12541253
if (key === "_name") {
12551254
result[j].name = value;
12561255
continue;
12571256
} else if (key.startsWith("double_")) {
12581257
name = key.substring(7);
1259-
type = "Double";
1258+
value = parseFloat(value);
12601259
} else if (key.startsWith("int_")) {
12611260
name = key.substring(4);
1262-
type = "Int";
1261+
value = parseInt(value);
12631262
} else if (key.startsWith("bool_")) {
12641263
name = key.substring(5);
1265-
type = "Bool";
1264+
value = !!parseInt(value);
12661265
} else if (key.startsWith("enum_")) {
12671266
name = key.substring(5);
1268-
type = "Enum";
1267+
value = parseInt(value);
12691268
}
12701269

1271-
result[j].settings.push({
1272-
"name": name,
1273-
"type": type,
1274-
"value": value
1275-
});
1270+
if (Number.isNaN(value)) {
1271+
continue;
1272+
}
1273+
1274+
result[j].settings[name] = value;
12761275
}
12771276
}
12781277
}
@@ -4400,7 +4399,8 @@ Item {
44004399
open();
44014400

44024401
var tuneArchive = tuneManager.loadTuneArchive();
4403-
if (tuneArchive) {
4402+
// backwards compatibility: Check for the first item settings not being an array (if it is, redownload)
4403+
if (tuneArchive && tuneArchive.length > 0 && !Array.isArray(tuneArchive[0].settings)) {
44044404
downloadedTunesModel.setTunes(tuneArchive);
44054405
tuneArchiveDownloadStatus.text = "Tunes downloaded on %1".arg(tuneManager.getTuneArchiveDate());
44064406
} else {

0 commit comments

Comments
 (0)