From 38fe1800e137d7497db5556eed2caaf4eeaa9f72 Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Mon, 2 Apr 2018 22:13:07 +0200 Subject: [PATCH] Close snacks faster if the queue is filled --- ui/src/component/SnackBarHandler.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ui/src/component/SnackBarHandler.js b/ui/src/component/SnackBarHandler.js index 35fc705..c6648cc 100644 --- a/ui/src/component/SnackBarHandler.js +++ b/ui/src/component/SnackBarHandler.js @@ -10,6 +10,7 @@ class SnackBarHandler extends Component { state = { current: '', + hasNext: false, open: false, openWhen: 0, }; @@ -40,6 +41,7 @@ class SnackBarHandler extends Component { open: true, openWhen: Date.now(), current: SnackBarStore.next(), + hasNext: SnackBarStore.hasNext(), }); } }; @@ -47,19 +49,22 @@ class SnackBarHandler extends Component { closeCurrentSnack = () => this.setState({...this.state, open: false}); render() { - const {open, current} = this.state; + const {open, current, hasNext} = this.state; + const duration = hasNext + ? SnackBarHandler.MIN_VISIBLE_SNACK_TIME_IN_MS + : SnackBarHandler.MAX_VISIBLE_SNACK_TIME_IN_MS; return ( {current}} - action={[ + action={ - , - ]} + + } /> ); }