Fix various issues (#123)

* Fix various issues

* Remove unused
This commit is contained in:
Geometrically
2023-05-23 14:24:39 -07:00
committed by GitHub
parent 8ff1b0d108
commit 9ea548cfe3
16 changed files with 47 additions and 40 deletions

View File

@@ -18,7 +18,6 @@ pub async fn get() -> crate::Result<Settings> {
#[tracing::instrument] #[tracing::instrument]
pub async fn set(settings: Settings) -> crate::Result<()> { pub async fn set(settings: Settings) -> crate::Result<()> {
let state = State::get().await?; let state = State::get().await?;
// Replaces the settings struct in the RwLock with the passed argument
let (reset_io, reset_fetch) = async { let (reset_io, reset_fetch) = async {
let read = state.settings.read().await; let read = state.settings.read().await;
( (
@@ -28,13 +27,17 @@ pub async fn set(settings: Settings) -> crate::Result<()> {
} }
.await; .await;
*state.settings.write().await = settings; {
*state.settings.write().await = settings;
}
if reset_io { if reset_io {
state.reset_io_semaphore().await; state.reset_io_semaphore().await;
} }
if reset_fetch { if reset_fetch {
state.reset_fetch_semaphore().await; state.reset_fetch_semaphore().await;
} }
State::sync().await?; State::sync().await?;
Ok(()) Ok(())
} }

View File

@@ -149,7 +149,7 @@ pub async fn install_minecraft(
let java_version = get_java_version_from_profile(profile, &version_info) let java_version = get_java_version_from_profile(profile, &version_info)
.await? .await?
.ok_or_else(|| { .ok_or_else(|| {
crate::ErrorKind::LauncherError( crate::ErrorKind::OtherError(
"No available java installation".to_string(), "No available java installation".to_string(),
) )
})?; })?;

View File

@@ -39,8 +39,8 @@ impl Default for Settings {
java_globals: JavaGlobals::new(), java_globals: JavaGlobals::new(),
default_user: None, default_user: None,
hooks: Hooks::default(), hooks: Hooks::default(),
max_concurrent_downloads: 64, max_concurrent_downloads: 10,
max_concurrent_writes: 100, max_concurrent_writes: 10,
version: CURRENT_FORMAT_VERSION, version: CURRENT_FORMAT_VERSION,
collapsed_navigation: false, collapsed_navigation: false,
} }

View File

@@ -221,7 +221,7 @@ async fn get_all_jre_path() -> Result<HashSet<PathBuf>, JREError> {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
#[allow(dead_code)] #[allow(dead_code)]
const JAVA_BIN: &str = "java.exe"; const JAVA_BIN: &str = "javaw.exe";
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
#[allow(dead_code)] #[allow(dead_code)]

View File

@@ -8,6 +8,7 @@ node_modules
dist dist
*.md *.md
package.json package.json
dist/
generated/ generated/
!.gitkeep !.gitkeep
@@ -86,4 +87,4 @@ sw.*
# pnpm files # pnpm files
pnpm-lock.yaml pnpm-lock.yaml
/.npmrc /.npmrc

View File

@@ -14,12 +14,12 @@
}, },
"dependencies": { "dependencies": {
"@tauri-apps/api": "^1.2.0", "@tauri-apps/api": "^1.2.0",
"dayjs": "^1.11.7",
"ofetch": "^1.0.1", "ofetch": "^1.0.1",
"omorphia": "^0.4.17", "omorphia": "^0.4.17",
"pinia": "^2.0.33", "pinia": "^2.0.33",
"vite-svg-loader": "^4.0.0", "vite-svg-loader": "^4.0.0",
"vue": "^3.2.45", "vue": "^3.2.45",
"dayjs": "^1.11.7",
"vue-multiselect": "^3.0.0-alpha.2", "vue-multiselect": "^3.0.0-alpha.2",
"vue-router": "4" "vue-router": "4"
}, },

View File

@@ -19,7 +19,7 @@ theseus = { path = "../../theseus", features = ["tauri"] }
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["dialog", "dialog-open", "protocol-asset", "shell-open", "updater", "window-close", "window-create"] } tauri = { version = "1.2", features = ["devtools", "dialog", "dialog-open", "protocol-asset", "shell-open", "updater", "window-close", "window-create"] }
tokio = { version = "1", features = ["full"] } tokio = { version = "1", features = ["full"] }
thiserror = "1.0" thiserror = "1.0"
tokio-stream = { version = "0.1", features = ["fs"] } tokio-stream = { version = "0.1", features = ["fs"] }

View File

@@ -47,7 +47,7 @@
</div> </div>
<Button v-if="accounts.length > 0" @click="login()"> <Button v-if="accounts.length > 0" @click="login()">
<PlusIcon /> <PlusIcon />
Add Account Add account
</Button> </Button>
</Card> </Card>
</transition> </transition>
@@ -115,6 +115,7 @@ const login = async () => {
const url = await authenticate_begin_flow().catch(handleError) const url = await authenticate_begin_flow().catch(handleError)
const window = new WebviewWindow('loginWindow', { const window = new WebviewWindow('loginWindow', {
title: 'Modrinth App',
url: url, url: url,
}) })

View File

@@ -1,7 +1,7 @@
<script setup> <script setup>
import { onUnmounted, ref, useSlots } from 'vue' import { onUnmounted, ref, useSlots } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { Card, SaveIcon, XIcon, Avatar, AnimatedLogo, PlayIcon } from 'omorphia' import { Card, DownloadIcon, XIcon, Avatar, AnimatedLogo, PlayIcon } from 'omorphia'
import { convertFileSrc } from '@tauri-apps/api/tauri' import { convertFileSrc } from '@tauri-apps/api/tauri'
import InstallConfirmModal from '@/components/ui/InstallConfirmModal.vue' import InstallConfirmModal from '@/components/ui/InstallConfirmModal.vue'
import { install as pack_install } from '@/helpers/pack' import { install as pack_install } from '@/helpers/pack'
@@ -206,7 +206,7 @@ onUnmounted(() => unlisten())
> >
<XIcon /> <XIcon />
</div> </div>
<div v-else class="install cta buttonbase" @click="install"><SaveIcon /></div> <div v-else class="install cta buttonbase" @click="install"><DownloadIcon /></div>
</template> </template>
<InstallConfirmModal ref="confirmModal" /> <InstallConfirmModal ref="confirmModal" />
</div> </div>

View File

@@ -1,16 +1,16 @@
<template> <template>
<Modal ref="modal" header="Create Instance"> <Modal ref="modal" header="Create instance">
<div v-if="showContent" class="modal-body"> <div v-if="showContent" class="modal-body">
<div class="image-upload"> <div class="image-upload">
<Avatar :src="display_icon" size="md" :rounded="true" /> <Avatar :src="display_icon" size="md" :rounded="true" />
<div class="image-input"> <div class="image-input">
<Button @click="upload_icon()"> <Button @click="upload_icon()">
<UploadIcon /> <UploadIcon />
Upload Icon Select icon
</Button> </Button>
<Button @click="reset_icon"> <Button @click="reset_icon">
<XIcon /> <XIcon />
Remove Icon Remove icon
</Button> </Button>
</div> </div>
</div> </div>
@@ -23,7 +23,7 @@
<Chips v-model="loader" :items="loaders" /> <Chips v-model="loader" :items="loaders" />
</div> </div>
<div class="input-row"> <div class="input-row">
<p class="input-label">Game Version</p> <p class="input-label">Game version</p>
<div class="versions"> <div class="versions">
<DropdownSelect v-model="game_version" :options="game_versions" render-up /> <DropdownSelect v-model="game_version" :options="game_versions" render-up />
<Checkbox <Checkbox
@@ -35,12 +35,12 @@
</div> </div>
</div> </div>
<div v-if="showAdvanced && loader !== 'vanilla'" class="input-row"> <div v-if="showAdvanced && loader !== 'vanilla'" class="input-row">
<p class="input-label">Loader Version</p> <p class="input-label">Loader version</p>
<Chips v-model="loader_version" :items="['stable', 'latest', 'other']" /> <Chips v-model="loader_version" :items="['stable', 'latest', 'other']" />
</div> </div>
<div v-if="showAdvanced && loader_version === 'other' && loader !== 'vanilla'"> <div v-if="showAdvanced && loader_version === 'other' && loader !== 'vanilla'">
<div v-if="game_version" class="input-row"> <div v-if="game_version" class="input-row">
<p class="input-label">Select Version</p> <p class="input-label">Select version</p>
<DropdownSelect <DropdownSelect
v-model="specified_loader_version" v-model="specified_loader_version"
:options="selectable_versions" :options="selectable_versions"
@@ -54,7 +54,7 @@
<div class="button-group"> <div class="button-group">
<Button @click="toggle_advanced"> <Button @click="toggle_advanced">
<CodeIcon /> <CodeIcon />
{{ showAdvanced ? 'Hide Advanced' : 'Show Advanced' }} {{ showAdvanced ? 'Hide advanced' : 'Show advanced' }}
</Button> </Button>
<Button @click="$refs.modal.hide()"> <Button @click="$refs.modal.hide()">
<XIcon /> <XIcon />

View File

@@ -172,11 +172,11 @@ const check_valid = computed(() => {
<div class="creation-icon__description"> <div class="creation-icon__description">
<Button @click="upload_icon()"> <Button @click="upload_icon()">
<UploadIcon /> <UploadIcon />
<span class="no-wrap"> Upload Icon </span> <span class="no-wrap"> Select icon </span>
</Button> </Button>
<Button @click="reset_icon()"> <Button @click="reset_icon()">
<XIcon /> <XIcon />
<span class="no-wrap"> Remove Icon </span> <span class="no-wrap"> Remove icon </span>
</Button> </Button>
</div> </div>
</div> </div>

View File

@@ -22,7 +22,7 @@
@click="$refs.detectJavaModal.show(props.version, props.modelValue)" @click="$refs.detectJavaModal.show(props.version, props.modelValue)"
> >
<SearchIcon /> <SearchIcon />
Auto Detect Auto detect
</Button> </Button>
<Button :disabled="props.disabled" @click="handleJavaFileInput()"> <Button :disabled="props.disabled" @click="handleJavaFileInput()">
<FolderSearchIcon /> <FolderSearchIcon />

View File

@@ -10,9 +10,9 @@ const themeStore = useTheming()
const fetchSettings = await get().catch(handleError) const fetchSettings = await get().catch(handleError)
if (!fetchSettings.java_globals?.JAVA_8) if (!fetchSettings.java_globals.JAVA_8)
fetchSettings.java_globals.JAVA_8 = { path: '', version: '' } fetchSettings.java_globals.JAVA_8 = { path: '', version: '' }
if (!fetchSettings.java_globals?.JAVA_17) if (!fetchSettings.java_globals.JAVA_17)
fetchSettings.java_globals.JAVA_17 = { path: '', version: '' } fetchSettings.java_globals.JAVA_17 = { path: '', version: '' }
fetchSettings.javaArgs = fetchSettings.custom_java_args.join(' ') fetchSettings.javaArgs = fetchSettings.custom_java_args.join(' ')
@@ -22,31 +22,33 @@ const settings = ref(fetchSettings)
const maxMemory = ref((await get_max_memory().catch(handleError)) / 1024) const maxMemory = ref((await get_max_memory().catch(handleError)) / 1024)
watch(settings.value, async (oldSettings, newSettings) => { watch(settings.value, async (oldSettings, newSettings) => {
if (newSettings.java_globals?.JAVA_8?.path === '') { const setSettings = JSON.parse(JSON.stringify(newSettings))
newSettings.java_globals.JAVA_8 = undefined
if (setSettings.java_globals.JAVA_8?.path === '') {
setSettings.java_globals.JAVA_8 = undefined
} }
if (newSettings.java_globals?.JAVA_17?.path === '') { if (setSettings.java_globals.JAVA_17?.path === '') {
newSettings.java_globals.JAVA_17 = undefined setSettings.java_globals.JAVA_17 = undefined
} }
newSettings.custom_java_args = newSettings.javaArgs.trim().split(/\s+/).filter(Boolean) setSettings.custom_java_args = setSettings.javaArgs.trim().split(/\s+/).filter(Boolean)
newSettings.custom_env_args = newSettings.envArgs setSettings.custom_env_args = setSettings.envArgs
.trim() .trim()
.split(/\s+/) .split(/\s+/)
.filter(Boolean) .filter(Boolean)
.map((x) => x.split('=').filter(Boolean)) .map((x) => x.split('=').filter(Boolean))
if (!newSettings.hooks.pre_launch) { if (!setSettings.hooks.pre_launch) {
newSettings.hooks.pre_launch = null setSettings.hooks.pre_launch = null
} }
if (!newSettings.hooks.wrapper) { if (!setSettings.hooks.wrapper) {
newSettings.hooks.wrapper = null setSettings.hooks.wrapper = null
} }
if (!newSettings.hooks.post_exit) { if (!setSettings.hooks.post_exit) {
newSettings.hooks.post_exit = null setSettings.hooks.post_exit = null
} }
await set(newSettings) await set(setSettings)
}) })
</script> </script>

View File

@@ -56,7 +56,7 @@
<div class="input-stack"> <div class="input-stack">
<button id="instance-icon" class="btn" @click="setIcon"> <button id="instance-icon" class="btn" @click="setIcon">
<UploadIcon /> <UploadIcon />
Upload icon Select icon
</button> </button>
<button class="btn" @click="resetIcon"> <button class="btn" @click="resetIcon">
<TrashIcon /> <TrashIcon />

View File

@@ -41,7 +41,7 @@
:action="clearFilters" :action="clearFilters"
> >
<ClearIcon /> <ClearIcon />
Clear Filters Clear filters
</Button> </Button>
</div> </div>
</Card> </Card>

View File

@@ -2,7 +2,7 @@ import { defineStore } from 'pinia'
export const useTheming = defineStore('themeStore', { export const useTheming = defineStore('themeStore', {
state: () => ({ state: () => ({
themeOptions: ['light', 'dark'], themeOptions: ['dark'],
collapsedNavigation: false, collapsedNavigation: false,
selectedTheme: 'dark', selectedTheme: 'dark',
darkTheme: true, darkTheme: true,