Watch article history over SSE so the tab stays current while open.

This commit is contained in:
seb
2026-08-05 09:48:30 +02:00
parent 60e6858fd5
commit 44d69e541c
3 changed files with 75 additions and 4 deletions

View File

@@ -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() {