mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2026-07-25 09:15:07 +10:00
handshakes
This commit is contained in:
+12
-9
@@ -4,15 +4,17 @@ mod remote;
|
||||
mod unpacker;
|
||||
|
||||
use std::{
|
||||
io,
|
||||
sync::{LazyLock, Mutex},
|
||||
task, thread,
|
||||
};
|
||||
|
||||
use auth::{auth_initiate, recieve_handshake};
|
||||
use data::DatabaseInterface;
|
||||
use futures::executor;
|
||||
use log::info;
|
||||
use remote::use_remote;
|
||||
use serde::Serialize;
|
||||
use structured_logger::{json::new_writer, Builder};
|
||||
use tauri_plugin_deep_link::DeepLinkExt;
|
||||
|
||||
#[derive(Clone, Copy, Serialize)]
|
||||
@@ -40,6 +42,10 @@ fn fetch_state<'a>(state: tauri::State<'_, Mutex<AppState>>) -> Result<AppState,
|
||||
}
|
||||
|
||||
fn setup<'a>() -> AppState {
|
||||
Builder::with_level("info")
|
||||
.with_target_writer("*", new_writer(io::stdout()))
|
||||
.init();
|
||||
|
||||
let is_set_up = data::is_set_up();
|
||||
if !is_set_up {
|
||||
return AppState {
|
||||
@@ -60,14 +66,14 @@ pub static DB: LazyLock<DatabaseInterface> = LazyLock::new(|| data::setup());
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
let state = setup();
|
||||
info!("Initialized drop client");
|
||||
|
||||
let mut builder = tauri::Builder::default();
|
||||
|
||||
#[cfg(desktop)]
|
||||
{
|
||||
builder = builder.plugin(tauri_plugin_single_instance::init(|_app, argv, _cwd| {
|
||||
println!("a new app instance was opened with {argv:?} and the deep link event was already triggered");
|
||||
// when defining deep link schemes at runtime, you must also check `argv` here
|
||||
// when defining deep link schemes at runtime, you must also check `argv` here
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -85,20 +91,17 @@ pub fn run() {
|
||||
{
|
||||
use tauri_plugin_deep_link::DeepLinkExt;
|
||||
app.deep_link().register_all()?;
|
||||
info!("registered all pre-defined deep links");
|
||||
}
|
||||
|
||||
let handle = app.handle().clone();
|
||||
|
||||
app.deep_link().on_open_url(move |event| {
|
||||
info!("handling drop:// url");
|
||||
let binding = event.urls();
|
||||
let url = binding.get(0).unwrap();
|
||||
match url.host_str().unwrap() {
|
||||
"handshake" => {
|
||||
executor::block_on(recieve_handshake(
|
||||
handle.clone(),
|
||||
url.path().to_string(),
|
||||
));
|
||||
}
|
||||
"handshake" => recieve_handshake(handle.clone(), url.path().to_string()),
|
||||
_ => (),
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user