From 5f0d44a8810ec01bd4c6ccc6407d2217cb9b18ed Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Sat, 5 Aug 2023 17:43:21 -0700 Subject: [PATCH] more bug fixes (#485) * more bug fixes * remove console log --- theseus/src/api/profile/mod.rs | 17 ----------------- theseus_gui/src-tauri/src/api/profile.rs | 7 ------- theseus_gui/src-tauri/tauri.conf.json | 2 +- theseus_gui/src/helpers/profile.js | 5 ----- theseus_gui/src/pages/Browse.vue | 2 +- theseus_gui/src/pages/instance/Mods.vue | 21 +++++++++++++++++---- theseus_gui/src/pages/instance/Options.vue | 2 +- 7 files changed, 20 insertions(+), 36 deletions(-) diff --git a/theseus/src/api/profile/mod.rs b/theseus/src/api/profile/mod.rs index 6791f115..e32490be 100644 --- a/theseus/src/api/profile/mod.rs +++ b/theseus/src/api/profile/mod.rs @@ -543,23 +543,6 @@ pub async fn remove_project( } } -/// Gets whether project is a managed modrinth pack -#[tracing::instrument] -pub async fn is_managed_modrinth_pack( - profile: &ProfilePathId, -) -> crate::Result { - if let Some(profile) = get(profile, None).await? { - if let Some(linked_data) = profile.metadata.linked_data { - return Ok(linked_data.project_id.is_some() - && linked_data.version_id.is_some()); - } - Ok(false) - } else { - Err(crate::ErrorKind::UnmanagedProfileError(profile.to_string()) - .as_error()) - } -} - /// Exports the profile to a Modrinth-formatted .mrpack file // Version ID of uploaded version (ie 1.1.5), not the unique identifying ID of the version (nvrqJg44) #[tracing::instrument(skip_all)] diff --git a/theseus_gui/src-tauri/src/api/profile.rs b/theseus_gui/src-tauri/src/api/profile.rs index 6c577680..f620ccde 100644 --- a/theseus_gui/src-tauri/src/api/profile.rs +++ b/theseus_gui/src-tauri/src/api/profile.rs @@ -24,7 +24,6 @@ pub fn init() -> tauri::plugin::TauriPlugin { profile_remove_project, profile_update_managed_modrinth, profile_repair_managed_modrinth, - profile_is_managed_modrinth, profile_run, profile_run_wait, profile_run_credentials, @@ -190,12 +189,6 @@ pub async fn profile_repair_managed_modrinth( Ok(profile::update::repair_managed_modrinth(&path).await?) } -// Gets if a profile is managed by Modrinth -#[tauri::command] -pub async fn profile_is_managed_modrinth(path: ProfilePathId) -> Result { - Ok(profile::is_managed_modrinth_pack(&path).await?) -} - // Exports a profile to a .mrpack file (export_location should end in .mrpack) // invoke('profile_export_mrpack') #[tauri::command] diff --git a/theseus_gui/src-tauri/tauri.conf.json b/theseus_gui/src-tauri/tauri.conf.json index 0ad4f999..1f11c3e8 100644 --- a/theseus_gui/src-tauri/tauri.conf.json +++ b/theseus_gui/src-tauri/tauri.conf.json @@ -83,7 +83,7 @@ } }, "security": { - "csp": "default-src 'self'; connect-src https://modrinth.com https://*.modrinth.com https://mixpanel.com https://*.mixpanel.com https://*.cloudflare.com; font-src https://cdn-raw.modrinth.com/fonts/inter/; img-src tauri: https: data: blob: 'unsafe-inline' asset: https://asset.localhost; script-src https://*.cloudflare.com; frame-src https://*.cloudflare.com; style-src unsafe-inline" + "csp": "default-src 'self'; connect-src https://modrinth.com https://*.modrinth.com https://mixpanel.com https://*.mixpanel.com https://*.cloudflare.com; font-src https://cdn-raw.modrinth.com/fonts/inter/; img-src tauri: https: data: blob: 'unsafe-inline' asset: https://asset.localhost; script-src https://*.cloudflare.com 'self'; frame-src https://*.cloudflare.com 'self'; style-src unsafe-inline 'self'" }, "updater": { "active": true, diff --git a/theseus_gui/src/helpers/profile.js b/theseus_gui/src/helpers/profile.js index d21db9bf..21944d76 100644 --- a/theseus_gui/src/helpers/profile.js +++ b/theseus_gui/src/helpers/profile.js @@ -110,11 +110,6 @@ export async function update_repair_modrinth(path) { return await invoke('plugin:profile|profile_repair_managed_modrinth', { path }) } -// Gets whether a profile is managed by Modrinth -export async function is_managed_modrinth(path) { - return await invoke('plugin:profile|profile_is_managed_modrinth', { path }) -} - // Export a profile to .mrpack /// included_overrides is an array of paths to override folders to include (ie: 'mods', 'resource_packs') // Version id is optional (ie: 1.1.5) diff --git a/theseus_gui/src/pages/Browse.vue b/theseus_gui/src/pages/Browse.vue index e6374c77..dc53aa63 100644 --- a/theseus_gui/src/pages/Browse.vue +++ b/theseus_gui/src/pages/Browse.vue @@ -247,7 +247,7 @@ async function refreshSearch() { } } if (instanceContext.value) { - for (let val of results.value) { + for (let val of results.value.hits) { val.installed = await check_installed(instanceContext.value.path, val.project_id).then( (x) => (val.installed = x) ) diff --git a/theseus_gui/src/pages/instance/Mods.vue b/theseus_gui/src/pages/instance/Mods.vue index 13bca8f1..76a9cb13 100644 --- a/theseus_gui/src/pages/instance/Mods.vue +++ b/theseus_gui/src/pages/instance/Mods.vue @@ -10,9 +10,14 @@ v-model="selectedProjectType" :items="Object.keys(selectableProjectTypes)" /> -
@@ -362,7 +367,6 @@ import { useRouter } from 'vue-router' import { add_project_from_path, get, - is_managed_modrinth, remove_project, toggle_disable_project, update_all, @@ -403,8 +407,14 @@ const props = defineProps({ const projects = ref([]) const selectionMap = ref(new Map()) const showingOptions = ref(false) -const canUpdatePack = ref(await is_managed_modrinth(props.instance.path)) +const canUpdatePack = computed(() => { + return ( + props.instance.metadata.linked_data && + props.instance.metadata.linked_data.version_id !== props.instance.modrinth_update_version + ) +}) +console.log(props.instance) const initProjects = (initInstance) => { projects.value = [] if (!initInstance || !initInstance.projects) return @@ -800,8 +810,11 @@ const handleContentOptionClick = async (args) => { } } +const updatingModpack = ref(false) const updateModpack = async () => { + updatingModpack.value = true await update_managed_modrinth(props.instance.path).catch(handleError) + updatingModpack.value = false } watch(selectAll, () => { diff --git a/theseus_gui/src/pages/instance/Options.vue b/theseus_gui/src/pages/instance/Options.vue index 3c208f0c..e00ac126 100644 --- a/theseus_gui/src/pages/instance/Options.vue +++ b/theseus_gui/src/pages/instance/Options.vue @@ -508,7 +508,7 @@ watch( async () => { const editProfile = { metadata: { - name: title.value.trim().substring(0, 16) ?? 'Instance', + name: title.value.trim().substring(0, 32) ?? 'Instance', groups: groups.value.map((x) => x.trim().substring(0, 32)).filter((x) => x.length > 0), loader_version: props.instance.metadata.loader_version, linked_data: props.instance.metadata.linked_data,