Skip to content

Commit

Permalink
Merge pull request #54 from 0916dhkim/dispatch-on-save
Browse files Browse the repository at this point in the history
Dispatch RootAction On Save
  • Loading branch information
0916dhkim committed Mar 15, 2020
2 parents b711102 + 1df7e1c commit a72d630
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bookery",
"version": "0.10.1-alpha",
"version": "0.10.2-alpha",
"description": "======= Bookery =======",
"main": "dist/main/main.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions src/renderer/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,16 @@ async function saveFileMenuHandler(
try {
if (state.appData !== null) {
if (state.currentFilePath === null) {
// First time saving.
// Equivalent to "save as".
return saveAsFileMenuHandler(request, dispatch, state);
}
const appDataSerializer = new AppDataSerializer();
const serializedAppData = appDataSerializer.serialize(state.appData);
fs.writeFileSync(state.currentFilePath, serializedAppData, {
encoding: "utf8"
});
dispatch({ type: "Save As File", filePath: state.currentFilePath });
}
} catch {
throw "Failed to handle save menu event.";
Expand Down

0 comments on commit a72d630

Please sign in to comment.