From e72b87c9bf5a8fc0bbef5e511a2cbc8fce110c89 Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Mon, 9 Nov 2020 15:30:15 +0200 Subject: [PATCH 1/3] Fix #932 : fix start scene button in scene list --- front/src/routes/scene/SceneCard.jsx | 55 ++++++++++++++++++---------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/front/src/routes/scene/SceneCard.jsx b/front/src/routes/scene/SceneCard.jsx index 8bd4830dee..5ac5e07e41 100644 --- a/front/src/routes/scene/SceneCard.jsx +++ b/front/src/routes/scene/SceneCard.jsx @@ -1,34 +1,49 @@ import { Text } from 'preact-i18n'; import { Component } from 'preact'; import { Link } from 'preact-router/match'; +import cx from 'classnames'; import style from './style.css'; class SceneCard extends Component { - startScene = () => { - this.props.startScene(this.props.scene.selector); + startScene = async () => { + try { + await this.setState({ saving: true }); + await this.props.httpClient.post(`/api/v1/scene/${this.props.scene.selector}/start`); + } catch (e) {} + // make sure the loader is displayed at least 200ms + setTimeout(() => this.setState({ saving: false }), 200); }; - render(props, {}) { + render(props, { saving }) { return (
-
-
- -
-

{props.scene.name}

-
{props.scene.description}
-
-