Commit 715eb109 authored by Juan Manuel Solaro's avatar Juan Manuel Solaro

(chore) move isScheduled function to a class method

1 merge request!370[Sprint/OldfashionedOwl] (chore) add yellow flag to scheduled activities
......@@ -7,7 +7,6 @@ import MdIcon from 'react-native-vector-icons/MaterialIcons';
import Colors from '../styles/Colors';
import Touchable from '../common/components/Touchable';
import Modal from 'react-native-modal';
import { CheckBox } from 'react-native-elements'
import TransparentButton from '../common/components/TransparentButton';
import LicensePicker from '../common/components/LicensePicker';
import TagInput from '../common/components/TagInput';
......@@ -19,6 +18,7 @@ import { GOOGLE_PLAY_STORE } from '../config/Config';
import testID from '../common/helpers/testID';
import i18n from '../common/services/i18n.service';
import DateTimePicker from 'react-native-modal-datetime-picker';
import BaseModel from '../common/BaseModel';
@inject('capture')
......@@ -211,22 +211,10 @@ export default class CapturePosterFlags extends Component {
this.setState({ datePickerVisible: false });
}
/**
* Is considered scheduled when time_created is setted and is gt current time
*/
isScheduled = () => {
let response = false;
if (this.props.timeCreatedValue) {
const timeCreatedValue = new Date(this.props.timeCreatedValue);
response = timeCreatedValue.getTime() > Date.now();
}
return response;
}
shouldRenderScheduler = () => {
const hasFeature = featuresService.has('post-scheduler');
return hasFeature && (this.isScheduled() || !this.timeCreatedValue);
const timeCreatedValue = this.props.timeCreatedValue;
return hasFeature && (!timeCreatedValue || BaseModel.isScheduled(timeCreatedValue));
}
// Locking (Wire Threshold)
......@@ -430,7 +418,7 @@ export default class CapturePosterFlags extends Component {
{this.shouldRenderScheduler() && <Touchable style={[styles.cell, styles.cell__last]} onPress={this.showDatePicker}>
<IonIcon
name="md-calendar"
color={this.isScheduled() ? Colors.primary : Colors.darkGreyed}
color={BaseModel.isScheduled(this.props.timeCreatedValue) ? Colors.primary : Colors.darkGreyed}
size={30}
{...testID('Post scheduler button')}
/>
......
import {
extendObservable,
decorate,
observable,
action,
computed,
runInAction,
toJS,
} from 'mobx';
import _ from 'lodash';
import sessionService from './services/session.service';
import { vote } from './services/votes.service';
import { toggleExplicit, toggleUserBlock, update } from '../newsfeed/NewsfeedService';
import { toggleExplicit } from '../newsfeed/NewsfeedService';
import logService from './services/log.service';
import channelService from '../channel/ChannelService';
import { revokeBoost, acceptBoost, rejectBoost } from '../boost/BoostService';
......@@ -284,4 +281,19 @@ export default class BaseModel {
const data = await toggleAllow(this.guid, !this.allow_comments);
this.allow_comments = !this.allow_comments;
}
isScheduled() {
return this.time_created * 1000 > Date.now();
}
static isScheduled(timeCreatedValue) {
let response = false;
if (timeCreatedValue) {
timeCreatedValue = new Date(timeCreatedValue);
response = timeCreatedValue.getTime() > Date.now();
}
return response;
}
}
\ No newline at end of file
......@@ -109,22 +109,20 @@ export default class Activity extends Component {
{ overlay }
</View>
{ this.showActions() }
{ this.isScheduled() &&
{ this.props.entity.isScheduled() &&
<View style={[{backgroundColor: '#ffecb3'}, CommonStyle.padding]}>
<Text style={[styles.scheduledText, CommonStyle.paddingLeft]}>
{`${i18n.t('activity.scheduled')} ${formatDate(this.props.entity.time_created)}.`}
</Text>
</View> }
{ this.props.isLast ? <View style={styles.activitySpacer}></View> : null}
{ !this.props.hideTabs && !this.isScheduled() && <ActivityMetrics entity={this.props.entity}/> }
{ !this.props.hideTabs &&
!this.props.entity.isScheduled() &&
<ActivityMetrics entity={this.props.entity}/> }
</View>
);
}
isScheduled() {
return this.props.entity.time_created * 1000 > Date.now();
}
/**
* Pause video if exist
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment