Skip to content
Advertisement

Electron window reloads when saved file is overwriten / replaced

So, I have the save function written and it works exactly as intended the first time I save a file. However, if I try to overwrite the file by saving it again, the file saves fine, but the window reloads clearing all the data that’s been entered. I can just load the saved file and continue editing, but that will get annoying fast. I cannot find any info on how to resolve this issue, anywhere. Any help would be greatly appreciated.

JavaScript

And here is the menu template entry:

JavaScript

And the getItem1 function:

JavaScript

Advertisement

Answer

Now I’m feeling a bit dumb. It turns out that the reason it was reloading was because I’m using the electron-reload package to automatically reload the page when I save the source files. It was also causing the page to reload when the save file was overwritten. Good to know going forward.

Edit:

You can tell electron-reload to ignore a directory by ammending your require statement to look something like this:

JavaScript

https://github.com/yan-foto/electron-reload#api

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement