publish: catch duplicate note titles
@@ -32,11 +32,16 @@ export class NewPost extends Component {
}
}
- this.setState({
- awaiting: newNote["new-note"].note
- }, () => {
window.api.setSpinner(true);
+ window.api.action("publish", "publish-action", newNote).then(() =>{
+ this.setState({ awaiting: newNote["new-note"].note });
+ }).catch((err) => {
+ if (err.includes("note already exists")) {
+ let timestamp = Math.floor(Date.now() / 1000);
+ newNote["new-note"].note += "-" + timestamp;
+ this.setState({awaiting: newNote["new-note"].note});
window.api.action("publish", "publish-action", newNote);
+ }
});
}
