final design (#184)

* feat: redesign

* feat: update other columns to new design

* chore: small fixes

* fix: better manage external webview

* feat: redesign note

* feat: update ui

* chore: update

* chore: update

* chore: polish ui

* chore: update auth ui

* feat: finalize note design

* chore: small fixes

* feat: add window management in rust

* chore: format

* feat: update ui for event screen

* feat: update event screen

* feat: final
This commit is contained in:
雨宮蓮
2024-05-03 15:15:48 +07:00
committed by GitHub
parent 61d1f095d4
commit a4aef25adb
250 changed files with 9360 additions and 9235 deletions

View File

@@ -1,4 +1,8 @@
use std::path::PathBuf;
use tauri::utils::config::WindowEffectsConfig;
use tauri::window::Effect;
use tauri::TitleBarStyle;
use tauri::WebviewWindowBuilder;
use tauri::{LogicalPosition, LogicalSize, Manager, WebviewUrl};
#[tauri::command]
@@ -19,6 +23,8 @@ pub fn create_column(
let webview_url = WebviewUrl::App(path);
let builder = tauri::webview::WebviewBuilder::new(label, webview_url)
.user_agent("Lume/4.0")
.zoom_hotkeys_enabled(true)
.enable_clipboard_access()
.transparent(true);
match main_window.add_child(
builder,
@@ -79,9 +85,54 @@ pub fn resize_column(
if let Ok(_) = webview.set_size(LogicalSize::new(width, height)) {
Ok(())
} else {
Err("Reposition column failed".into())
Err("Resize column failed".into())
}
}
None => Err("Webview not found".into()),
}
}
#[tauri::command]
pub fn open_window(
label: &str,
title: &str,
url: &str,
width: f64,
height: f64,
app_handle: tauri::AppHandle,
) -> Result<(), String> {
if let Some(window) = app_handle.get_window(label) {
if window.is_visible().unwrap_or_default() {
let _ = window.set_focus();
} else {
let _ = window.show();
let _ = window.set_focus();
};
} else {
#[cfg(target_os = "macos")]
let _ = WebviewWindowBuilder::new(&app_handle, label, WebviewUrl::App(PathBuf::from(url)))
.title(title)
.min_inner_size(width, height)
.inner_size(width, height)
.hidden_title(true)
.title_bar_style(TitleBarStyle::Overlay)
.transparent(true)
.effects(WindowEffectsConfig {
state: None,
effects: vec![Effect::WindowBackground],
radius: None,
color: None,
})
.build()
.unwrap();
#[cfg(not(target_os = "macos"))]
let _ = WebviewWindowBuilder::new(&app_handle, label, WebviewUrl::App(PathBuf::from(url)))
.title(title)
.min_inner_size(width, height)
.inner_size(width, height)
.build()
.unwrap();
}
Ok(())
}

View File

@@ -55,17 +55,17 @@ fn main() {
// Add some bootstrap relays
// #TODO: Pull bootstrap relays from user's settings
client
.add_relay("wss://relay.damus.io")
.add_relay("wss://relay.nostr.net")
.await
.expect("Cannot connect to relay.damus.io, please try again later.");
client
.add_relay("wss://relayable.org")
.await
.expect("Cannot connect to relayable.org, please try again later.");
.expect("Cannot connect to relay.nostr.net, please try again later.");
client
.add_relay("wss://relay.nostr.band")
.await
.expect("Cannot connect to relay.nostr.band, please try again later.");
client
.add_relay("wss://welcome.nostr.wine")
.await
.expect("Cannot connect to welcome.nostr.wine, please try again later.");
// Connect
client.connect().await;
@@ -140,7 +140,8 @@ fn main() {
commands::window::create_column,
commands::window::close_column,
commands::window::reposition_column,
commands::window::resize_column
commands::window::resize_column,
commands::window::open_window
])
.run(tauri::generate_context!())
.expect("error while running tauri application")

View File

@@ -57,11 +57,8 @@ pub async fn get_events_from(
.authors(vec![author])
.limit(limit)
.until(until);
let _ = client
.reconcile(filter.clone(), NegentropyOptions::default())
.await;
match client.database().query(vec![filter], Order::Asc).await {
match client.get_events_of(vec![filter], None).await {
Ok(events) => Ok(events),
Err(err) => Err(err.to_string()),
}
@@ -127,13 +124,10 @@ pub async fn get_events(
let filter = Filter::new()
.kinds(vec![Kind::TextNote, Kind::Repost])
.limit(limit)
.authors(val)
.authors(val.clone())
.until(as_of);
let _ = client
.reconcile(filter.clone(), NegentropyOptions::default())
.await;
match client.database().query(vec![filter], Order::Asc).await {
match client.get_events_of(vec![filter], None).await {
Ok(events) => Ok(events),
Err(err) => Err(err.to_string()),
}
@@ -162,11 +156,8 @@ pub async fn get_events_from_interests(
.limit(limit)
.until(as_of)
.hashtags(hashtags);
let _ = client
.reconcile(filter.clone(), NegentropyOptions::default())
.await;
match client.database().query(vec![filter], Order::Asc).await {
match client.get_events_of(vec![filter], None).await {
Ok(events) => Ok(events),
Err(err) => Err(err.to_string()),
}
@@ -179,14 +170,8 @@ pub async fn get_event_thread(id: &str, state: State<'_, Nostr>) -> Result<Vec<E
match EventId::from_hex(id) {
Ok(event_id) => {
let filter = Filter::new().kinds(vec![Kind::TextNote]).event(event_id);
let _ = client
.reconcile(filter.clone(), NegentropyOptions::default())
.await;
match client
.get_events_of(vec![filter], Some(Duration::from_secs(10)))
.await
{
match client.get_events_of(vec![filter], None).await {
Ok(events) => Ok(events),
Err(err) => Err(err.to_string()),
}

View File

@@ -172,6 +172,22 @@ pub async fn load_selected_account(npub: &str, state: State<'_, Nostr>) -> Resul
client.set_signer(Some(signer)).await;
}
// Verify signer
let signer = client.signer().await.unwrap();
// Get public key
let public_key = signer.public_key().await.unwrap();
let filter = Filter::new().pubkey(public_key).limit(200).kinds(vec![
Kind::TextNote,
Kind::Repost,
Kind::ZapReceipt,
Kind::EncryptedDirectMessage,
Kind::SealedDirect,
]);
// Setup negentropy for user's activity
let _ = client.reconcile(filter, NegentropyOptions::default()).await;
Ok(true)
}
Err(err) => Err(err.to_string()),

View File

@@ -128,6 +128,7 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
.title("Settings")
.inner_size(800., 500.)
.title_bar_style(TitleBarStyle::Overlay)
.hidden_title(true)
.resizable(false)
.minimizable(false)
.build()