Sort presets by title.
This commit is contained in:
1 file changed
+6
@@ -53,6 +53,7 @@ extension PresetManager.Error: LocalizedError {
|
||||
throw Error.alreadyExists
|
||||
}
|
||||
presets.append(newElement)
|
||||
sort()
|
||||
postNotification()
|
||||
}
|
||||
|
||||
@@ -67,6 +68,10 @@ extension PresetManager.Error: LocalizedError {
|
||||
return presets.filter { $0.title == name }.first
|
||||
}
|
||||
|
||||
private func sort() {
|
||||
presets.sort { return $0.title.localizedCompare($1.title) == ComparisonResult.orderedAscending }
|
||||
}
|
||||
|
||||
private func postNotification() {
|
||||
NotificationCenter.default.post(name: updateNotification, object: self)
|
||||
}
|
||||
@@ -138,6 +143,7 @@ extension PresetManager.Error: LocalizedError {
|
||||
}
|
||||
catch {}
|
||||
}
|
||||
sort()
|
||||
}
|
||||
|
||||
private func save(preset: Preset, to url: URL) throws {
|
||||
|
||||
Reference in new issue
Block a user