mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-27 09:21:21 +01:00
Make OPML generate in a consistent order when the Web Feed name is the same. Issue #1545
This commit is contained in:
parent
f84abb81e2
commit
7824939c30
@ -1245,10 +1245,10 @@ extension Account: OPMLRepresentable {
|
||||
|
||||
public func OPMLString(indentLevel: Int, strictConformance: Bool) -> String {
|
||||
var s = ""
|
||||
for feed in topLevelWebFeeds.sorted(by: { $0.nameForDisplay < $1.nameForDisplay }) {
|
||||
for feed in topLevelWebFeeds.sorted() {
|
||||
s += feed.OPMLString(indentLevel: indentLevel + 1, strictConformance: strictConformance)
|
||||
}
|
||||
for folder in folders!.sorted(by: { $0.nameForDisplay < $1.nameForDisplay }) {
|
||||
for folder in folders!.sorted() {
|
||||
s += folder.OPMLString(indentLevel: indentLevel + 1, strictConformance: strictConformance)
|
||||
}
|
||||
return s
|
||||
|
@ -189,7 +189,7 @@ extension Folder: OPMLRepresentable {
|
||||
|
||||
var hasAtLeastOneChild = false
|
||||
|
||||
for feed in topLevelWebFeeds.sorted(by: { $0.nameForDisplay < $1.nameForDisplay }) {
|
||||
for feed in topLevelWebFeeds.sorted() {
|
||||
s += feed.OPMLString(indentLevel: indentLevel + 1, strictConformance: strictConformance)
|
||||
hasAtLeastOneChild = true
|
||||
}
|
||||
@ -206,3 +206,14 @@ extension Folder: OPMLRepresentable {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Set
|
||||
|
||||
extension Set where Element == Folder {
|
||||
|
||||
func sorted() -> Array<Folder> {
|
||||
return sorted(by: { (folder1, folder2) -> Bool in
|
||||
return folder1.nameForDisplay.localizedStandardCompare(folder2.nameForDisplay) == .orderedAscending
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -276,4 +276,14 @@ extension Set where Element == WebFeed {
|
||||
func webFeedIDs() -> Set<String> {
|
||||
return Set<String>(map { $0.webFeedID })
|
||||
}
|
||||
|
||||
func sorted() -> Array<WebFeed> {
|
||||
return sorted(by: { (webFeed1, webFeed2) -> Bool in
|
||||
if webFeed1.nameForDisplay.localizedStandardCompare(webFeed2.nameForDisplay) == .orderedSame {
|
||||
return webFeed1.url < webFeed2.url
|
||||
}
|
||||
return webFeed1.nameForDisplay.localizedStandardCompare(webFeed2.nameForDisplay) == .orderedAscending
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user