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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 47 additions and 40 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,7 +19,7 @@ theseus = { path = "../../theseus", features = ["tauri"] }
serde_json = "1.0"
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"] }
thiserror = "1.0"
tokio-stream = { version = "0.1", features = ["fs"] }

View File

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

View File

@ -1,7 +1,7 @@
<script setup>
import { onUnmounted, ref, useSlots } from 'vue'
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 InstallConfirmModal from '@/components/ui/InstallConfirmModal.vue'
import { install as pack_install } from '@/helpers/pack'
@ -206,7 +206,7 @@ onUnmounted(() => unlisten())
>
<XIcon />
</div>
<div v-else class="install cta buttonbase" @click="install"><SaveIcon /></div>
<div v-else class="install cta buttonbase" @click="install"><DownloadIcon /></div>
</template>
<InstallConfirmModal ref="confirmModal" />
</div>

View File

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

View File

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

View File

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

View File

@ -10,9 +10,9 @@ const themeStore = useTheming()
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: '' }
if (!fetchSettings.java_globals?.JAVA_17)
if (!fetchSettings.java_globals.JAVA_17)
fetchSettings.java_globals.JAVA_17 = { path: '', version: '' }
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)
watch(settings.value, async (oldSettings, newSettings) => {
if (newSettings.java_globals?.JAVA_8?.path === '') {
newSettings.java_globals.JAVA_8 = undefined
const setSettings = JSON.parse(JSON.stringify(newSettings))
if (setSettings.java_globals.JAVA_8?.path === '') {
setSettings.java_globals.JAVA_8 = undefined
}
if (newSettings.java_globals?.JAVA_17?.path === '') {
newSettings.java_globals.JAVA_17 = undefined
if (setSettings.java_globals.JAVA_17?.path === '') {
setSettings.java_globals.JAVA_17 = undefined
}
newSettings.custom_java_args = newSettings.javaArgs.trim().split(/\s+/).filter(Boolean)
newSettings.custom_env_args = newSettings.envArgs
setSettings.custom_java_args = setSettings.javaArgs.trim().split(/\s+/).filter(Boolean)
setSettings.custom_env_args = setSettings.envArgs
.trim()
.split(/\s+/)
.filter(Boolean)
.map((x) => x.split('=').filter(Boolean))
if (!newSettings.hooks.pre_launch) {
newSettings.hooks.pre_launch = null
if (!setSettings.hooks.pre_launch) {
setSettings.hooks.pre_launch = null
}
if (!newSettings.hooks.wrapper) {
newSettings.hooks.wrapper = null
if (!setSettings.hooks.wrapper) {
setSettings.hooks.wrapper = null
}
if (!newSettings.hooks.post_exit) {
newSettings.hooks.post_exit = null
if (!setSettings.hooks.post_exit) {
setSettings.hooks.post_exit = null
}
await set(newSettings)
await set(setSettings)
})
</script>

View File

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

View File

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

View File

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