Skip to content

Commit

Permalink
Save entry before app is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmeuli committed Jan 20, 2019
1 parent a5c7e0d commit 97a781d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/renderer/components/elements/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import TextareaAutosize from 'react-autosize-textarea';

import { toDateString, toIndexDate } from '../../../helpers/dateUtils';

const AUTOSAVE_INTERVAL = 500;
const AUTOSAVE_INTERVAL = 1000;


const propTypes = {
Expand Down Expand Up @@ -68,6 +68,11 @@ export default class Editor extends PureComponent {
this.onTitleChange = this.onTitleChange.bind(this);
this.saveEntry = this.saveEntry.bind(this);
this.saveEntryDebounced = debounce(this.saveEntry.bind(this), AUTOSAVE_INTERVAL);

// Save entry before app is closed
window.addEventListener('unload', () => {
this.saveEntry();
});
}

onTextChange(e) {
Expand Down

0 comments on commit 97a781d

Please sign in to comment.