From 7103d0e3a1e72ea6b27b9c87b6b8643b008f6795 Mon Sep 17 00:00:00 2001 From: Lncvrt Date: Sun, 10 May 2026 07:54:38 -0700 Subject: [PATCH] Get some async functions to be awaited, and also use different failed to load screen --- src/app/main/account/page.tsx | 2 +- src/app/main/game/page.tsx | 2 +- src/app/main/layout.tsx | 23 +++++++++++++++-------- src/app/main/settings/page.tsx | 2 +- src/components/Sidebar.tsx | 12 ++++++------ src/popups/ManageVersion.tsx | 2 +- src/popups/ModDownloads.tsx | 8 ++++---- src/popups/VersionsDownload.tsx | 4 ++-- 8 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/app/main/account/page.tsx b/src/app/main/account/page.tsx index f880701..f5649eb 100644 --- a/src/app/main/account/page.tsx +++ b/src/app/main/account/page.tsx @@ -235,7 +235,7 @@ function AccountChangePassword ({ e.preventDefault() if (newPassword !== retypeNewPassword) { - message('Passwords must match', { + await message('Passwords must match', { title: "Passwords don't match!", kind: 'error' }) diff --git a/src/app/main/game/page.tsx b/src/app/main/game/page.tsx index 627af3b..faf1bbb 100644 --- a/src/app/main/game/page.tsx +++ b/src/app/main/game/page.tsx @@ -316,7 +316,7 @@ export default function Installs () { )) && !downloadProgress.find(d => d.version == v) ) { - downloadVersions([ + await downloadVersions([ { id: v, type: 1 diff --git a/src/app/main/layout.tsx b/src/app/main/layout.tsx index c0b5bd7..20fc58f 100644 --- a/src/app/main/layout.tsx +++ b/src/app/main/layout.tsx @@ -34,7 +34,7 @@ import { faChevronLeft, faXmark } from '@fortawesome/free-solid-svg-icons' import { invoke } from '@tauri-apps/api/core' import semver from 'semver' import { exit } from '@tauri-apps/plugin-process' -import { ask } from '@tauri-apps/plugin-dialog' +import { ask, message } from '@tauri-apps/plugin-dialog' import VersionsDownloadPopup from '@/popups/VersionsDownload' import GamesDownloadPopup from '@/popups/GamesDownload' @@ -54,7 +54,6 @@ export default function RootLayout ({ children: React.ReactNode }) { const [loading, setLoading] = useState(true) - const [loadingText, setLoadingText] = useState('Loading...') const [version, setVersion] = useState(null) const [platformName, setPlatformName] = useState(null) const [movingData, setMovingData] = useState(false) @@ -441,18 +440,18 @@ export default function RootLayout ({ //reinstall setSelectedVersionList([versionInfo.id]) - downloadVersions([ + await downloadVersions([ { id: versionInfo.id, type: 0 } ]) } else { - openFolder(versionInfo.id) + await openFolder(versionInfo.id) } return } - invoke('launch_game', { + await invoke('launch_game', { name: versionInfo.id, executable: versionInfo.executable, displayName: versionInfo.displayName, @@ -728,11 +727,19 @@ export default function RootLayout ({ if (await verifySignature(JSON.stringify(data), signature)) { setServerVersionList(data) } else { - setLoadingText('Failed to download versions list.') + await message( + 'Failed to get version manifest, please try again later.', + { title: 'Error fetching launcher manifest', kind: 'error' } + ) + await exit(1) return } } catch { - setLoadingText('Failed to download versions list.') + await message( + 'Failed to get version manifest, please try again later.', + { title: 'Error fetching launcher manifest', kind: 'error' } + ) + await exit(1) return } @@ -846,7 +853,7 @@ export default function RootLayout ({ : 'h-screen' } flex items-center justify-center`} > -

{loadingText}

+

Loading...

) : ( diff --git a/src/app/main/settings/page.tsx b/src/app/main/settings/page.tsx index bf9c13c..d383eca 100644 --- a/src/app/main/settings/page.tsx +++ b/src/app/main/settings/page.tsx @@ -269,7 +269,7 @@ export default function Settings () { } } - message( + await message( 'Removed the following game items: ' + (removed.length == 0 ? '(none)' : removed.join(', ')), { title: 'Sucessfully cleaned games folder', kind: 'info' } diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index ec4e550..f784fa9 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -58,12 +58,12 @@ export default function Sidebar () { {platform() == 'macos' && (
{ + onMouseDown={async e => { if (e.buttons === 1) { if (e.detail === 2) { - getCurrentWindow().toggleMaximize() + await getCurrentWindow().toggleMaximize() } else { - getCurrentWindow().startDragging() + await getCurrentWindow().startDragging() } } }} @@ -75,13 +75,13 @@ export default function Sidebar () { (platform() == 'windows' ? 'pl-1 pt-1' : 'pl-2 pt-2') + (platform() == 'macos' ? ' mt-6' : '') } - onMouseDown={e => { + onMouseDown={async e => { if (platform() != 'macos') return if (e.buttons === 1) { if (e.detail === 2) { - getCurrentWindow().toggleMaximize() + await getCurrentWindow().toggleMaximize() } else { - getCurrentWindow().startDragging() + await getCurrentWindow().startDragging() } } }} diff --git a/src/popups/ManageVersion.tsx b/src/popups/ManageVersion.tsx index 96aee83..da2b41b 100644 --- a/src/popups/ManageVersion.tsx +++ b/src/popups/ManageVersion.tsx @@ -195,7 +195,7 @@ export default function ManageVersionPopup () { //reinstall setSelectedVersionList([managingVersion]) - downloadVersions([ + await downloadVersions([ { id: managingVersion, type: 0 diff --git a/src/popups/ModDownloads.tsx b/src/popups/ModDownloads.tsx index 5c0dee4..999ca9e 100644 --- a/src/popups/ModDownloads.tsx +++ b/src/popups/ModDownloads.tsx @@ -243,7 +243,7 @@ export default function ModDownloadsPopup () { ) ) - downloadVersions([ + await downloadVersions([ { id: managingVersion, type: 2, @@ -350,8 +350,8 @@ export default function ModDownloadsPopup () { ) : (