From 89bdce3dedaa22eec4e5481449e2977d8dbb6849 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 30 May 2021 17:59:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20even=20more=20bugs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nest_frontend/components/interactive/FormInlineTimeRay.js | 8 +++++--- nest_frontend/objects/Filter.js | 1 - nest_frontend/objects/TimeRay.js | 4 +--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/nest_frontend/components/interactive/FormInlineTimeRay.js b/nest_frontend/components/interactive/FormInlineTimeRay.js index 6aa1a04..7e4cce7 100644 --- a/nest_frontend/components/interactive/FormInlineTimeRay.js +++ b/nest_frontend/components/interactive/FormInlineTimeRay.js @@ -37,19 +37,21 @@ export default function FormInlineTimeRay( ) { const [isBefore, setBefore] = useState(false) const [value, setValue] = useState("") + const [disabled, setDisabled] = useState(true) const _onSubmit = event => { event.preventDefault() if(!value) { return } - console.debug(value) submit(new TimeRay(isBefore, new Date(value))) setValue("") } const _onChange = event => { - setValue(validate(event.target.value.toUpperCase().replace(INVALID_CHARACTERS, ""))) + const newValue = validate(event.target.value.toUpperCase().replace(INVALID_CHARACTERS, "")) + setValue(newValue) + setDisabled(!value || isNaN(new Date(newValue).getDate())) } return ( @@ -71,7 +73,7 @@ export default function FormInlineTimeRay( icon={buttonIcon} color={buttonColor} onClick={_onSubmit} - disabled={!value} + disabled={disabled} /> ) diff --git a/nest_frontend/objects/Filter.js b/nest_frontend/objects/Filter.js index 7b096fb..45af9b0 100644 --- a/nest_frontend/objects/Filter.js +++ b/nest_frontend/objects/Filter.js @@ -211,7 +211,6 @@ export class FilterInsideTimeRay extends Filter { } check(tweet) { - console.debug(this.timeRay.date, tweet["post_time"]) return this.timeRay.includes(new Date(tweet["post_time"])) } diff --git a/nest_frontend/objects/TimeRay.js b/nest_frontend/objects/TimeRay.js index b3779ef..a0b64ec 100644 --- a/nest_frontend/objects/TimeRay.js +++ b/nest_frontend/objects/TimeRay.js @@ -38,8 +38,6 @@ export default class TimeRay { } includes(date) { - return Boolean(( - this.date > date - ) ^ this.isBefore) + return Boolean((date > this.date) ^ this.isBefore) } }