Also sort tags and lists in profile view (#764)

* Add CurrentAccount.sortedLists and .sortedTags

Sorts alphabetically, ascending, lowercased on title and name respectively.

* TimelineTab uses CurrentAccount.sortedLists and .sortedTags

* Account detail sorts tags and lists

Alphabetically, ascending, lowercased via CurrentAccount.sortedTags, .sortedLists
This commit is contained in:
David Davies-Payne 2023-02-10 18:38:18 +13:00 committed by GitHub
parent 22b4044dfd
commit 11167c35c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View file

@ -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: {

View file

@ -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)

View file

@ -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) {