timeline: add TimelineKind equality

we will be using these for tests

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2024-11-13 10:52:14 -08:00
parent 9801a20429
commit 19d790fce0

View File

@@ -8,13 +8,13 @@ use nostrdb::{Ndb, Transaction};
use std::fmt::Display; use std::fmt::Display;
use tracing::{error, warn}; use tracing::{error, warn};
#[derive(Clone, Debug)] #[derive(Clone, Debug, PartialEq, Eq)]
pub enum PubkeySource { pub enum PubkeySource {
Explicit(Pubkey), Explicit(Pubkey),
DeckAuthor, DeckAuthor,
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum ListKind { pub enum ListKind {
Contact(PubkeySource), Contact(PubkeySource),
} }
@@ -27,7 +27,7 @@ pub enum ListKind {
/// - filter /// - filter
/// - ... etc /// - ... etc
/// ///
#[derive(Debug, Clone)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum TimelineKind { pub enum TimelineKind {
List(ListKind), List(ListKind),
@@ -58,10 +58,18 @@ impl TimelineKind {
TimelineKind::List(ListKind::Contact(pk)) TimelineKind::List(ListKind::Contact(pk))
} }
pub fn is_contacts(&self) -> bool {
matches!(self, TimelineKind::List(ListKind::Contact(_)))
}
pub fn profile(pk: PubkeySource) -> Self { pub fn profile(pk: PubkeySource) -> Self {
TimelineKind::Profile(pk) TimelineKind::Profile(pk)
} }
pub fn is_notifications(&self) -> bool {
matches!(self, TimelineKind::Notifications(_))
}
pub fn notifications(pk: PubkeySource) -> Self { pub fn notifications(pk: PubkeySource) -> Self {
TimelineKind::Notifications(pk) TimelineKind::Notifications(pk)
} }