Merge pull request #201 from NotThorny/Exit-Proceedures

Fix Closure Stuff
This commit is contained in:
SpikeHD 2023-09-10 00:32:18 -07:00 committed by GitHub
commit 4c5b79513a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,12 +1,14 @@
import React from 'react' import React from 'react'
import { app } from '@tauri-apps/api' import { app, invoke } from '@tauri-apps/api'
import { appWindow } from '@tauri-apps/api/window' import { appWindow } from '@tauri-apps/api/window'
import { getConfig, setConfigOption } from '../../utils/configuration' import { getConfig, setConfigOption } from '../../utils/configuration'
import Tr from '../../utils/language' import Tr from '../../utils/language'
import { confirm } from '@tauri-apps/api/dialog'
import './TopBar.css' import './TopBar.css'
import closeIcon from '../../resources/icons/close.svg' import closeIcon from '../../resources/icons/close.svg'
import minIcon from '../../resources/icons/min.svg' import minIcon from '../../resources/icons/min.svg'
import { unpatchGame } from '../../utils/rsa'
interface IProps { interface IProps {
children?: React.ReactNode | React.ReactNode[] children?: React.ReactNode | React.ReactNode[]
@ -36,7 +38,19 @@ export default class TopBar extends React.Component<IProps, IState> {
this.setState({ version }) this.setState({ version })
} }
handleClose() { async handleClose() {
if (await invoke('is_game_running')) {
const confirmed = await confirm(
'Game is running. You WILL NOT be unpatched. Would you like to exit?',
'WARNING!!'
)
if (!confirmed) {
return
}
}
await invoke('disconnect')
unpatchGame()
appWindow.close() appWindow.close()
} }