fix: Save and apply profile icon if it hasn't been applied yet
Icon saving was not working in situations where profile.Name had not changed.
This commit is contained in:
@@ -538,13 +538,14 @@ func (profile *Profile) updateMetadataFromSystem(ctx context.Context, md Matchin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply new icon if found.
|
// Apply new icon if found.
|
||||||
if newIcon != nil {
|
if newIcon != nil && !profile.iconExists(newIcon) {
|
||||||
if len(profile.Icons) == 0 {
|
if len(profile.Icons) == 0 {
|
||||||
profile.Icons = []binmeta.Icon{*newIcon}
|
profile.Icons = []binmeta.Icon{*newIcon}
|
||||||
} else {
|
} else {
|
||||||
profile.Icons = append(profile.Icons, *newIcon)
|
profile.Icons = append(profile.Icons, *newIcon)
|
||||||
profile.Icons = binmeta.SortAndCompactIcons(profile.Icons)
|
profile.Icons = binmeta.SortAndCompactIcons(profile.Icons)
|
||||||
}
|
}
|
||||||
|
changed = true
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@@ -559,3 +560,13 @@ func (profile *Profile) updateMetadataFromSystem(ctx context.Context, md Matchin
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks if the given icon already assigned to the profile.
|
||||||
|
func (profile *Profile) iconExists(newIcon *binmeta.Icon) bool {
|
||||||
|
for _, icon := range profile.Icons {
|
||||||
|
if icon.Value == newIcon.Value && icon.Type == newIcon.Type && icon.Source == newIcon.Source {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user