From b64b88883eafaca242abe694338e21b9d474c4ac Mon Sep 17 00:00:00 2001 From: CMK Date: Fri, 29 Apr 2022 20:41:23 +0800 Subject: [PATCH] chore: update sort direction and add comments --- .../xcschemes/xcschememanagement.plist | 6 +++--- .../PickServer/MastodonPickServerViewModel.swift | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist index c71d962de..640adb736 100644 --- a/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/Mastodon.xcodeproj/xcuserdata/mainasuk.xcuserdatad/xcschemes/xcschememanagement.plist @@ -109,7 +109,7 @@ MastodonIntent.xcscheme_^#shared#^_ orderHint - 26 + 21 MastodonIntents.xcscheme_^#shared#^_ @@ -124,12 +124,12 @@ NotificationService.xcscheme_^#shared#^_ orderHint - 27 + 19 ShareActionExtension.xcscheme_^#shared#^_ orderHint - 28 + 20 SuppressBuildableAutocreation diff --git a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift index 2e4994815..749843880 100644 --- a/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift +++ b/Mastodon/Scene/Onboarding/PickServer/MastodonPickServerViewModel.swift @@ -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() 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] = []