Watch article history over SSE so the tab stays current while open.
This commit is contained in:
@@ -17,13 +17,20 @@ export default class ArticleHistoryTab extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { history: null };
|
||||
this.unwatchHistory = null;
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
void this.context.article
|
||||
.history(this.props.sku)
|
||||
.then((res) => this.setState({ history: res.history }))
|
||||
.catch(notifyError);
|
||||
this.unwatchHistory = this.context.article.historyWatch(
|
||||
this.props.sku,
|
||||
(history) => this.setState({ history }),
|
||||
notifyError,
|
||||
);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.unwatchHistory?.();
|
||||
this.unwatchHistory = null;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user