diff --git a/pkg/interface/publish/src/js/components/lib/note.js b/pkg/interface/publish/src/js/components/lib/note.js index 055676e6a..ed1f0412c 100644 --- a/pkg/interface/publish/src/js/components/lib/note.js +++ b/pkg/interface/publish/src/js/components/lib/note.js @@ -33,6 +33,7 @@ export class Note extends Component { }); this.scrollElement = React.createRef(); this.onScroll = this.onScroll.bind(this); + this.deletePost = this.deletePost.bind(this); } componentWillMount() { @@ -47,6 +48,16 @@ export class Note extends Component { window.api.fetchNote(this.props.ship, this.props.book, this.props.note); } + componentDidMount() { + if (!(this.props.notebooks[this.props.ship]) || + !(this.props.notebooks[this.props.ship][this.props.book]) || + !(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note]) || + !(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note].file)) { + window.api.fetchNote(this.props.ship, this.props.book, this.props.note); + } + this.onScroll(); + } + componentDidUpdate(prevProps) { if (!(this.props.notebooks[this.props.ship]) || !(this.props.notebooks[this.props.ship][this.props.book]) || @@ -97,15 +108,23 @@ export class Note extends Component { } } - componentDidMount() { - if (!(this.props.notebooks[this.props.ship]) || - !(this.props.notebooks[this.props.ship][this.props.book]) || - !(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note]) || - !(this.props.notebooks[this.props.ship][this.props.book].notes[this.props.note].file)) - { - window.api.fetchNote(this.props.ship, this.props.book, this.props.note); + deletePost() { + const { props } = this; + let deleteAction = { + "del-note": { + who: this.props.ship.slice(1), + book: this.props.book, + note: this.props.note, + } } - this.onScroll(); + let popout = (props.popout) ? "popout/" : ""; + let baseUrl = `/~publish/${popout}notebook/${props.ship}/${props.book}`; + window.api.setSpinner(true); + window.api.action("publish", "publish-action", deleteAction) + .then(() => { + window.api.setSpinner(false); + props.history.push(baseUrl); + }); } render() { @@ -156,8 +175,11 @@ export class Note extends Component { let editPost = null; let editUrl = props.location.pathname + "/edit"; if (`~${window.ship}` === author) { - editPost = + editPost =
Edit +

this.deletePost())}>Delete

+
} let popout = (props.popout) ? "popout/" : ""; diff --git a/pkg/interface/publish/src/js/components/lib/notebook.js b/pkg/interface/publish/src/js/components/lib/notebook.js index c7a91ecbf..51b9cadd2 100644 --- a/pkg/interface/publish/src/js/components/lib/notebook.js +++ b/pkg/interface/publish/src/js/components/lib/notebook.js @@ -183,15 +183,15 @@ export class Notebook extends Component { ref={el => { this.scrollElement = el; }}> +
+ {"<- All Notebooks"} +
-
- {"<- All Notebooks"} -