Self-hosted, federated location sharing app and server that prioritizes user privacy and security
end-to-end-encryption location-sharing privacy self-hosted federated
at android-location 44 lines 1.3 kB view raw
1use std::path::PathBuf; 2use tauri::{WebviewUrl, WebviewWindowBuilder}; 3use tauri_plugin_store::StoreBuilder; 4 5// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ 6#[tauri::command] 7fn greet(name: &str) -> String { 8 format!("Hello, {}! You've been greeted from Rust!", name) 9} 10 11#[cfg_attr(mobile, tauri::mobile_entry_point)] 12pub fn run() { 13 tauri::Builder::default() 14 .setup(|app| { 15 let app_handle = app.handle(); 16 let store_path = PathBuf::from("settings.json"); 17 let store = StoreBuilder::new(app_handle, store_path).build()?; 18 19 let user_id = store.get("user_id"); 20 21 let page = if user_id.is_some() { 22 "/src/home-page/home.html" 23 } else { 24 "/src/signup-page/signup.html" 25 }; 26 27 // create and open window directly at the correct page 28 let builder = 29 WebviewWindowBuilder::new(app_handle, "main", WebviewUrl::App(page.into())); 30 31 // only for desktop to emulate mobile size (for testing) 32 #[cfg(desktop)] 33 let builder = builder.title("privacypin").inner_size(412.0, 715.0).resizable(false); 34 35 builder.build()?; 36 37 Ok(()) 38 }) 39 .plugin(tauri_plugin_store::Builder::default().build()) 40 .plugin(tauri_plugin_opener::init()) 41 .invoke_handler(tauri::generate_handler![greet]) 42 .run(tauri::generate_context!()) 43 .expect("error while running tauri application"); 44}