diff --git a/src/post.js b/src/post.js index 2dcc841..b3b3c99 100644 --- a/src/post.js +++ b/src/post.js @@ -2,26 +2,34 @@ import React from 'react'; import Tag from './tag.js'; import TagSuggest from './tag-suggest.js'; -function renderTags(props) { - let tagReturn = [] - if (props.post.Tags !== null) { - tagReturn = props.post.Tags.map((t) => { - return() - }) +class Post extends React.Component { + renderTags(props) { + let tagReturn = [] + if (props.post.Tags !== null) { + tagReturn = props.post.Tags.map((t) => { + return() + }) + } + tagReturn.push() + return tagReturn + } + + componentDidUpdate(prevProps) { + if (this.props.post.Hash !== prevProps.post.Hash) { + this.props.postUpdated() + } } - tagReturn.push() - return tagReturn -} -function Post(props) { - return( -
-

{props.post.Description}

- -
{props.post.Extended}
-
Tags: {renderTags(props)}
-
- ); + render() { + return( +
+

{this.props.post.Description}

+ +
{this.props.post.Extended}
+
Tags: {this.renderTags(this.props)}
+
+ ); + } } export default Post; diff --git a/src/tagger.js b/src/tagger.js index 1774e0a..d11f26f 100644 --- a/src/tagger.js +++ b/src/tagger.js @@ -23,6 +23,7 @@ class Tagger extends React.Component { this.nextPost = this.nextPost.bind(this) this.prevPost = this.prevPost.bind(this) this.handleDateChange = this.handleDateChange.bind(this) + this.postUpdated = this.postUpdated.bind(this) } async componentDidMount() { @@ -192,6 +193,12 @@ class Tagger extends React.Component { }) } + postUpdated() { + this.setState({ + taggerToast: "" + }) + } + render() { const keyMap = { LEFTARROW: "ArrowLeft", @@ -221,6 +228,7 @@ class Tagger extends React.Component { deleteTag={this.deleteTag} addTag={this.addTag} allTags={this.state.allTags} + postUpdated={this.postUpdated} />
{this.state.taggerToast}