diff --git a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift index 38f9ed42..c0abc067 100644 --- a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift +++ b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift @@ -112,9 +112,8 @@ struct TimelineTab: View { } } if !currentAccount.lists.isEmpty { - let sortedLists = currentAccount.lists.sorted { $0.title.lowercased() < $1.title.lowercased() } Menu("timeline.filter.lists") { - ForEach(sortedLists) { list in + ForEach(currentAccount.sortedLists) { list in Button { timeline = .list(list: list) } label: { @@ -125,9 +124,8 @@ struct TimelineTab: View { } if !currentAccount.tags.isEmpty { - let sortedTags = currentAccount.tags.sorted { $0.name.lowercased() < $1.name.lowercased() } Menu("timeline.filter.tags") { - ForEach(sortedTags) { tag in + ForEach(currentAccount.sortedTags) { tag in Button { timeline = .hashtag(tag: tag.name, accountId: nil) } label: { diff --git a/Packages/Account/Sources/Account/AccountDetailView.swift b/Packages/Account/Sources/Account/AccountDetailView.swift index 5568c06d..2d8c9f6a 100644 --- a/Packages/Account/Sources/Account/AccountDetailView.swift +++ b/Packages/Account/Sources/Account/AccountDetailView.swift @@ -264,7 +264,7 @@ public struct AccountDetailView: View { private var tagsListView: some View { Group { - ForEach(currentAccount.tags) { tag in + ForEach(currentAccount.sortedTags) { tag in HStack { TagRowView(tag: tag) Spacer() @@ -280,7 +280,7 @@ public struct AccountDetailView: View { private var listsListView: some View { Group { - ForEach(currentAccount.lists) { list in + ForEach(currentAccount.sortedLists) { list in NavigationLink(value: RouterDestinations.list(list: list)) { HStack { Text(list.title) diff --git a/Packages/Env/Sources/Env/CurrentAccount.swift b/Packages/Env/Sources/Env/CurrentAccount.swift index e354e1fe..ea9985af 100644 --- a/Packages/Env/Sources/Env/CurrentAccount.swift +++ b/Packages/Env/Sources/Env/CurrentAccount.swift @@ -16,6 +16,14 @@ public class CurrentAccount: ObservableObject { public static let shared = CurrentAccount() + public var sortedLists: [List] { + lists.sorted { $0.title.lowercased() < $1.title.lowercased() } + } + + public var sortedTags: [Tag] { + tags.sorted { $0.name.lowercased() < $1.name.lowercased() } + } + private init() {} public func setClient(client: Client) {