aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/ConnectionContent.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/components/ConnectionContent.js')
-rw-r--r--frontend/src/components/ConnectionContent.js28
1 files changed, 19 insertions, 9 deletions
diff --git a/frontend/src/components/ConnectionContent.js b/frontend/src/components/ConnectionContent.js
index 0c00e8e..0069424 100644
--- a/frontend/src/components/ConnectionContent.js
+++ b/frontend/src/components/ConnectionContent.js
@@ -22,20 +22,30 @@ class ConnectionContent extends Component {
this.setFormat = this.setFormat.bind(this);
}
+ componentDidMount() {
+ if (this.props.connection != null) {
+ this.loadStream();
+ }
+ }
+
componentDidUpdate(prevProps, prevState, snapshot) {
- if (this.props.connection !== null && (
+ if (this.props.connection != null && (
this.props.connection !== prevProps.connection || this.state.format !== prevState.format)) {
- this.setState({loading: true});
- // TODO: limit workaround.
- backend.get(`/api/streams/${this.props.connection.id}?format=${this.state.format}&limit=999999`).then(res => {
- this.setState({
- connectionContent: res,
- loading: false
- });
- });
+ this.loadStream();
}
}
+ loadStream = () => {
+ this.setState({loading: true});
+ // TODO: limit workaround.
+ backend.getJson(`/api/streams/${this.props.connection.id}?format=${this.state.format}&limit=999999`).then(res => {
+ this.setState({
+ connectionContent: res,
+ loading: false
+ });
+ });
+ };
+
setFormat(format) {
if (this.validFormats.includes(format)) {
this.setState({format: format});