refactor: remove Tasks to TasksRelay

This commit is contained in:
xeruf 2024-09-22 16:48:15 +02:00
parent afe3fa8670
commit 34657540de
2 changed files with 9 additions and 9 deletions

View File

@ -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::<MostrMessage>(64);
let tasks_for_url = |url: Option<Url>| Tasks::from(url, &tx, &keys, metadata.clone());
let mut relays: HashMap<Option<Url>, Tasks> =
let tasks_for_url = |url: Option<Url>| TasksRelay::from(url, &tx, &keys, metadata.clone());
let mut relays: HashMap<Option<Url>, TasksRelay> =
client.relays().await.into_keys().map(|url| (Some(url.clone()), tasks_for_url(Some(url)))).collect();
let sender = tokio::spawn(async move {

View File

@ -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<Url>,
tx: &Sender<MostrMessage>,
@ -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(),