aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/main.rs
diff options
context:
space:
mode:
authorRémy Raes <contact@remyraes.com>2022-09-22 22:35:31 +0200
committerGitHub <noreply@github.com>2022-09-22 22:35:31 +0200
commit6b7f92b062ab8d4ed7ccd8cc84663b9cab63ec2f (patch)
tree52f34da65eb5bf79eb4f7771c285591ade5ef6d4 /src-tauri/src/main.rs
parent41cf93b7121fe2bd83a5428ebd20ace5beb60866 (diff)
parent7be562965057dddd0719646c5bb7fb48574bb3a2 (diff)
downloadFlightCore-6b7f92b062ab8d4ed7ccd8cc84663b9cab63ec2f.tar.gz
FlightCore-6b7f92b062ab8d4ed7ccd8cc84663b9cab63ec2f.zip
Merge branch 'GeckoEidechse:main' into feat/new-ui
Diffstat (limited to 'src-tauri/src/main.rs')
-rw-r--r--src-tauri/src/main.rs44
1 files changed, 24 insertions, 20 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 20ad4716..536acbe5 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -10,12 +10,14 @@ use std::{
};
use app::{
- check_is_flightcore_outdated, check_is_valid_game_path, check_origin_running,
- convert_release_candidate_number, find_game_install_location, get_host_os,
- get_northstar_version_number, install_northstar, launch_northstar, GameInstall,
+ check_is_flightcore_outdated, check_is_valid_game_path, check_northstar_running,
+ check_origin_running, convert_release_candidate_number, find_game_install_location,
+ get_host_os, get_log_list, get_northstar_version_number, install_northstar, launch_northstar,
+ GameInstall,
};
-use tauri::{Manager, State};
+use tauri::Manager;
use tokio::time::sleep;
+use tauri_plugin_store::PluginBuilder;
#[derive(Default)]
struct Counter(Arc<Mutex<i32>>);
@@ -32,6 +34,7 @@ fn main() {
));
tauri::Builder::default()
+ .plugin(PluginBuilder::default().build())
.setup(|app| {
let app_handle = app.app_handle();
tauri::async_runtime::spawn(async move {
@@ -50,13 +53,20 @@ fn main() {
.unwrap();
}
});
+ let app_handle = app.app_handle();
+ tauri::async_runtime::spawn(async move {
+ loop {
+ sleep(Duration::from_millis(2000)).await;
+ app_handle
+ .emit_all("northstar-running-ping", check_northstar_running())
+ .unwrap();
+ }
+ });
Ok(())
})
.manage(Counter(Default::default()))
.invoke_handler(tauri::generate_handler![
- hello_world,
- add_count,
force_panic,
find_game_install_location_caller,
get_version_number,
@@ -67,7 +77,8 @@ fn main() {
install_northstar_caller,
update_northstar_caller,
launch_northstar_caller,
- check_is_flightcore_outdated_caller
+ check_is_flightcore_outdated_caller,
+ get_log_list_caller
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
@@ -86,19 +97,6 @@ fn find_game_install_location_caller() -> Result<GameInstall, String> {
}
#[tauri::command]
-fn hello_world() -> String {
- "Hello World!!!".to_string()
-}
-
-#[tauri::command]
-fn add_count(num: i32, counter: State<'_, Counter>) -> String {
- let mut val = counter.0.lock().unwrap();
- *val += num;
-
- format!("{val}")
-}
-
-#[tauri::command]
/// This function's only use is to force a `panic!()`
fn force_panic() {
panic!("Force panicked!");
@@ -236,3 +234,9 @@ async fn update_northstar_caller(
fn launch_northstar_caller(game_install: GameInstall) -> Result<String, String> {
launch_northstar(game_install)
}
+
+#[tauri::command]
+/// Get list of Northstar logs
+fn get_log_list_caller(game_install: GameInstall) -> Result<Vec<std::path::PathBuf>, String> {
+ get_log_list(game_install)
+}