From c5bc8344a1d4cf8b95fee308dec12c317d8aa663 Mon Sep 17 00:00:00 2001 From: louis Date: Sat, 9 Apr 2022 16:20:49 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20Remove=20prepend=20time=20capabi?= =?UTF-8?q?lity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MessageForm.js | 14 ++++++-------- src/components/Ticker.js | 12 +----------- src/components/TickerForm.js | 9 +-------- src/models/Ticker.js | 2 -- 4 files changed, 8 insertions(+), 29 deletions(-) diff --git a/src/components/MessageForm.js b/src/components/MessageForm.js index f9619873..14e54a48 100644 --- a/src/components/MessageForm.js +++ b/src/components/MessageForm.js @@ -17,6 +17,8 @@ const initialState = { formErrorMessage: '', }; +const MESSAGE_LIMIT = 280; + export default class MessageForm extends React.Component { constructor(props) { super(props); @@ -26,19 +28,15 @@ export default class MessageForm extends React.Component { this.state = initialState; } - counterLimit() { - return this.props.ticker.prepend_time ? 274 : 280 - } - handleInput(event, input) { let color; let errorMessage = ''; let error = false; //TODO: Calculate length for Twitter (cutting links to 20 characters) - if (input.value.length > this.counterLimit()) { + if (input.value.length > MESSAGE_LIMIT) { color = 'red'; - errorMessage = `The message is too long. You must remove ${input.value.length - this.counterLimit()} characters.`; + errorMessage = `The message is too long. You must remove ${input.value.length - MESSAGE_LIMIT} characters.`; error = true; } else if (input.value.length >= 260) { color = 'orange'; @@ -61,7 +59,7 @@ export default class MessageForm extends React.Component { let message = this.state.message, id = this.props.ticker.id, geoInformation = this.state.geoInformation, attachments = []; const {length} = message; - if (length === 0 || length > this.counterLimit()) { + if (length === 0 || length > MESSAGE_LIMIT) { return; } @@ -218,7 +216,7 @@ export default class MessageForm extends React.Component { onChange={this.uploadAttachment.bind(this)} />