forked from zelo72/mastodon-ios
feat: use new sort logic for pick server list
This commit is contained in:
parent
0b7ff6e54d
commit
484f8536ba
|
@ -126,14 +126,22 @@ extension MastodonPickServerViewModel {
|
||||||
// append to dict
|
// append to dict
|
||||||
languageToServersMapping[languageCode] = indexedServers
|
languageToServersMapping[languageCode] = indexedServers
|
||||||
.filter { $0.language.lowercased() == languageCode.lowercased() }
|
.filter { $0.language.lowercased() == languageCode.lowercased() }
|
||||||
.sorted(by: { $0.totalUsers > $1.totalUsers })
|
.sorted(by: { lh, rh in
|
||||||
|
let lhValue = abs(log2(800.0) - log2(Double(lh.lastWeekUsers)))
|
||||||
|
let rhValue = abs(log2(800.0) - log2(Double(rh.lastWeekUsers)))
|
||||||
|
return lhValue > rhValue
|
||||||
|
})
|
||||||
}
|
}
|
||||||
// sort remains servers by `totalUsers`
|
// sort remains servers by `totalUsers`
|
||||||
let remainsServers = indexedServers
|
let remainsServers = indexedServers
|
||||||
.filter { server in
|
.filter { server in
|
||||||
return !languageToServersMapping.contains { _, servers in servers.contains(server) }
|
return !languageToServersMapping.contains { _, servers in servers.contains(server) }
|
||||||
}
|
}
|
||||||
.sorted(by: { $0.totalUsers > $1.totalUsers })
|
.sorted(by: { lh, rh in
|
||||||
|
let lhValue = abs(log2(800.0) - log2(Double(lh.lastWeekUsers)))
|
||||||
|
let rhValue = abs(log2(800.0) - log2(Double(rh.lastWeekUsers)))
|
||||||
|
return lhValue > rhValue
|
||||||
|
})
|
||||||
|
|
||||||
var _indexedServers: [Mastodon.Entity.Server] = []
|
var _indexedServers: [Mastodon.Entity.Server] = []
|
||||||
for key in languageToServersMapping.keys {
|
for key in languageToServersMapping.keys {
|
||||||
|
|
Loading…
Reference in New Issue