diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-02-05 22:34:51 +0100 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2023-02-05 22:34:51 +0100 |
commit | 1970eb80f84ffdae7d5940fde3ff0d400e951c3c (patch) | |
tree | f2490b10f02864dc2ee24e11f614092d72e13c90 | |
parent | 3f315cfd36cb6d1bdbdd102c0bcfb2f9a0ce0fb9 (diff) | |
download | FlightCore-1970eb80f84ffdae7d5940fde3ff0d400e951c3c.tar.gz FlightCore-1970eb80f84ffdae7d5940fde3ff0d400e951c3c.zip |
refactor: Use custom object to expose results
Allows for expandability in the future
-rw-r--r-- | src-tauri/bindings/ParsedLogResults.ts | 3 | ||||
-rw-r--r-- | src-tauri/src/repair_and_verify/log_handling.rs | 16 | ||||
-rw-r--r-- | src-vue/src/views/DeveloperView.vue | 3 |
3 files changed, 19 insertions, 3 deletions
diff --git a/src-tauri/bindings/ParsedLogResults.ts b/src-tauri/bindings/ParsedLogResults.ts new file mode 100644 index 00000000..9d9d5c63 --- /dev/null +++ b/src-tauri/bindings/ParsedLogResults.ts @@ -0,0 +1,3 @@ +// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually. + +export interface ParsedLogResults { installed_mods: Array<string>, }
\ No newline at end of file diff --git a/src-tauri/src/repair_and_verify/log_handling.rs b/src-tauri/src/repair_and_verify/log_handling.rs index 3b87f632..6bb6528e 100644 --- a/src-tauri/src/repair_and_verify/log_handling.rs +++ b/src-tauri/src/repair_and_verify/log_handling.rs @@ -1,10 +1,18 @@ use regex::Regex; +use serde::{Deserialize, Serialize}; +use ts_rs::TS; + +#[derive(Serialize, Deserialize, Debug, Clone, TS)] +#[ts(export)] +pub struct ParsedLogResults { + installed_mods: Vec<String>, +} /// Parse logs for installed mods #[tauri::command] pub async fn parse_given_log_text_for_installed_mods( log_text: String, -) -> Result<Vec<String>, String> { +) -> Result<ParsedLogResults, String> { // Regex to capture mod loading let regex = Regex::new(r"(?m)Loaded mod (.*) successfully\n").unwrap(); @@ -22,6 +30,10 @@ pub async fn parse_given_log_text_for_installed_mods( }; } + let parsed_log_results = ParsedLogResults { + installed_mods: mods, + }; + // Return the captured mod names - return Ok(mods); + return Ok(parsed_log_results); } diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue index b3887ebd..96040189 100644 --- a/src-vue/src/views/DeveloperView.vue +++ b/src-vue/src/views/DeveloperView.vue @@ -74,6 +74,7 @@ import { invoke } from "@tauri-apps/api"; import { ElNotification } from "element-plus"; import { GameInstall } from "../utils/GameInstall"; import { Store } from 'tauri-plugin-store-api'; +import { ParsedLogResults } from "../../../src-tauri/bindings/ParsedLogResults"; const persistentStore = new Store('flight-core-settings.json'); import { ref } from 'vue' @@ -227,7 +228,7 @@ export default defineComponent({ }, async parseGivenLogTextForMods() { let current_log_content = this.log_content; - await invoke("parse_given_log_text_for_installed_mods", { logText: current_log_content }) + await invoke<[ParsedLogResults]>("parse_given_log_text_for_installed_mods", { logText: current_log_content }) .then((message) => { console.log(message); // TODO present better here // Show user notification if task completed. |