Misc bugs 4 (#381)

* bug fixes

* fixed jres being undetected

* cleanup

* prettier

* fixed folders not displaying windows exporting

* fixes, more bugs

* missed function

* clippy, fmt

* prettier
This commit is contained in:
Wyatt Verchere
2023-07-28 19:56:49 -07:00
committed by GitHub
parent 744d11f09e
commit 87449f91c3
22 changed files with 171 additions and 78 deletions

View File

@@ -308,7 +308,7 @@ const accounts = ref(null)
align-items: center;
flex-grow: 1;
background: var(--color-raised-bg);
box-shadow: inset 0px -3px 0px black;
box-shadow: var(--shadow-inset-sm), var(--shadow-floating);
text-align: center;
padding: var(--gap-md);
height: 3.25rem;

View File

@@ -27,7 +27,7 @@ import {
import { handleError } from '@/store/notifications.js'
import { remove, run } from '@/helpers/profile.js'
import { useRouter } from 'vue-router'
import { showInFolder } from '@/helpers/utils.js'
import { showProfileInFolder } from '@/helpers/utils.js'
import { useFetch } from '@/helpers/fetch.js'
import { install as pack_install } from '@/helpers/pack.js'
import { useTheming } from '@/store/state.js'
@@ -155,7 +155,7 @@ const handleOptionsClick = async (args) => {
deleteConfirmModal.value.show()
break
case 'open_folder':
await showInFolder(args.item.path)
await showProfileInFolder(args.item.path)
break
case 'copy_path':
await navigator.clipboard.writeText(args.item.path)

View File

@@ -5,6 +5,7 @@ import { ref } from 'vue'
import { export_profile_mrpack, get_potential_override_folders } from '@/helpers/profile.js'
import { open } from '@tauri-apps/api/dialog'
import { handleError } from '@/store/notifications.js'
import { sep } from '@tauri-apps/api/path'
const props = defineProps({
instance: {
@@ -33,11 +34,11 @@ const initFiles = async () => {
filePaths
.map((folder) => ({
path: folder,
name: folder.split('/').pop(),
name: folder.split(sep).pop(),
selected: false,
}))
.forEach((pathData) => {
const parent = pathData.path.split('/').slice(0, -1).join('/')
const parent = pathData.path.split(sep).slice(0, -1).join(sep)
if (parent !== '') {
if (newFolders.has(parent)) {
newFolders.get(parent).push(pathData)

View File

@@ -31,14 +31,13 @@ defineExpose({
async function install() {
installing.value = true
console.log(`Installing ${projectId.value} ${version.value} ${title.value} ${icon.value}`)
confirmModal.value.hide()
await pack_install(
projectId.value,
version.value,
title.value,
icon.value ? icon.value : null
).catch(handleError)
confirmModal.value.hide()
mixpanel.track('PackInstall', {
id: projectId.value,
version_id: version.value,

View File

@@ -14,7 +14,7 @@ import {
import { process_listener } from '@/helpers/events'
import { useFetch } from '@/helpers/fetch.js'
import { handleError } from '@/store/state.js'
import { showInFolder } from '@/helpers/utils.js'
import { showProfileInFolder } from '@/helpers/utils.js'
import InstanceInstallModal from '@/components/ui/InstanceInstallModal.vue'
import mixpanel from 'mixpanel-browser'
@@ -155,7 +155,7 @@ const stop = async (e, context) => {
}
const openFolder = async () => {
await showInFolder(props.instance.path)
await showProfileInFolder(props.instance.path)
}
const addContent = async () => {

View File

@@ -37,6 +37,12 @@ export async function get(path, clearProjects) {
return await invoke('plugin:profile|profile_get', { path, clearProjects })
}
// Get a profile's full fs path
// Returns a path
export async function get_full_path(path) {
return await invoke('plugin:profile|profile_get_full_path', { path })
}
// Get optimal java version from profile
// Returns a java version
export async function get_optimal_jre_key(path) {

View File

@@ -1,4 +1,8 @@
import { add_project_from_version as installMod, check_installed } from '@/helpers/profile'
import {
add_project_from_version as installMod,
check_installed,
get_full_path,
} from '@/helpers/profile'
import { useFetch } from '@/helpers/fetch.js'
import { handleError } from '@/store/notifications.js'
import { invoke } from '@tauri-apps/api/tauri'
@@ -11,6 +15,12 @@ export async function showInFolder(path) {
return await invoke('plugin:utils|show_in_folder', { path })
}
// Opens a profile's folder in the OS file explorer
export async function showProfileInFolder(path) {
const fullPath = await get_full_path(path)
return await showInFolder(fullPath)
}
export const releaseColor = (releaseType) => {
switch (releaseType) {
case 'release':

View File

@@ -23,7 +23,11 @@ app.mixin(loadCssMixin)
const mountedApp = app.mount('#app')
const raw_invoke = async (plugin, fn, args) => {
return await invoke('plugin:' + plugin + '|' + fn, args)
if (plugin == '') {
return await invoke(fn, args)
} else {
return await invoke('plugin:' + plugin + '|' + fn, args)
}
}
isDev()
.then((dev) => {

View File

@@ -654,7 +654,7 @@ const showLoaders = computed(
</Card>
</aside>
<div class="search">
<Promotion class="promotion" />
<Promotion class="promotion" :external="false" />
<Card class="project-type-container">
<NavRow :links="selectableProjectTypes" />
</Card>

View File

@@ -51,7 +51,7 @@
<Button
v-tooltip="'Open instance folder'"
class="instance-button"
@click="showInFolder(instance.path)"
@click="showProfileInFolder(instance.path)"
>
<FolderOpenIcon />
Folder
@@ -148,7 +148,7 @@ import { process_listener, profile_listener } from '@/helpers/events'
import { useRoute, useRouter } from 'vue-router'
import { ref, onUnmounted } from 'vue'
import { handleError, useBreadcrumbs, useLoading } from '@/store/state'
import { showInFolder } from '@/helpers/utils.js'
import { showProfileInFolder } from '@/helpers/utils.js'
import ContextMenu from '@/components/ui/ContextMenu.vue'
import mixpanel from 'mixpanel-browser'
import { PackageIcon } from '@/assets/icons/index.js'
@@ -268,7 +268,7 @@ const handleOptionsClick = async (args) => {
})
break
case 'open_folder':
await showInFolder(instance.value.path)
await showProfileInFolder(instance.value.path)
break
case 'copy_path':
await navigator.clipboard.writeText(instance.value.path)

View File

@@ -223,7 +223,11 @@
:checked="!mod.disabled"
@change="toggleDisableMod(mod)"
/>
<Button v-tooltip="`Show ${mod.file_name}`" icon-only @click="showInFolder(mod.path)">
<Button
v-tooltip="`Show ${mod.file_name}`"
icon-only
@click="showProfileInFolder(mod.path)"
>
<FolderOpenIcon />
</Button>
</div>
@@ -345,7 +349,7 @@ import mixpanel from 'mixpanel-browser'
import { open } from '@tauri-apps/api/dialog'
import { listen } from '@tauri-apps/api/event'
import { convertFileSrc } from '@tauri-apps/api/tauri'
import { showInFolder } from '@/helpers/utils.js'
import { showProfileInFolder } from '@/helpers/utils.js'
import { MenuIcon, ToggleIcon, TextInputIcon, AddProjectImage } from '@/assets/icons'
const router = useRouter()
@@ -605,17 +609,39 @@ const updateProject = async (mod) => {
})
}
let locks = {}
const toggleDisableMod = async (mod) => {
mod.path = await toggle_disable_project(props.instance.path, mod.path).catch(handleError)
mod.disabled = !mod.disabled
mixpanel.track('InstanceProjectDisable', {
loader: props.instance.metadata.loader,
game_version: props.instance.metadata.game_version,
id: mod.id,
name: mod.name,
project_type: mod.project_type,
disabled: mod.disabled,
})
// Use mod's id as the key for the lock. If mod doesn't have a unique id, replace `mod.id` with some unique property.
if (!locks[mod.id]) {
locks[mod.id] = ref(null)
}
let lock = locks[mod.id]
while (lock.value) {
await lock.value
}
lock.value = toggle_disable_project(props.instance.path, mod.path)
.then((newPath) => {
mod.path = newPath
mod.disabled = !mod.disabled
mixpanel.track('InstanceProjectDisable', {
loader: props.instance.metadata.loader,
game_version: props.instance.metadata.game_version,
id: mod.id,
name: mod.name,
project_type: mod.project_type,
disabled: mod.disabled,
})
})
.catch(handleError)
.finally(() => {
lock.value = null
})
await lock.value
}
const removeMod = async (mod) => {

View File

@@ -350,15 +350,19 @@ async function install(version) {
}
if (installed.value) {
await remove_project(
instance.value.path,
Object.entries(instance.value.projects)
.map(([key, value]) => ({
key,
value,
}))
.find((p) => p.value.metadata?.version?.project_id === data.value.id).key
)
const old_project = Object.entries(instance.value.projects)
.map(([key, value]) => ({
key,
value,
}))
.find((p) => p.value.metadata?.version?.project_id === data.value.id)
if (!old_project) {
// Switching too fast, old project is not recognized as a Modrinth project yet
installing.value = false
return
}
await remove_project(instance.value.path, old_project.key)
}
if (version) {