Skip to content

Commit

Permalink
chore: Refactor date handling in ChatTalk component
Browse files Browse the repository at this point in the history
  • Loading branch information
tako0614 committed Jun 19, 2024
1 parent b438437 commit fe3d4ae
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions islands/Chats/ChatTalk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ function TalkArea(props: any) {
<ul class="p-talk-chat-main__ul">
{props.talkData.map((data: any) => {
const isEncodeDate =
new Date(DateState).toLocaleDateString() !==
new Date(data.time).toLocaleDateString()
new Date(DateState).toLocaleDateString() !== new Date(data.time).toLocaleDateString()
DateState = data.time
if (data.type == "message") {
if (data.sender == props.userName) {
Expand All @@ -86,9 +85,7 @@ function TalkArea(props: any) {
<>
{isEncodeDate && (
<ChatDate
date={data.time.split(
"T",
)[0]}
date={new Date(data.time)}
/>
)}
<ChatSendMessage
Expand All @@ -104,7 +101,7 @@ function TalkArea(props: any) {
<>
{isEncodeDate && (
<ChatDate
date={data.time.split("T")[0]}
date={new Date(data.time)}
/>
)}
<ChatSendMessage
Expand All @@ -123,9 +120,7 @@ function TalkArea(props: any) {
<>
{isEncodeDate && (
<ChatDate
date={data.time.split(
"T",
)[0]}
date={new Date(data.time)}
/>
)}
<ChatOtherMessage
Expand All @@ -143,7 +138,7 @@ function TalkArea(props: any) {
<>
{isEncodeDate && (
<ChatDate
date={data.time.split("T")[0]}
date={new Date(data.time)}
/>
)}
<ChatOtherMessage
Expand All @@ -157,7 +152,7 @@ function TalkArea(props: any) {
)
}
} else {
return <ChatDate date={data.date} />
return <ChatDate date={new Date(data.time)} />
}
})}
</ul>
Expand Down

0 comments on commit fe3d4ae

Please sign in to comment.