feat: show toast when saving to existing file (#2988)
This commit is contained in:
parent
bf50c9cae7
commit
9c51ba6067
@ -96,9 +96,24 @@ export const actionChangeShouldAddWatermark = register({
|
|||||||
export const actionSaveScene = register({
|
export const actionSaveScene = register({
|
||||||
name: "saveScene",
|
name: "saveScene",
|
||||||
perform: async (elements, appState, value) => {
|
perform: async (elements, appState, value) => {
|
||||||
|
const fileHandleExists = !!appState.fileHandle;
|
||||||
try {
|
try {
|
||||||
const { fileHandle } = await saveAsJSON(elements, appState);
|
const { fileHandle } = await saveAsJSON(elements, appState);
|
||||||
return { commitToHistory: false, appState: { ...appState, fileHandle } };
|
return {
|
||||||
|
commitToHistory: false,
|
||||||
|
appState: {
|
||||||
|
...appState,
|
||||||
|
fileHandle,
|
||||||
|
toastMessage: fileHandleExists
|
||||||
|
? fileHandle.name
|
||||||
|
? t("toast.fileSavedToFilename").replace(
|
||||||
|
"{filename}",
|
||||||
|
`"${fileHandle.name}"`,
|
||||||
|
)
|
||||||
|
: t("toast.fileSaved")
|
||||||
|
: null,
|
||||||
|
},
|
||||||
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error?.name !== "AbortError") {
|
if (error?.name !== "AbortError") {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -243,6 +243,8 @@
|
|||||||
"toast": {
|
"toast": {
|
||||||
"copyStyles": "Copied styles.",
|
"copyStyles": "Copied styles.",
|
||||||
"copyToClipboard": "Copied to clipboard.",
|
"copyToClipboard": "Copied to clipboard.",
|
||||||
"copyToClipboardAsPng": "Copied to clipboard as PNG."
|
"copyToClipboardAsPng": "Copied to clipboard as PNG.",
|
||||||
|
"fileSaved": "File saved.",
|
||||||
|
"fileSavedToFilename": "Saved to {filename}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user