diff --git a/Notes/Views/Notes/NotesListView.swift b/Notes/Views/Notes/NotesListView.swift index ee15156..30c4441 100644 --- a/Notes/Views/Notes/NotesListView.swift +++ b/Notes/Views/Notes/NotesListView.swift @@ -55,7 +55,7 @@ struct NotesListView: View { } Section("All notes") { - ForEach(notes) { note in + ForEach(orderedNotes) { note in row(note) } } @@ -71,11 +71,23 @@ struct NotesListView: View { } } + /// In-flight notes (transcription still pending) float to the top; + /// everything else stays newest-first. + private var orderedNotes: [NoteEntity] { + notes.filter(isInFlight) + notes.filter { !isInFlight($0) } + } + + private func isInFlight(_ note: NoteEntity) -> Bool { + note.audio?.transcriptionStatus == .pending + } + private func row(_ note: NoteEntity) -> some View { Button { editingNote = note } label: { NoteRowView(note: note) + .frame(maxWidth: .infinity, alignment: .leading) + .contentShape(Rectangle()) } .buttonStyle(.plain) .swipeActions(edge: .trailing) {