commit f436b49feccfee555b03ddacc146d66ed92e61d7
parent 04ce29d1ddb01b83f50e83a9f3c8b787bb6c4619
Author: kernelkind <kernelkind@gmail.com>
Date: Thu, 4 Sep 2025 15:38:59 -0400
add Repost to composite unit & fragment
Signed-off-by: kernelkind <kernelkind@gmail.com>
Diffstat:
2 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/crates/notedeck_columns/src/timeline/unit.rs b/crates/notedeck_columns/src/timeline/unit.rs
@@ -25,6 +25,7 @@ impl NoteUnit {
NoteUnit::Single(note_ref) => note_ref,
NoteUnit::Composite(clustered) => match clustered {
CompositeUnit::Reaction(reaction_entry) => &reaction_entry.note_reacted_to,
+ CompositeUnit::Repost(repost_unit) => &repost_unit.note_reposted,
},
}
}
@@ -61,12 +62,14 @@ impl PartialOrd for NoteUnit {
#[derive(Debug, Clone)]
pub enum CompositeUnit {
Reaction(ReactionUnit),
+ Repost(RepostUnit),
}
impl CompositeUnit {
pub fn get_latest_ref(&self) -> &NoteRef {
match self {
CompositeUnit::Reaction(reaction_unit) => reaction_unit.get_latest_ref(),
+ CompositeUnit::Repost(repost_unit) => repost_unit.get_latest_ref(),
}
}
}
@@ -75,6 +78,8 @@ impl PartialEq for CompositeUnit {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Reaction(l0), Self::Reaction(r0)) => l0 == r0,
+ (Self::Repost(l0), Self::Repost(r0)) => l0 == r0,
+ _ => false,
}
}
}
@@ -86,6 +91,10 @@ impl CompositeUnit {
key: reaction_entry.note_reacted_to.key,
composite_type: CompositeType::Reaction,
},
+ CompositeUnit::Repost(repost_unit) => CompositeKey {
+ key: repost_unit.note_reposted.key,
+ composite_type: CompositeType::Repost,
+ },
}
}
}
@@ -96,6 +105,9 @@ impl From<CompositeFragment> for CompositeUnit {
CompositeFragment::Reaction(reaction_fragment) => {
CompositeUnit::Reaction(reaction_fragment.into())
}
+ CompositeFragment::Repost(repost_fragment) => {
+ CompositeUnit::Repost(repost_fragment.into())
+ }
}
}
}
@@ -174,15 +186,28 @@ pub enum NoteUnitFragment {
#[derive(Debug, Clone)]
pub enum CompositeFragment {
Reaction(ReactionFragment),
+ Repost(RepostFragment),
}
impl CompositeFragment {
pub fn fold_into(self, unit: &mut CompositeUnit) {
match self {
CompositeFragment::Reaction(reaction_fragment) => {
- let CompositeUnit::Reaction(reaction_unit) = unit;
+ let CompositeUnit::Reaction(reaction_unit) = unit else {
+ tracing::error!("Attempting to fold a reaction fragment into a unit which isn't ReactionUnit. Doing nothing, this should never occur");
+ return;
+ };
+
reaction_fragment.fold_into(reaction_unit);
}
+ CompositeFragment::Repost(repost_fragment) => {
+ let CompositeUnit::Repost(repost_unit) = unit else {
+ tracing::error!("Attempting to fold a repost fragment into a unit which isn't RepostUnit. Doing nothing, this should never occur");
+ return;
+ };
+
+ repost_fragment.fold_into(repost_unit);
+ }
}
}
@@ -192,24 +217,31 @@ impl CompositeFragment {
key: reaction.noteref_reacted_to.key,
composite_type: CompositeType::Reaction,
},
+ CompositeFragment::Repost(repost) => CompositeKey {
+ key: repost.reposted_noteref.key,
+ composite_type: CompositeType::Repost,
+ },
}
}
pub fn get_underlying_noteref(&self) -> &NoteRef {
match self {
CompositeFragment::Reaction(reaction_fragment) => &reaction_fragment.noteref_reacted_to,
+ CompositeFragment::Repost(repost_fragment) => &repost_fragment.reposted_noteref,
}
}
pub fn get_latest_ref(&self) -> &NoteRef {
match self {
CompositeFragment::Reaction(reaction_fragment) => &reaction_fragment.reaction_note_ref,
+ CompositeFragment::Repost(repost_fragment) => &repost_fragment.repost_noteref,
}
}
pub fn get_type(&self) -> CompositeType {
match self {
CompositeFragment::Reaction(_) => CompositeType::Reaction,
+ CompositeFragment::Repost(_) => CompositeType::Repost,
}
}
}
diff --git a/crates/notedeck_columns/src/ui/timeline.rs b/crates/notedeck_columns/src/ui/timeline.rs
@@ -460,6 +460,15 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
self.txn,
reaction_unit,
),
+ CompositeUnit::Repost(repost_unit) => render_repost_cluster(
+ ui,
+ self.note_context,
+ self.note_options,
+ self.jobs,
+ mute,
+ self.txn,
+ repost_unit,
+ ),
},
}
}