mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2024-12-22 22:28:35 +01:00
chore: update sort direction and add comments
This commit is contained in:
parent
f78da37915
commit
b64b88883e
@ -109,7 +109,7 @@
|
||||
<key>MastodonIntent.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>26</integer>
|
||||
<integer>21</integer>
|
||||
</dict>
|
||||
<key>MastodonIntents.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
@ -124,12 +124,12 @@
|
||||
<key>NotificationService.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>27</integer>
|
||||
<integer>19</integer>
|
||||
</dict>
|
||||
<key>ShareActionExtension.xcscheme_^#shared#^_</key>
|
||||
<dict>
|
||||
<key>orderHint</key>
|
||||
<integer>28</integer>
|
||||
<integer>20</integer>
|
||||
</dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
|
@ -115,8 +115,11 @@ extension MastodonPickServerViewModel {
|
||||
if self.mode == .signUp {
|
||||
indexedServers = indexedServers.filter { !$0.approvalRequired }
|
||||
}
|
||||
// Note:
|
||||
// sort by calculate last week users count
|
||||
// and make medium size (~800) server to top
|
||||
|
||||
// group by language user preferred language first. Then sort by `totalUsers`
|
||||
// group by language user preferred language first
|
||||
var languageToServersMapping = OrderedDictionary<String, [Mastodon.Entity.Server]>()
|
||||
for language in Locale.preferredLanguages {
|
||||
let local = Locale(identifier: language)
|
||||
@ -129,10 +132,10 @@ extension MastodonPickServerViewModel {
|
||||
.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
|
||||
return lhValue < rhValue
|
||||
})
|
||||
}
|
||||
// sort remains servers by `totalUsers`
|
||||
// sort remains servers
|
||||
let remainsServers = indexedServers
|
||||
.filter { server in
|
||||
return !languageToServersMapping.contains { _, servers in servers.contains(server) }
|
||||
@ -140,7 +143,7 @@ extension MastodonPickServerViewModel {
|
||||
.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
|
||||
return lhValue < rhValue
|
||||
})
|
||||
|
||||
var _indexedServers: [Mastodon.Entity.Server] = []
|
||||
|
Loading…
Reference in New Issue
Block a user