sort highlights by createdAt

This commit is contained in:
Satindar Dhillon
2022-10-04 22:09:44 -07:00
parent 79875706e9
commit cffdfa4342
2 changed files with 18 additions and 2 deletions

View File

@ -37,7 +37,19 @@ struct HighlightsListCard: View {
}
var addNoteSection: some View {
Text("Tap to add a note")
HStack {
Image(systemName: "note.text.badge.plus").foregroundColor(.appGrayTextContrast)
Text("Add a Note")
.font(.appSubheadline)
.foregroundColor(.appGrayTextContrast)
.lineLimit(1)
Spacer()
}
.onTapGesture {
print("add a note")
}
}
var body: some View {

View File

@ -8,7 +8,11 @@ import Views
@Published var highlights = [Highlight]()
func load(item: LinkedItem) {
highlights = item.highlights.asArray(of: Highlight.self)
let unsortedHighlights = item.highlights.asArray(of: Highlight.self)
highlights = unsortedHighlights.sorted {
($0.createdAt ?? Date()) < ($1.createdAt ?? Date())
}
}
}