avoiding vote time rendering from past

This commit is contained in:
Nouman Tahir 2021-07-26 00:26:51 +05:00
parent b25f7be3d5
commit 94462fbaa8
2 changed files with 8 additions and 3 deletions

View File

@ -15,7 +15,7 @@ import ROUTES from '../../../constants/routeNames';
// Styles
import styles from './votersDisplayStyles';
const VotersDisplayView = ({ votes, navigation }) => {
const VotersDisplayView = ({ votes, navigation, createdAt = '2010-01-01T00:00:00' }) => {
const intl = useIntl();
/*getActiveVotes(get(content, 'author'), get(content, 'permlink'))
@ -41,11 +41,16 @@ const VotersDisplayView = ({ votes, navigation }) => {
const value = `$ ${item.reward}`;
const percent = `${item.percent}%`;
//snippet to avoid rendering time form long past
const minTimestamp = new Date(createdAt).getTime();
const voteTimestamp = new Date(item.time).getTime();
const timeString = item.time && minTimestamp < voteTimestamp ? getTimeFromNow(item.time) : null;
return (
<UserListItem
index={index}
username={item.voter}
description={getTimeFromNow(item.time)}
description={timeString}
isHasRightItem
isRightColor={item.is_down_vote}
rightText={value}

View File

@ -74,7 +74,7 @@ const VotersScreen = ({ navigation }) => {
selectedOptionIndex={filterIndex}
onDropdownSelect={handleOnVotersDropdownSelect}
/>
<VotersDisplay votes={filterResult || data} />
<VotersDisplay votes={filterResult || data} createdAt={content.created} />
</>
)}
</AccountListContainer>