publish: catch duplicate note titles

This commit is contained in:
Matilde Park 2020-02-25 18:31:50 -05:00
parent 1272a61443
commit c8fe63dddc

View File

@ -32,12 +32,17 @@ export class NewPost extends Component {
}
}
this.setState({
awaiting: newNote["new-note"].note
}, () => {
window.api.setSpinner(true);
window.api.action("publish", "publish-action", newNote);
});
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);
}
});
}
componentWillMount() {