Improve moving data system
This commit is contained in:
5 files changed
+26
-26
No files matched your search
@@ -19,6 +19,7 @@
|
|||||||
"core:window:allow-toggle-maximize",
|
"core:window:allow-toggle-maximize",
|
||||||
"core:window:allow-request-user-attention",
|
"core:window:allow-request-user-attention",
|
||||||
"core:window:allow-show",
|
"core:window:allow-show",
|
||||||
|
"core:window:allow-hide",
|
||||||
"core:webview:allow-create-webview-window",
|
"core:webview:allow-create-webview-window",
|
||||||
"fs:default",
|
"fs:default",
|
||||||
"fs:allow-remove",
|
"fs:allow-remove",
|
||||||
|
|||||||
@@ -635,11 +635,6 @@ async fn move_game_data(app: AppHandle, destination: String) -> Result<(), Strin
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
|
||||||
fn restart_app(app: AppHandle) {
|
|
||||||
app.restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn open_game_folder(app: AppHandle, version: String) -> Result<(), String> {
|
fn open_game_folder(app: AppHandle, version: String) -> Result<(), String> {
|
||||||
let dir = data_dir(&app)?;
|
let dir = data_dir(&app)?;
|
||||||
@@ -718,7 +713,6 @@ pub fn run() {
|
|||||||
verify_signature,
|
verify_signature,
|
||||||
cancel_download,
|
cancel_download,
|
||||||
move_game_data,
|
move_game_data,
|
||||||
restart_app,
|
|
||||||
open_game_folder,
|
open_game_folder,
|
||||||
remove_stale_executable
|
remove_stale_executable
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -56,7 +56,6 @@ export default function RootLayout ({
|
|||||||
const [loading, setLoading] = useState(true)
|
const [loading, setLoading] = useState(true)
|
||||||
const [version, setVersion] = useState<string | null>(null)
|
const [version, setVersion] = useState<string | null>(null)
|
||||||
const [platformName, setPlatformName] = useState<string | null>(null)
|
const [platformName, setPlatformName] = useState<string | null>(null)
|
||||||
const [movingData, setMovingData] = useState(false)
|
|
||||||
|
|
||||||
const [serverVersionList, setServerVersionList] =
|
const [serverVersionList, setServerVersionList] =
|
||||||
useState<null | ServerVersionsResponse>(null)
|
useState<null | ServerVersionsResponse>(null)
|
||||||
@@ -906,8 +905,6 @@ export default function RootLayout ({
|
|||||||
accountId,
|
accountId,
|
||||||
accountName,
|
accountName,
|
||||||
accountAdmin,
|
accountAdmin,
|
||||||
movingData,
|
|
||||||
setMovingData,
|
|
||||||
managingGame,
|
managingGame,
|
||||||
setManagingGame,
|
setManagingGame,
|
||||||
needsRevisionUpdate,
|
needsRevisionUpdate,
|
||||||
@@ -980,11 +977,6 @@ export default function RootLayout ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{movingData && (
|
|
||||||
<div className='fixed inset-0 z-999999 bg-(--col0) flex items-center justify-center'>
|
|
||||||
<p className='text-5xl text-center'>Moving data...</p>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</GlobalProvider>
|
</GlobalProvider>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ import { Setting } from '@/components/Setting'
|
|||||||
import { useGlobal } from '@/providers/GlobalProvider'
|
import { useGlobal } from '@/providers/GlobalProvider'
|
||||||
import { copyToClipboard } from '@/lib/clipboard'
|
import { copyToClipboard } from '@/lib/clipboard'
|
||||||
import { platform } from '@tauri-apps/plugin-os'
|
import { platform } from '@tauri-apps/plugin-os'
|
||||||
import { message, open } from '@tauri-apps/plugin-dialog'
|
import { confirm, message, open } from '@tauri-apps/plugin-dialog'
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
import Dropdown from '@/components/Dropdown'
|
import Dropdown from '@/components/Dropdown'
|
||||||
import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
|
import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
|
||||||
import { relaunch } from '@tauri-apps/plugin-process'
|
import { exit, relaunch } from '@tauri-apps/plugin-process'
|
||||||
import { BaseDirectory, exists, readDir, remove } from '@tauri-apps/plugin-fs'
|
import { BaseDirectory, exists, readDir, remove } from '@tauri-apps/plugin-fs'
|
||||||
import { openPath } from '@tauri-apps/plugin-opener'
|
import { openPath } from '@tauri-apps/plugin-opener'
|
||||||
import { appLocalDataDir } from '@tauri-apps/api/path'
|
import { appLocalDataDir } from '@tauri-apps/api/path'
|
||||||
|
import { getCurrentWindow } from '@tauri-apps/api/window'
|
||||||
|
|
||||||
export default function SettingsPage () {
|
export default function SettingsPage () {
|
||||||
const {
|
const {
|
||||||
@@ -25,8 +26,7 @@ export default function SettingsPage () {
|
|||||||
linuxWineCommand,
|
linuxWineCommand,
|
||||||
theme,
|
theme,
|
||||||
customDataLocation,
|
customDataLocation,
|
||||||
downloadProgress,
|
downloadProgress
|
||||||
setMovingData
|
|
||||||
} = useGlobal()
|
} = useGlobal()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -73,12 +73,19 @@ export default function SettingsPage () {
|
|||||||
onChange={async () => {
|
onChange={async () => {
|
||||||
if (customDataLocation) {
|
if (customDataLocation) {
|
||||||
try {
|
try {
|
||||||
setMovingData(true)
|
const confirmation = await confirm(
|
||||||
|
'Data will be moved back to the original location. The launcher will restart when completed and will not be visible until the restart.',
|
||||||
|
{ title: 'Moving data', kind: 'warning' }
|
||||||
|
)
|
||||||
|
if (!confirmation) return
|
||||||
|
|
||||||
|
const window = getCurrentWindow()
|
||||||
|
await window.hide()
|
||||||
await invoke('move_game_data', { destination: '' })
|
await invoke('move_game_data', { destination: '' })
|
||||||
await settings?.set('customDataLocation', '')
|
await settings?.set('customDataLocation', '')
|
||||||
await invoke('restart_app')
|
await relaunch()
|
||||||
} catch {
|
} catch {
|
||||||
setMovingData(false)
|
await exit(1)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const selected = await open({
|
const selected = await open({
|
||||||
@@ -87,12 +94,20 @@ export default function SettingsPage () {
|
|||||||
})
|
})
|
||||||
if (!selected || typeof selected !== 'string') return
|
if (!selected || typeof selected !== 'string') return
|
||||||
try {
|
try {
|
||||||
setMovingData(true)
|
const confirmation = await confirm(
|
||||||
|
`Data will be moved to the directory "${selected}". The launcher will restart when completed and will not be visible until the restart.`,
|
||||||
|
{ title: 'Moving data', kind: 'warning' }
|
||||||
|
)
|
||||||
|
if (!confirmation) return
|
||||||
|
|
||||||
|
const window = getCurrentWindow()
|
||||||
|
await window.hide()
|
||||||
await invoke('move_game_data', { destination: selected })
|
await invoke('move_game_data', { destination: selected })
|
||||||
await settings?.set('customDataLocation', selected)
|
await settings?.set('customDataLocation', selected)
|
||||||
await invoke('restart_app')
|
await relaunch()
|
||||||
} catch {
|
} catch {
|
||||||
setMovingData(false)
|
await exit(1)
|
||||||
|
await exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -67,8 +67,6 @@ type GlobalCtxType = {
|
|||||||
accountId: string | null
|
accountId: string | null
|
||||||
accountName: string | null
|
accountName: string | null
|
||||||
accountAdmin: boolean
|
accountAdmin: boolean
|
||||||
movingData: boolean
|
|
||||||
setMovingData: Dispatch<SetStateAction<boolean>>
|
|
||||||
managingGame: number | null
|
managingGame: number | null
|
||||||
setManagingGame: Dispatch<SetStateAction<number | null>>
|
setManagingGame: Dispatch<SetStateAction<number | null>>
|
||||||
needsRevisionUpdate: (
|
needsRevisionUpdate: (
|
||||||
|
|||||||
Reference in new issue
Block a user