Skip to content

Commit

Permalink
Merge pull request #252 from systemli/remove-prepend-time
Browse files Browse the repository at this point in the history
🔥 Remove prepend time capability
  • Loading branch information
0x46616c6b authored Apr 9, 2022
2 parents 35fb7a5 + c5bc834 commit 9747cdf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 29 deletions.
14 changes: 6 additions & 8 deletions src/components/MessageForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const initialState = {
formErrorMessage: '',
};

const MESSAGE_LIMIT = 280;

export default class MessageForm extends React.Component {
constructor(props) {
super(props);
Expand All @@ -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';
Expand All @@ -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;
}

Expand Down Expand Up @@ -218,7 +216,7 @@ export default class MessageForm extends React.Component {
onChange={this.uploadAttachment.bind(this)}
/>
<Label
content={`${state.counter}/${this.counterLimit()}`}
content={`${state.counter}/${MESSAGE_LIMIT}`}
color={state.counterColor} style={{float: 'right'}}
/>
</Form>
Expand Down
12 changes: 1 addition & 11 deletions src/components/Ticker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import {Button, Card, Confirm, Divider, Icon, Label, Popup} from 'semantic-ui-react';
import {Button, Card, Confirm, Icon, Label} from 'semantic-ui-react';
import {deleteTicker} from "../api/Ticker";
import PropTypes from 'prop-types';
import ReactMarkdown from "react-markdown";
Expand Down Expand Up @@ -108,15 +108,6 @@ export default class Ticker extends React.Component {
<Card.Description>
<ReactMarkdown source={this.props.ticker.description}/>
</Card.Description>
<Card.Description>
<Divider />
<Icon color={this.props.ticker.prepend_time ? 'green' : 'gray'}
name={this.props.ticker.prepend_time ? 'toggle on' : 'toggle off'}
/>
Prepend Time
<Popup content='This will prepend the time (in format 13:12) to the message'
trigger={<Button basic color='black' compact circular icon='info' size='tiny' style={{marginLeft: '.5em'}}/>}/>
</Card.Description>
</Card.Content>
<Card.Content>
<Button.Group size='tiny' fluid compact>
Expand Down Expand Up @@ -147,7 +138,6 @@ Ticker.propTypes = {
domain: PropTypes.string,
description: PropTypes.string,
active: PropTypes.bool,
prepend_time: PropTypes.bool,
information: PropTypes.shape({
author: PropTypes.string,
url: PropTypes.string,
Expand Down
9 changes: 1 addition & 8 deletions src/components/TickerForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class TickerForm extends React.Component {
}

let formData = CommonUtils.mapValueArray(
['title', 'domain', 'description', 'active', 'prepend_time'],
['title', 'domain', 'description', 'active'],
this.form,
this.props.ticker
);
Expand Down Expand Up @@ -172,13 +172,6 @@ export default class TickerForm extends React.Component {
onChange={(event, input) => this.form.description = input.value}
required
/>
<Form.Checkbox
toggle
label='Prepend Time'
name='prepend_time'
defaultChecked={this.props.ticker.prepend_time}
onChange={(event, input) => this.form.prepend_time = input.checked}
/>
<Header dividing>Information</Header>
<Form.Group widths='equal'>
<Form.Input label='Author'>
Expand Down
2 changes: 0 additions & 2 deletions src/models/Ticker.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export default class Ticker {
this.domain = undefined !== props.domain ? props.domain : null;
this.description = undefined !== props.description ? props.description : null;
this.active = undefined !== props.active ? props.active : false;
this.prepend_time = undefined !== props.prepend_time ? props.prepend_time : false;

if (undefined !== props.information) {
this.information = {
Expand Down Expand Up @@ -69,7 +68,6 @@ Ticker.propTypes = {
domain: PropTypes.string,
description: PropTypes.string,
active: PropTypes.bool,
prepend_time: PropTypes.bool,
information: PropTypes.shape({
author: PropTypes.string,
url: PropTypes.string,
Expand Down

0 comments on commit 9747cdf

Please sign in to comment.