mirror of
https://github.com/lumehq/lume.git
synced 2025-10-09 22:32:42 +02:00
feat: add mock tray menu
This commit is contained in:
@@ -132,6 +132,7 @@ pub async fn load_selected_account(npub: &str, state: State<'_, Nostr>) -> Resul
|
|||||||
if let Some(event) = events.first() {
|
if let Some(event) = events.first() {
|
||||||
let list = nip65::extract_relay_list(&event);
|
let list = nip65::extract_relay_list(&event);
|
||||||
for item in list.into_iter() {
|
for item in list.into_iter() {
|
||||||
|
println!("connecting to relay: {}", item.0.to_string());
|
||||||
client
|
client
|
||||||
.connect_relay(item.0.to_string())
|
.connect_relay(item.0.to_string())
|
||||||
.await
|
.await
|
||||||
@@ -140,6 +141,9 @@ pub async fn load_selected_account(npub: &str, state: State<'_, Nostr>) -> Resul
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #TODO
|
||||||
|
// Subscribe new event for activity and local newsfeed
|
||||||
|
|
||||||
Ok(true)
|
Ok(true)
|
||||||
} else {
|
} else {
|
||||||
Err("nsec not found".into())
|
Err("nsec not found".into())
|
||||||
|
@@ -1,8 +1,32 @@
|
|||||||
use tauri::{tray::ClickType, Manager, Runtime};
|
use tauri::{Manager, Runtime};
|
||||||
|
|
||||||
pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
|
pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
|
||||||
|
let version = app.package_info().version.to_string();
|
||||||
let tray = app.tray().unwrap();
|
let tray = app.tray().unwrap();
|
||||||
let menu = tauri::menu::MenuBuilder::new(app)
|
let menu = tauri::menu::MenuBuilder::new(app)
|
||||||
|
.item(
|
||||||
|
&tauri::menu::MenuItem::with_id(app, "open_lume", "Open Lume", true, None::<&str>).unwrap(),
|
||||||
|
)
|
||||||
|
.item(&tauri::menu::MenuItem::with_id(app, "editor", "New Post", true, None::<&str>).unwrap())
|
||||||
|
.separator()
|
||||||
|
.item(
|
||||||
|
&tauri::menu::MenuItem::with_id(
|
||||||
|
app,
|
||||||
|
"version",
|
||||||
|
format!("Version {}", version),
|
||||||
|
false,
|
||||||
|
None::<&str>,
|
||||||
|
)
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.item(&tauri::menu::MenuItem::with_id(app, "about", "About Lume", true, None::<&str>).unwrap())
|
||||||
|
.item(
|
||||||
|
&tauri::menu::MenuItem::with_id(app, "update", "Check for Updates", true, None::<&str>)
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.item(
|
||||||
|
&tauri::menu::MenuItem::with_id(app, "settings", "Settings...", true, None::<&str>).unwrap(),
|
||||||
|
)
|
||||||
.item(&tauri::menu::MenuItem::with_id(app, "quit", "Quit", true, None::<&str>).unwrap())
|
.item(&tauri::menu::MenuItem::with_id(app, "quit", "Quit", true, None::<&str>).unwrap())
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@@ -16,15 +40,5 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
|
|||||||
_ => {}
|
_ => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
tray.on_tray_icon_event(|tray, event| {
|
|
||||||
if event.click_type == ClickType::Left {
|
|
||||||
let app = tray.app_handle();
|
|
||||||
if let Some(window) = app.get_webview_window("main") {
|
|
||||||
let _ = window.show();
|
|
||||||
let _ = window.set_focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user