Skip to content

Commit

Permalink
fix - limit instances to a maximum of 30
Browse files Browse the repository at this point in the history
  • Loading branch information
mormaer committed Sep 18, 2023
1 parent 8f1f9a9 commit d57fb4f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Mlem/Views/Shared/Accounts/Instance Picker View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ struct InstancePickerView: View {
@State var instances: [InstanceMetadata]?

/// Instances currently accepting new users
var filteredInstances: [InstanceMetadata]? {
var filteredInstances: ArraySlice<InstanceMetadata>? {
instances?
.filter { instance in
instance.newUsers
}
.sorted(by: { $0.users > $1.users }) // remote source is already sorted by user count but that may change...
.filter(\.newUsers) // restrict the list to instances who are accepting new users
.prefix(30) // limit to a maximum of 30
}

let onboarding: Bool

var body: some View {
ScrollView {
LazyVStack(spacing: 0) {
VStack(spacing: .zero) {
if onboarding {
Text(pickInstance)
.frame(maxWidth: .infinity)
Expand All @@ -38,7 +38,7 @@ struct InstancePickerView: View {

if let filteredInstances {
ForEach(filteredInstances) { instance in
VStack(spacing: 0) {
VStack(spacing: .zero) {
Divider()

InstanceSummary(
Expand Down

0 comments on commit d57fb4f

Please sign in to comment.