Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showSaveDialogSync is not working #491

Open
AlejandroFNadal opened this issue Aug 26, 2024 · 2 comments
Open

showSaveDialogSync is not working #491

AlejandroFNadal opened this issue Aug 26, 2024 · 2 comments

Comments

@AlejandroFNadal
Copy link

AlejandroFNadal commented Aug 26, 2024

Hello @saltyshiomix , and the Nextron Community:

The showSaveDialogSync seems not to be working.

Code example:

ipcMain.on("save-as", (event, data) => {
    console.log("Save As: Main Process");
    console.log(`Data: ${JSON.stringify(data)}`);
    try {
      console.log("Before Dialog");
      const path = dialog.showSaveDialogSync({});
      console.log("After Dialog");
      if (path) {
        console.log("Path selected");
        console.log(`Path: ${path}`);
        const fileBuffer = Buffer.from(data, "base64");
        fs.writeFile(path, fileBuffer, (err) => {
          if (err) {
            console.log(err);
            return;
          }
        });
      } else {
        console.log("No path selected");
      }
    } catch (error) {
      console.log("Error in save-as");
      console.log(error);
    }
    console.log("Save As in Main Process Done");
  });
}

Result:

Save As: Main Process
Data: "NiaMTwAAAAAAABkBAAAAAAAAAAAEAAAAEAQAAAAICAAHQBwAAAgDoAwAAAQAEVGVzdAAACAdTaWduYWwxAAABAACAPwAAgD8AAAAAAAAAAAA="

Before Dialog

As you can see, nothing is happening after the dialog (I have tried both saving and canceling the dialog).
It does work if I convert everything to a async dialog.

Might it be related to this bug? electron/electron#31152

It is a very old bug though, the project is on Electron 31 right?

Thanks for your time and your work for the community @saltyshiomix .

EDIT: I have no idea what those links from those people are down below, but I highly recommend not clicking them. I have reported them to Github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@AlejandroFNadal and others