From 9dc6818fd76ac776e3c8693bbd18caf667a26bdb Mon Sep 17 00:00:00 2001 From: undefined Date: Sat, 29 Oct 2022 17:10:46 +0800 Subject: [PATCH] ui: scratchpad: use seperate cooldown for pretest and submit --- .../scratchpad/ScratchpadToolbarContainer.jsx | 16 ++++---- .../components/scratchpad/reducers/ui.ts | 38 +++++++++++-------- packages/ui-default/package.json | 2 +- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx b/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx index a18dd3d5d..e774f1155 100644 --- a/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx +++ b/packages/ui-default/components/scratchpad/ScratchpadToolbarContainer.jsx @@ -18,8 +18,8 @@ const mapStateToProps = (state) => ({ recordsVisible: state.ui.records.visible, isPosting: state.ui.isPosting, isRunning: state.pretest.isRunning, - isWaiting: state.ui.isWaiting, - waitSec: state.ui.waitSec, + pretestWaitSec: state.ui.pretestWaitSec, + submitWaitSec: state.ui.submitWaitSec, editorLang: state.editor.lang, editorCode: state.editor.code, pretestInput: state.pretest.input, @@ -96,7 +96,9 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool } componentDidUpdate() { - if (this.props.waitSec > 0) setTimeout(() => this.props.tick(), 1000); + if (this.props.pretestWaitSec > 0 || this.props.submitWaitSec > 0) { + setTimeout(() => this.props.tick(), 1000); + } } render() { @@ -109,7 +111,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool {canUsePretest && ( this.props.postPretest(this.props)} data-global-hotkey="f9" @@ -119,11 +121,11 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool {' '} {i18n('Run Pretest')} {' '} - {this.props.isWaiting ? `(${this.props.waitSec}s)` : '(F9)'} + {this.props.pretestWaitSec ? `(${this.props.pretestWaitSec}s)` : '(F9)'} )} this.props.postSubmit(this.props)} data-global-hotkey="f10" @@ -133,7 +135,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadTool {' '} {i18n('Submit Solution')} {' '} - {this.props.isWaiting ? `(${this.props.waitSec}s)` : '(F10)'} + {this.props.submitWaitSec ? `(${this.props.submitWaitSec}s)` : '(F10)'} 1, + lastTick: Date.now(), + pretestWaitSec: Math.max(state.pretestWaitSec - 1, 0), + submitWaitSec: Math.max(state.submitWaitSec - 1, 0), }; } case 'SCRATCHPAD_RECORDS_LOAD_SUBMISSIONS_PENDING': { diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index ec3611dce..724cff267 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.42.13", + "version": "4.42.14", "author": "undefined ", "license": "AGPL-3.0", "main": "index.ts",