commit 19d790fce037e0826fb3e34363ff52cea791a4a6
parent 9801a204290a6aaacd806e7f76f90610fa07594b
Author: William Casarin <jb55@jb55.com>
Date: Wed, 13 Nov 2024 10:52:14 -0800
timeline: add TimelineKind equality
we will be using these for tests
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/timeline/kind.rs b/src/timeline/kind.rs
@@ -8,13 +8,13 @@ use nostrdb::{Ndb, Transaction};
use std::fmt::Display;
use tracing::{error, warn};
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, PartialEq, Eq)]
pub enum PubkeySource {
Explicit(Pubkey),
DeckAuthor,
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ListKind {
Contact(PubkeySource),
}
@@ -27,7 +27,7 @@ pub enum ListKind {
/// - filter
/// - ... etc
///
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq, Eq)]
pub enum TimelineKind {
List(ListKind),
@@ -58,10 +58,18 @@ impl TimelineKind {
TimelineKind::List(ListKind::Contact(pk))
}
+ pub fn is_contacts(&self) -> bool {
+ matches!(self, TimelineKind::List(ListKind::Contact(_)))
+ }
+
pub fn profile(pk: PubkeySource) -> Self {
TimelineKind::Profile(pk)
}
+ pub fn is_notifications(&self) -> bool {
+ matches!(self, TimelineKind::Notifications(_))
+ }
+
pub fn notifications(pk: PubkeySource) -> Self {
TimelineKind::Notifications(pk)
}