add Repost to composite unit & fragment
Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ impl NoteUnit {
|
|||||||
NoteUnit::Single(note_ref) => note_ref,
|
NoteUnit::Single(note_ref) => note_ref,
|
||||||
NoteUnit::Composite(clustered) => match clustered {
|
NoteUnit::Composite(clustered) => match clustered {
|
||||||
CompositeUnit::Reaction(reaction_entry) => &reaction_entry.note_reacted_to,
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum CompositeUnit {
|
pub enum CompositeUnit {
|
||||||
Reaction(ReactionUnit),
|
Reaction(ReactionUnit),
|
||||||
|
Repost(RepostUnit),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompositeUnit {
|
impl CompositeUnit {
|
||||||
pub fn get_latest_ref(&self) -> &NoteRef {
|
pub fn get_latest_ref(&self) -> &NoteRef {
|
||||||
match self {
|
match self {
|
||||||
CompositeUnit::Reaction(reaction_unit) => reaction_unit.get_latest_ref(),
|
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 {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(Self::Reaction(l0), Self::Reaction(r0)) => l0 == r0,
|
(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,
|
key: reaction_entry.note_reacted_to.key,
|
||||||
composite_type: CompositeType::Reaction,
|
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) => {
|
CompositeFragment::Reaction(reaction_fragment) => {
|
||||||
CompositeUnit::Reaction(reaction_fragment.into())
|
CompositeUnit::Reaction(reaction_fragment.into())
|
||||||
}
|
}
|
||||||
|
CompositeFragment::Repost(repost_fragment) => {
|
||||||
|
CompositeUnit::Repost(repost_fragment.into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,15 +186,28 @@ pub enum NoteUnitFragment {
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum CompositeFragment {
|
pub enum CompositeFragment {
|
||||||
Reaction(ReactionFragment),
|
Reaction(ReactionFragment),
|
||||||
|
Repost(RepostFragment),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompositeFragment {
|
impl CompositeFragment {
|
||||||
pub fn fold_into(self, unit: &mut CompositeUnit) {
|
pub fn fold_into(self, unit: &mut CompositeUnit) {
|
||||||
match self {
|
match self {
|
||||||
CompositeFragment::Reaction(reaction_fragment) => {
|
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);
|
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,
|
key: reaction.noteref_reacted_to.key,
|
||||||
composite_type: CompositeType::Reaction,
|
composite_type: CompositeType::Reaction,
|
||||||
},
|
},
|
||||||
|
CompositeFragment::Repost(repost) => CompositeKey {
|
||||||
|
key: repost.reposted_noteref.key,
|
||||||
|
composite_type: CompositeType::Repost,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_underlying_noteref(&self) -> &NoteRef {
|
pub fn get_underlying_noteref(&self) -> &NoteRef {
|
||||||
match self {
|
match self {
|
||||||
CompositeFragment::Reaction(reaction_fragment) => &reaction_fragment.noteref_reacted_to,
|
CompositeFragment::Reaction(reaction_fragment) => &reaction_fragment.noteref_reacted_to,
|
||||||
|
CompositeFragment::Repost(repost_fragment) => &repost_fragment.reposted_noteref,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_latest_ref(&self) -> &NoteRef {
|
pub fn get_latest_ref(&self) -> &NoteRef {
|
||||||
match self {
|
match self {
|
||||||
CompositeFragment::Reaction(reaction_fragment) => &reaction_fragment.reaction_note_ref,
|
CompositeFragment::Reaction(reaction_fragment) => &reaction_fragment.reaction_note_ref,
|
||||||
|
CompositeFragment::Repost(repost_fragment) => &repost_fragment.repost_noteref,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_type(&self) -> CompositeType {
|
pub fn get_type(&self) -> CompositeType {
|
||||||
match self {
|
match self {
|
||||||
CompositeFragment::Reaction(_) => CompositeType::Reaction,
|
CompositeFragment::Reaction(_) => CompositeType::Reaction,
|
||||||
|
CompositeFragment::Repost(_) => CompositeType::Repost,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -460,6 +460,15 @@ impl<'a, 'd> TimelineTabView<'a, 'd> {
|
|||||||
self.txn,
|
self.txn,
|
||||||
reaction_unit,
|
reaction_unit,
|
||||||
),
|
),
|
||||||
|
CompositeUnit::Repost(repost_unit) => render_repost_cluster(
|
||||||
|
ui,
|
||||||
|
self.note_context,
|
||||||
|
self.note_options,
|
||||||
|
self.jobs,
|
||||||
|
mute,
|
||||||
|
self.txn,
|
||||||
|
repost_unit,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user