update
This commit is contained in:
@@ -281,18 +281,33 @@ pub async fn get_group(id: String, state: State<'_, Nostr>) -> Result<String, St
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn get_all_groups(id: String, state: State<'_, Nostr>) -> Result<Vec<RichEvent>, String> {
|
||||
pub async fn get_all_newsfeeds(
|
||||
id: String,
|
||||
state: State<'_, Nostr>,
|
||||
) -> Result<Vec<RichEvent>, String> {
|
||||
let client = &state.client;
|
||||
let public_key = PublicKey::parse(&id).map_err(|e| e.to_string())?;
|
||||
let filter = Filter::new().kind(Kind::FollowSet).author(public_key);
|
||||
|
||||
match client
|
||||
.fetch_events(vec![filter], Some(Duration::from_secs(3)))
|
||||
let groups = Filter::new().kind(Kind::FollowSet).author(public_key);
|
||||
let contacts = Filter::new()
|
||||
.kind(Kind::ContactList)
|
||||
.author(public_key)
|
||||
.limit(1);
|
||||
|
||||
let remote_events = client
|
||||
.fetch_events(vec![groups], Some(Duration::from_secs(3)))
|
||||
.await
|
||||
{
|
||||
Ok(events) => Ok(process_event(client, events, false).await),
|
||||
Err(e) => Err(e.to_string()),
|
||||
}
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let contact_events = client
|
||||
.fetch_events(vec![contacts], Some(Duration::from_secs(3)))
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let events = remote_events.merge(contact_events);
|
||||
let alt_events = process_event(client, events, false).await;
|
||||
|
||||
Ok(alt_events)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
@@ -47,7 +47,17 @@ pub async fn create_column(
|
||||
main_window: Window,
|
||||
) -> Result<String, String> {
|
||||
match app_handle.get_webview(&column.label) {
|
||||
Some(_) => Ok(column.label),
|
||||
Some(webview) => {
|
||||
if let Err(e) = webview.set_size(LogicalSize::new(column.width, column.height)) {
|
||||
return Err(e.to_string());
|
||||
}
|
||||
|
||||
if let Err(e) = webview.set_position(LogicalPosition::new(column.x, column.y)) {
|
||||
return Err(e.to_string());
|
||||
}
|
||||
|
||||
Ok(column.label)
|
||||
}
|
||||
None => {
|
||||
let path = PathBuf::from(column.url);
|
||||
let webview_url = WebviewUrl::App(path);
|
||||
@@ -145,28 +155,15 @@ pub async fn close_column(label: String, app_handle: tauri::AppHandle) -> Result
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn update_column(
|
||||
label: String,
|
||||
width: f32,
|
||||
height: f32,
|
||||
x: f32,
|
||||
y: f32,
|
||||
app_handle: tauri::AppHandle,
|
||||
) -> Result<(), String> {
|
||||
match app_handle.get_webview(&label) {
|
||||
Some(webview) => {
|
||||
if let Err(e) = webview.set_size(LogicalSize::new(width, height)) {
|
||||
return Err(e.to_string());
|
||||
}
|
||||
pub async fn close_all_columns(app_handle: tauri::AppHandle) -> Result<(), String> {
|
||||
let mut webviews = app_handle.webviews();
|
||||
webviews.remove("main");
|
||||
|
||||
if let Err(e) = webview.set_position(LogicalPosition::new(x, y)) {
|
||||
return Err(e.to_string());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
None => Err("Cannot update, column not found.".into()),
|
||||
for webview in webviews.values() {
|
||||
webview.close().unwrap()
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
Reference in New Issue
Block a user