From 0d564bcf05cccdbc2d0a8dd7bc63020d944fd072 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Wed, 15 May 2024 11:47:24 +0530 Subject: [PATCH] combine into single if --- packages/excalidraw/components/App.tsx | 28 +++++++++++--------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index 843f57ec3..4d0c1d796 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -1777,25 +1777,21 @@ class App extends React.Component { this.setState({ errorMessage: error.message }); }); - if (fileHandle && isImageFileHandle(fileHandle)) { + if (type === "clipboard" || (fileHandle && isImageFileHandle(fileHandle))) { this.setState({ - fileHandle: this.state.exportEmbedScene ? fileHandle : null, + fileHandle: + fileHandle && this.state.exportEmbedScene ? fileHandle : null, openDialog: null, toast: { - message: fileHandle?.name - ? t("toast.fileSavedToFilename").replace( - "{filename}", - `"${fileHandle.name}"`, - ) - : t("toast.fileSaved"), - duration: 1500, - }, - }); - } else if (type === "clipboard") { - this.setState({ - openDialog: null, - toast: { - message: t("toast.copyToClipboard"), + message: + type === "clipboard" + ? t("toast.copyToClipboard") + : fileHandle?.name + ? t("toast.fileSavedToFilename").replace( + "{filename}", + `"${fileHandle.name}"`, + ) + : t("toast.fileSaved"), duration: 1500, }, });