feat: readd for you column
This commit is contained in:
@@ -6,12 +6,12 @@
|
||||
"windows": [
|
||||
"main",
|
||||
"splash",
|
||||
"editor",
|
||||
"settings",
|
||||
"nwc",
|
||||
"zap-*",
|
||||
"event-*",
|
||||
"user-*",
|
||||
"editor-*",
|
||||
"column-*"
|
||||
],
|
||||
"permissions": [
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","splash","editor","settings","nwc","zap-*","event-*","user-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging","window:allow-create","window:allow-close","store:allow-get","clipboard-manager:allow-write","clipboard-manager:allow-read","webview:allow-create-webview-window","webview:allow-create-webview","webview:allow-set-webview-size","webview:allow-set-webview-position","webview:allow-webview-close","dialog:allow-open","fs:allow-read-file","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}}
|
||||
{"desktop-capability":{"identifier":"desktop-capability","description":"Capability for the desktop","local":true,"windows":["main","splash","settings","nwc","zap-*","event-*","user-*","editor-*","column-*"],"permissions":["path:default","event:default","window:default","app:default","resources:default","menu:default","tray:default","notification:allow-is-permission-granted","notification:allow-request-permission","notification:default","os:allow-locale","os:allow-platform","updater:allow-check","updater:default","window:allow-start-dragging","window:allow-create","window:allow-close","store:allow-get","clipboard-manager:allow-write","clipboard-manager:allow-read","webview:allow-create-webview-window","webview:allow-create-webview","webview:allow-set-webview-size","webview:allow-set-webview-position","webview:allow-webview-close","dialog:allow-open","fs:allow-read-file","shell:allow-open",{"identifier":"http:default","allow":[{"url":"http://**/"},{"url":"https://**/"}]},{"identifier":"fs:allow-read-text-file","allow":[{"path":"$RESOURCE/locales/*"}]}],"platforms":["linux","macOS","windows"]}}
|
||||
@@ -126,8 +126,8 @@ fn main() {
|
||||
nostr::metadata::zap_event,
|
||||
nostr::event::get_event,
|
||||
nostr::event::get_events_from,
|
||||
nostr::event::get_local_events,
|
||||
nostr::event::get_global_events,
|
||||
nostr::event::get_events,
|
||||
nostr::event::get_events_from_interests,
|
||||
nostr::event::get_event_thread,
|
||||
nostr::event::publish,
|
||||
nostr::event::repost,
|
||||
|
||||
@@ -72,66 +72,120 @@ pub async fn get_events_from(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_local_events(
|
||||
pub async fn get_events(
|
||||
limit: usize,
|
||||
until: Option<&str>,
|
||||
contacts: Option<Vec<&str>>,
|
||||
global: Option<bool>,
|
||||
state: State<'_, Nostr>,
|
||||
) -> Result<Vec<Event>, String> {
|
||||
let client = &state.client;
|
||||
let f_until = match until {
|
||||
let as_of = match until {
|
||||
Some(until) => Timestamp::from_str(until).unwrap(),
|
||||
None => Timestamp::now(),
|
||||
};
|
||||
|
||||
let contact_list = client
|
||||
.get_contact_list_public_keys(Some(Duration::from_secs(10)))
|
||||
.await;
|
||||
|
||||
if let Ok(authors) = contact_list {
|
||||
if authors.len() == 0 {
|
||||
return Err("Get text event failed".into());
|
||||
let authors = match contacts {
|
||||
Some(val) => {
|
||||
let c: Vec<PublicKey> = val
|
||||
.into_iter()
|
||||
.map(|key| PublicKey::from_str(key).unwrap())
|
||||
.collect();
|
||||
Some(c)
|
||||
}
|
||||
|
||||
let filter = Filter::new()
|
||||
None => match global {
|
||||
Some(val) => match val {
|
||||
true => None,
|
||||
false => {
|
||||
match client
|
||||
.get_contact_list_public_keys(Some(Duration::from_secs(10)))
|
||||
.await
|
||||
{
|
||||
Ok(val) => Some(val),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
match client
|
||||
.get_contact_list_public_keys(Some(Duration::from_secs(10)))
|
||||
.await
|
||||
{
|
||||
Ok(val) => Some(val),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
let filter = match authors {
|
||||
Some(val) => Filter::new()
|
||||
.kinds(vec![Kind::TextNote, Kind::Repost])
|
||||
.authors(authors)
|
||||
.authors(val)
|
||||
.limit(limit)
|
||||
.until(f_until);
|
||||
.until(as_of),
|
||||
None => Filter::new()
|
||||
.kinds(vec![Kind::TextNote, Kind::Repost])
|
||||
.limit(limit)
|
||||
.until(as_of),
|
||||
};
|
||||
|
||||
if let Ok(events) = client
|
||||
.get_events_of(vec![filter], Some(Duration::from_secs(10)))
|
||||
.await
|
||||
{
|
||||
Ok(events)
|
||||
} else {
|
||||
Err("Get text event failed".into())
|
||||
}
|
||||
if let Ok(events) = client
|
||||
.get_events_of(vec![filter], Some(Duration::from_secs(15)))
|
||||
.await
|
||||
{
|
||||
println!("total events: {}", events.len());
|
||||
Ok(events)
|
||||
} else {
|
||||
Err("Get contact list failed".into())
|
||||
Err("Get text event failed".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_global_events(
|
||||
pub async fn get_events_from_interests(
|
||||
hashtags: Vec<&str>,
|
||||
limit: usize,
|
||||
until: Option<&str>,
|
||||
global: Option<bool>,
|
||||
state: State<'_, Nostr>,
|
||||
) -> Result<Vec<Event>, String> {
|
||||
let client = &state.client;
|
||||
let f_until = match until {
|
||||
let as_of = match until {
|
||||
Some(until) => Timestamp::from_str(until).unwrap(),
|
||||
None => Timestamp::now(),
|
||||
};
|
||||
|
||||
let filter = Filter::new()
|
||||
.kinds(vec![Kind::TextNote, Kind::Repost])
|
||||
.limit(limit)
|
||||
.until(f_until);
|
||||
let authors = match global {
|
||||
Some(val) => match val {
|
||||
true => None,
|
||||
false => {
|
||||
match client
|
||||
.get_contact_list_public_keys(Some(Duration::from_secs(10)))
|
||||
.await
|
||||
{
|
||||
Ok(val) => Some(val),
|
||||
Err(_) => None,
|
||||
}
|
||||
}
|
||||
},
|
||||
None => None,
|
||||
};
|
||||
let filter = match authors {
|
||||
Some(val) => Filter::new()
|
||||
.kinds(vec![Kind::TextNote, Kind::Repost])
|
||||
.authors(val)
|
||||
.limit(limit)
|
||||
.until(as_of)
|
||||
.hashtags(hashtags),
|
||||
None => Filter::new()
|
||||
.kinds(vec![Kind::TextNote, Kind::Repost])
|
||||
.limit(limit)
|
||||
.until(as_of)
|
||||
.hashtags(hashtags),
|
||||
};
|
||||
|
||||
if let Ok(events) = client
|
||||
.get_events_of(vec![filter], Some(Duration::from_secs(10)))
|
||||
.get_events_of(vec![filter], Some(Duration::from_secs(15)))
|
||||
.await
|
||||
{
|
||||
println!("total events: {}", events.len());
|
||||
Ok(events)
|
||||
} else {
|
||||
Err("Get text event failed".into())
|
||||
|
||||
@@ -44,14 +44,24 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
|
||||
}
|
||||
}
|
||||
"editor" => {
|
||||
let _ = WebviewWindowBuilder::new(app, "editor", WebviewUrl::App(PathBuf::from("editor")))
|
||||
.title("Editor")
|
||||
.min_inner_size(500., 400.)
|
||||
.inner_size(600., 400.)
|
||||
.hidden_title(true)
|
||||
.title_bar_style(TitleBarStyle::Overlay)
|
||||
.build()
|
||||
.unwrap();
|
||||
if let Some(window) = app.get_window("editor-0") {
|
||||
if window.is_visible().unwrap_or_default() {
|
||||
let _ = window.set_focus();
|
||||
} else {
|
||||
let _ = window.show();
|
||||
let _ = window.set_focus();
|
||||
};
|
||||
} else {
|
||||
let _ =
|
||||
WebviewWindowBuilder::new(app, "editor-0", WebviewUrl::App(PathBuf::from("editor")))
|
||||
.title("Editor")
|
||||
.min_inner_size(500., 400.)
|
||||
.inner_size(600., 400.)
|
||||
.hidden_title(true)
|
||||
.title_bar_style(TitleBarStyle::Overlay)
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
"about" => {
|
||||
app.shell().open("https://lume.nu", None).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user