feat(settings): allow sorting thread replies newest first
This commit is contained in:
@@ -115,7 +115,10 @@ impl<'a, 'd> ThreadView<'a, 'd> {
|
||||
.unwrap()
|
||||
.list;
|
||||
|
||||
let notes = note_builder.into_notes(&mut self.threads.seen_flags);
|
||||
let notes = note_builder.into_notes(
|
||||
self.note_options.contains(NoteOptions::RepliesNewestFirst),
|
||||
&mut self.threads.seen_flags,
|
||||
);
|
||||
|
||||
if !full_chain {
|
||||
// TODO(kernelkind): insert UI denoting we don't have the full chain yet
|
||||
@@ -223,7 +226,11 @@ impl<'a> ThreadNoteBuilder<'a> {
|
||||
self.replies.push(note);
|
||||
}
|
||||
|
||||
pub fn into_notes(mut self, seen_flags: &mut NoteSeenFlags) -> ThreadNotes<'a> {
|
||||
pub fn into_notes(
|
||||
mut self,
|
||||
replies_newer_first: bool,
|
||||
seen_flags: &mut NoteSeenFlags,
|
||||
) -> ThreadNotes<'a> {
|
||||
let mut notes = Vec::new();
|
||||
|
||||
let selected_is_root = self.chain.is_empty();
|
||||
@@ -246,6 +253,11 @@ impl<'a> ThreadNoteBuilder<'a> {
|
||||
unread_and_have_replies: false,
|
||||
});
|
||||
|
||||
if replies_newer_first {
|
||||
self.replies
|
||||
.sort_by(|a, b| b.created_at().cmp(&a.created_at()));
|
||||
}
|
||||
|
||||
for reply in self.replies {
|
||||
notes.push(ThreadNote {
|
||||
unread_and_have_replies: *seen_flags.get(reply.id()).unwrap_or(&false),
|
||||
|
||||
Reference in New Issue
Block a user