From 9e9d7762c4239cd57bcde9ed212bfc1214cd1b84 Mon Sep 17 00:00:00 2001 From: Abishek PY <43115551+vj-abishek@users.noreply.github.com> Date: Mon, 1 Feb 2021 14:30:30 +0530 Subject: [PATCH 1/2] fix: date undefined issue --- src/Components/Home/Room/Single.jsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Components/Home/Room/Single.jsx b/src/Components/Home/Room/Single.jsx index 5a6e4af..fbdfdb2 100644 --- a/src/Components/Home/Room/Single.jsx +++ b/src/Components/Home/Room/Single.jsx @@ -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'; @@ -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 ( {snapShot.pro.data().displayName}
- {(hasLastMessage && + {(hasLastMessage && checkDate && format(new Date(lastMessagetime), 'hh:mm a')) || ''}
From dc9f84d8bf39691eb81f8d454c8cbb0699d79098 Mon Sep 17 00:00:00 2001 From: Abishek PY <43115551+vj-abishek@users.noreply.github.com> Date: Mon, 1 Feb 2021 14:34:03 +0530 Subject: [PATCH 2/2] fix: typo --- src/Components/Home/Room/Single.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/Home/Room/Single.jsx b/src/Components/Home/Room/Single.jsx index fbdfdb2..fa47a2c 100644 --- a/src/Components/Home/Room/Single.jsx +++ b/src/Components/Home/Room/Single.jsx @@ -147,7 +147,7 @@ const Single = ({ lastMessagetime = message.message?.time; } - const checkDate = isDate(lastMessagetime) && (new Date(lastMessagetime) !=== 'Invalid Date') + const checkDate = isDate(lastMessagetime) && (new Date(lastMessagetime) !== 'Invalid Date') return (