mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-22 12:51:42 +03:00
Merge pull request #1439 from esteemapp/rev
revert getTimeFromNow to moment usage until Intl support is added int…
This commit is contained in:
commit
454fc6b38a
Binary file not shown.
@ -32,17 +32,7 @@ const UserListItem = ({
|
|||||||
<UserAvatar noAction={userCanPress} style={styles.avatar} username={username} />
|
<UserAvatar noAction={userCanPress} style={styles.avatar} username={username} />
|
||||||
<View style={styles.userDescription}>
|
<View style={styles.userDescription}>
|
||||||
<Text style={styles.name}>{text || username}</Text>
|
<Text style={styles.name}>{text || username}</Text>
|
||||||
{description && (
|
{description && <Text style={styles.date}>{description}</Text>}
|
||||||
<Text style={styles.date}>
|
|
||||||
<FormattedRelativeTime
|
|
||||||
value={description.value}
|
|
||||||
numeric="auto"
|
|
||||||
// eslint-disable-next-line react/style-prop-object
|
|
||||||
style="short"
|
|
||||||
unit={description.unit}
|
|
||||||
/>
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
{middleText && (
|
{middleText && (
|
||||||
<View style={styles.middleWrapper}>
|
<View style={styles.middleWrapper}>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { View, Text, TouchableOpacity } from 'react-native';
|
import { View, Text, TouchableOpacity } from 'react-native';
|
||||||
import { withNavigation } from 'react-navigation';
|
import { withNavigation } from 'react-navigation';
|
||||||
import { injectIntl, FormattedRelativeTime } from 'react-intl';
|
import { injectIntl } from 'react-intl';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { Tag } from '../../../basicUIElements';
|
import { Tag } from '../../../basicUIElements';
|
||||||
@ -78,17 +78,7 @@ class PostHeaderDescription extends PureComponent {
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
<Text style={styles.date}>
|
<Text style={styles.date}>
|
||||||
{isPromoted ? (
|
{isPromoted ? intl.formatMessage({ id: 'post.sponsored' }) : date}
|
||||||
intl.formatMessage({ id: 'post.sponsored' })
|
|
||||||
) : (
|
|
||||||
<FormattedRelativeTime
|
|
||||||
value={date.value}
|
|
||||||
// eslint-disable-next-line react/style-prop-object
|
|
||||||
style="short"
|
|
||||||
numeric="auto"
|
|
||||||
unit={date.unit}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Text>
|
</Text>
|
||||||
{isShowOwnerIndicator && (
|
{isShowOwnerIndicator && (
|
||||||
<Icon style={styles.ownerIndicator} name="stars" iconType="MaterialIcons" />
|
<Icon style={styles.ownerIndicator} name="stars" iconType="MaterialIcons" />
|
||||||
|
@ -45,6 +45,7 @@ class PostListItemView extends Component {
|
|||||||
handleOnRemoveItem,
|
handleOnRemoveItem,
|
||||||
id,
|
id,
|
||||||
intl,
|
intl,
|
||||||
|
isFormatedDate,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -52,7 +53,7 @@ class PostListItemView extends Component {
|
|||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<View style={styles.header}>
|
<View style={styles.header}>
|
||||||
<PostHeaderDescription
|
<PostHeaderDescription
|
||||||
date={getTimeFromNow(created)}
|
date={isFormatedDate ? created : getTimeFromNow(created, true)}
|
||||||
name={username}
|
name={username}
|
||||||
reputation={reputation}
|
reputation={reputation}
|
||||||
size={36}
|
size={36}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React, { Component, Fragment } from 'react';
|
import React, { Component, Fragment } from 'react';
|
||||||
import { View, TouchableOpacity, Text, Alert } from 'react-native';
|
import { View, TouchableOpacity, Text, Alert } from 'react-native';
|
||||||
import { injectIntl, FormattedRelativeTime } from 'react-intl';
|
import { injectIntl } from 'react-intl';
|
||||||
import { Popover, PopoverController } from 'react-native-modal-popover';
|
import { Popover, PopoverController } from 'react-native-modal-popover';
|
||||||
import Slider from 'react-native-slider';
|
import Slider from 'react-native-slider';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
@ -331,14 +331,7 @@ class UpvoteView extends Component {
|
|||||||
<Text style={styles.detailsText}>
|
<Text style={styles.detailsText}>
|
||||||
{`${intl.formatMessage({
|
{`${intl.formatMessage({
|
||||||
id: 'payout.payout_date',
|
id: 'payout.payout_date',
|
||||||
})} `}
|
})} ${payoutDate}`}
|
||||||
<FormattedRelativeTime
|
|
||||||
value={payoutDate.value}
|
|
||||||
numeric="auto"
|
|
||||||
// eslint-disable-next-line react/style-prop-object
|
|
||||||
style="short"
|
|
||||||
unit={payoutDate.unit}
|
|
||||||
/>
|
|
||||||
</Text>
|
</Text>
|
||||||
{warnZeroPayout && (
|
{warnZeroPayout && (
|
||||||
<Text style={styles.detailsText}>
|
<Text style={styles.detailsText}>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
const TODAY = new Date();
|
const TODAY = new Date();
|
||||||
const ONE_DAY = new Date(TODAY.getTime() - 24 * 60 * 60 * 1000);
|
const ONE_DAY = new Date(TODAY.getTime() - 24 * 60 * 60 * 1000);
|
||||||
const SEVEN_DAY = new Date(TODAY.getTime() - 7 * 24 * 60 * 60 * 1000);
|
const SEVEN_DAY = new Date(TODAY.getTime() - 7 * 24 * 60 * 60 * 1000);
|
||||||
@ -9,7 +11,8 @@ const WEEK = 60 * 60 * 24 * 7;
|
|||||||
const MONTH = 60 * 60 * 24 * 30;
|
const MONTH = 60 * 60 * 24 * 30;
|
||||||
const YEAR = 60 * 60 * 24 * 365;
|
const YEAR = 60 * 60 * 24 * 365;
|
||||||
|
|
||||||
export const getTimeFromNow = d => {
|
// TODO: once hermes has Intl support, enable native version
|
||||||
|
export const getTimeFromNowNative = d => {
|
||||||
if (!d) {
|
if (!d) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -49,6 +52,17 @@ export const getTimeFromNow = d => {
|
|||||||
}
|
}
|
||||||
return { unit: 'day', value: future ? Math.round(diff / DAY) : -Math.round(diff / DAY) };
|
return { unit: 'day', value: future ? Math.round(diff / DAY) : -Math.round(diff / DAY) };
|
||||||
};
|
};
|
||||||
|
export const getTimeFromNow = (value, isWithoutUtc) => {
|
||||||
|
if (!value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isWithoutUtc) {
|
||||||
|
return moment(value).fromNow(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return moment.utc(value).fromNow(true);
|
||||||
|
};
|
||||||
|
|
||||||
export const getFormatedCreatedDate = value => {
|
export const getFormatedCreatedDate = value => {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user