From a4108210ee4ab1f98433e98795b619964e285941 Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Wed, 12 Feb 2020 00:40:10 +0800 Subject: [PATCH] improve trash #228 --- src/renderer.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/renderer.jsx b/src/renderer.jsx index a667a75f..074c7a0c 100644 --- a/src/renderer.jsx +++ b/src/renderer.jsx @@ -497,12 +497,18 @@ class App extends React.Component { deleteSourceClick = async () => { // eslint-disable-next-line no-alert if (this.state.working || !window.confirm('Are you sure you want to move the source file to trash?')) return; - const { filePath, html5FriendlyPath } = this.state; - this.setState({ working: true }); - await trash(filePath); - if (html5FriendlyPath) await trash(html5FriendlyPath); - this.resetState(); + try { + this.setState({ working: true }); + + const { filePath, html5FriendlyPath } = this.state; + await trash(filePath); + if (html5FriendlyPath) await trash(html5FriendlyPath); + } catch (err) { + toast.fire({ type: 'error', title: `Failed to trash source file: ${err.message}` }); + } finally { + this.resetState(); + } } cutClick = async () => {