fix(17-02): handle float64 numeric values from Wails JSON deserialization

Wails deserializes JSON numbers from JavaScript as float64, not int.
All .(int) type assertions on year, track_number, and disc_number
silently failed. Add asInt() helper, replace all assertions.
This commit is contained in:
2026-03-18 07:46:29 -04:00
parent ffcdc41b0d
commit 900db2e56c
4 changed files with 40 additions and 11 deletions
+3 -3
View File
@@ -62,17 +62,17 @@ func applyTextChanges(tag *id3v2.Tag, changes TagChanges) {
tag.SetGenre(v)
}
if v, ok := changes[FieldYear].(int); ok {
if v, ok := asInt(changes[FieldYear]); ok {
tag.SetYear(strconv.Itoa(v))
}
if v, ok := changes[FieldTrackNumber].(int); ok {
if v, ok := asInt(changes[FieldTrackNumber]); ok {
trckID := tag.CommonID("Track number/Position in set")
tag.DeleteFrames(trckID)
tag.AddTextFrame(trckID, id3v2.EncodingUTF8, strconv.Itoa(v))
}
if v, ok := changes[FieldDiscNumber].(int); ok {
if v, ok := asInt(changes[FieldDiscNumber]); ok {
tposID := tag.CommonID("Part of a set")
tag.DeleteFrames(tposID)
tag.AddTextFrame(tposID, id3v2.EncodingUTF8, strconv.Itoa(v))