exit & relaunching
Signed-off-by: FTCHD <144691102+FTCHD@users.noreply.github.com>
This commit is contained in:
@@ -5,7 +5,6 @@ import { ask, message, open } from '@tauri-apps/plugin-dialog'
|
||||
import { exists, mkdir, remove } from '@tauri-apps/plugin-fs'
|
||||
import { openPath } from '@tauri-apps/plugin-opener'
|
||||
import { platform } from '@tauri-apps/plugin-os'
|
||||
import { exit } from '@tauri-apps/plugin-process'
|
||||
import { isDirectoryEmpty } from './fs'
|
||||
import notify from './notify'
|
||||
import { cleanupRemote, deleteRemote, listMounts, mountRemote, unmountRemote } from './rclone/api'
|
||||
@@ -495,7 +494,6 @@ export async function buildMenu() {
|
||||
text: 'Quit',
|
||||
action: async () => {
|
||||
await getCurrentWindow().emit('close-app')
|
||||
await exit(0)
|
||||
},
|
||||
})
|
||||
menuItems.push(quitItem)
|
||||
|
||||
@@ -7,7 +7,6 @@ import { TrayIcon } from '@tauri-apps/api/tray'
|
||||
import { getAllWindows, getCurrentWindow } from '@tauri-apps/api/window'
|
||||
import { ask } from '@tauri-apps/plugin-dialog'
|
||||
import { platform } from '@tauri-apps/plugin-os'
|
||||
import { exit } from '@tauri-apps/plugin-process'
|
||||
import { buildMenu } from './menu'
|
||||
import { resetMainWindow } from './window'
|
||||
|
||||
@@ -89,7 +88,6 @@ export async function initLoadingTray() {
|
||||
const answer = await ask('An operation is in progress, are you sure you want to exit?')
|
||||
if (answer) {
|
||||
await getCurrentWindow().emit('close-app')
|
||||
await exit(0)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -12,13 +12,13 @@ import { isDirectoryEmpty } from './lib/fs'
|
||||
import { validateLicense } from './lib/license'
|
||||
import notify from './lib/notify'
|
||||
import {
|
||||
listJobs,
|
||||
listRemotes,
|
||||
mountRemote,
|
||||
startCopy,
|
||||
startDelete,
|
||||
startMove,
|
||||
startSync,
|
||||
unmountAllRemotes,
|
||||
} from './lib/rclone/api'
|
||||
import { initRclone } from './lib/rclone/init'
|
||||
import { usePersistedStore, useStore } from './lib/store'
|
||||
@@ -192,22 +192,48 @@ async function startRclone() {
|
||||
getCurrentWindow().listen('close-app', async (e) => {
|
||||
console.log('[startRclone] (main) window close-app requested')
|
||||
|
||||
if (rclone?.system) {
|
||||
const answer = await ask('Unmount all remotes before exiting?', {
|
||||
const jobs = await listJobs().catch(() => ({ active: [] }))
|
||||
|
||||
if (jobs.active.length > 0) {
|
||||
const answer = await ask('All active jobs will be stopped.', {
|
||||
title: 'Exit',
|
||||
kind: 'info',
|
||||
okLabel: 'Unmount',
|
||||
cancelLabel: 'Exit',
|
||||
okLabel: 'Quit',
|
||||
cancelLabel: 'Cancel',
|
||||
})
|
||||
if (answer) {
|
||||
await unmountAllRemotes()
|
||||
|
||||
if (!answer) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
await childProcess.kill()
|
||||
await exit(0)
|
||||
})
|
||||
console.log('[startRclone] set listener for close-app')
|
||||
|
||||
getCurrentWindow().listen('relaunch-app', async (e) => {
|
||||
console.log('[startRclone] (main) window relaunch-app requested')
|
||||
|
||||
const jobs = await listJobs().catch(() => ({ active: [] }))
|
||||
|
||||
if (jobs.active.length > 0) {
|
||||
const answer = await ask('All active jobs will be stopped.', {
|
||||
title: 'Exit',
|
||||
kind: 'info',
|
||||
okLabel: 'Relaunch',
|
||||
cancelLabel: 'Cancel',
|
||||
})
|
||||
if (!answer) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
await childProcess.kill()
|
||||
await relaunch()
|
||||
})
|
||||
console.log('[startRclone] set listener for relaunch-app')
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 200))
|
||||
|
||||
useStore.setState({ rcloneLoaded: true })
|
||||
@@ -485,10 +511,7 @@ async function checkVersion() {
|
||||
okLabel: 'Restart',
|
||||
})
|
||||
|
||||
await getCurrentWindow().emit('close-app')
|
||||
await new Promise((resolve) => setTimeout(resolve, 200))
|
||||
|
||||
await relaunch()
|
||||
await getCurrentWindow().emit('relaunch-app')
|
||||
} else if (compareVersions(currentVersion, okVersion) < 0) {
|
||||
const confirmed = await ask(
|
||||
'You are running an outdated version of Rclone UI. Please update to the latest version.',
|
||||
@@ -512,10 +535,7 @@ async function checkVersion() {
|
||||
okLabel: 'Restart',
|
||||
})
|
||||
|
||||
await getCurrentWindow().emit('close-app')
|
||||
await new Promise((resolve) => setTimeout(resolve, 200))
|
||||
|
||||
await relaunch()
|
||||
await getCurrentWindow().emit('relaunch-app')
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
@@ -354,9 +354,6 @@ function GeneralSection() {
|
||||
}
|
||||
|
||||
await getCurrentWindow().emit('close-app')
|
||||
await new Promise((resolve) => setTimeout(resolve, 200))
|
||||
|
||||
await relaunch()
|
||||
}, [update])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user