From 34657540de3a604f566c18fe6bb6e5e0fe2f07e8 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Sun, 22 Sep 2024 16:48:15 +0200 Subject: [PATCH] refactor: remove Tasks to TasksRelay --- src/main.rs | 6 +++--- src/tasks.rs | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 05f6c53..f0aa13b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,7 +30,7 @@ use xdg::BaseDirectories; use crate::helpers::*; use crate::kinds::{BASIC_KINDS, PROPERTY_COLUMNS, PROP_KINDS, TRACKING_KIND}; use crate::task::{State, MARKER_DEPENDS}; -use crate::tasks::{PropertyCollection, StateFilter, Tasks}; +use crate::tasks::{PropertyCollection, StateFilter, TasksRelay}; mod helpers; mod task; @@ -251,8 +251,8 @@ async fn main() -> Result<()> { let moved_metadata = metadata.clone(); let (tx, mut rx) = mpsc::channel::(64); - let tasks_for_url = |url: Option| Tasks::from(url, &tx, &keys, metadata.clone()); - let mut relays: HashMap, Tasks> = + let tasks_for_url = |url: Option| TasksRelay::from(url, &tx, &keys, metadata.clone()); + let mut relays: HashMap, TasksRelay> = client.relays().await.into_keys().map(|url| (Some(url.clone()), tasks_for_url(Some(url)))).collect(); let sender = tokio::spawn(async move { diff --git a/src/tasks.rs b/src/tasks.rs index 2d53ee0..805a00b 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -46,7 +46,7 @@ impl TaskMapMethods for TaskMap { } #[derive(Debug, Clone)] -pub(crate) struct Tasks { +pub(crate) struct TasksRelay { /// The Tasks tasks: TaskMap, /// History of active tasks by PubKey @@ -124,7 +124,7 @@ impl Display for StateFilter { } } -impl Tasks { +impl TasksRelay { pub(crate) fn from( url: Option, tx: &Sender, @@ -137,7 +137,7 @@ impl Tasks { } pub(crate) fn with_sender(sender: EventSender) -> Self { - Tasks { + TasksRelay { tasks: Default::default(), history: Default::default(), users: Default::default(), @@ -1278,7 +1278,7 @@ impl<'a> ChildIterator<'a> { } } - fn from(tasks: &'a Tasks, id: &'a EventId) -> Self { + fn from(tasks: &'a TasksRelay, id: &'a EventId) -> Self { let mut queue = Vec::with_capacity(30); queue.push(id); ChildIterator { @@ -1424,12 +1424,12 @@ mod tasks_test { use super::*; - fn stub_tasks() -> Tasks { + fn stub_tasks() -> TasksRelay { use tokio::sync::mpsc; use nostr_sdk::Keys; let (tx, _rx) = mpsc::channel(16); - Tasks::with_sender(EventSender { + TasksRelay::with_sender(EventSender { url: None, tx, keys: Keys::generate(),