fix(main): fetch task kinds before updates

This commit is contained in:
xeruf 2024-08-19 21:25:20 +03:00
parent c64a1fa051
commit 0296556bcd
2 changed files with 11 additions and 4 deletions

View File

@ -9,10 +9,12 @@ pub const METADATA_KIND: u16 = 0;
pub const NOTE_KIND: u16 = 1;
pub const TASK_KIND: u16 = 1621;
pub const TRACKING_KIND: u16 = 1650;
pub const KINDS: [u16; 9] = [
pub const KINDS: [u16; 3] = [
METADATA_KIND,
NOTE_KIND,
TASK_KIND,
];
pub const PROP_KINDS: [u16; 6] = [
TRACKING_KIND,
State::Open as u16,
State::Done as u16,

View File

@ -23,7 +23,7 @@ use regex::Regex;
use xdg::BaseDirectories;
use crate::helpers::*;
use crate::kinds::{KINDS, PROPERTY_COLUMNS, TRACKING_KIND};
use crate::kinds::{KINDS, PROP_KINDS, PROPERTY_COLUMNS, TRACKING_KIND};
use crate::task::{MARKER_DEPENDS, MARKER_PARENT, State};
use crate::tasks::{PropertyCollection, StateFilter, Tasks};
@ -180,14 +180,19 @@ async fn main() {
},
}
let sub_id = client.subscribe(vec![
let sub1 = client.subscribe(vec![
Filter::new().kinds(KINDS.into_iter().map(|k| Kind::from(k)))
], None).await;
info!("Subscribed with {:?}", sub_id);
info!("Subscribed to tasks with {:?}", sub1);
let mut notifications = client.notifications();
client.connect().await;
let sub2 = client.subscribe(vec![
Filter::new().kinds(PROP_KINDS.into_iter().map(|k| Kind::from(k)))
], None).await;
info!("Subscribed to updates with {:?}", sub2);
let (tx, rx) = mpsc::channel::<MostrMessage>();
let tasks_for_url = |url: Option<Url>| Tasks::from(url, &tx, &keys);
let mut relays: HashMap<Url, Tasks> =