Skip to content

Commit

Permalink
Merge pull request #29 from vj-abishek/vj-abishek-patch-1
Browse files Browse the repository at this point in the history
fix: date undefined issue
  • Loading branch information
vj-abishek authored Feb 1, 2021
2 parents c23f4a4 + dc9f84d commit e56bcc0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Components/Home/Room/Single.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
import { Link, useParams } from 'react-router-dom';
import { Helmet } from 'react-helmet';
import { connect } from 'react-redux';
import { format, formatDistanceToNow } from 'date-fns';
import { format, formatDistanceToNow, isDate } from 'date-fns';
import E2E from '../../Utils/EndToEnd';
import Styles from '../../../Styles/responsive.module.css';
import { UpdateChannel } from '../../../Store/Actions/Channel';
Expand Down Expand Up @@ -146,6 +146,9 @@ const Single = ({
const message = lastMessage.get(snapShot.channelId);
lastMessagetime = message.message?.time;
}

const checkDate = isDate(lastMessagetime) && (new Date(lastMessagetime) !== 'Invalid Date')

return (
<Link
to={`/r/${snapShot.channelId}/${
Expand Down Expand Up @@ -208,7 +211,7 @@ const Single = ({
<span>{snapShot.pro.data().displayName}</span>
</div>
<div className={`${Styles.gray1} text-xs`}>
{(hasLastMessage &&
{(hasLastMessage && checkDate &&
format(new Date(lastMessagetime), 'hh:mm a')) ||
''}
</div>
Expand Down

1 comment on commit e56bcc0

@vercel
Copy link

@vercel vercel bot commented on e56bcc0 Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.