Skip to content

Commit

Permalink
CW-instant-chat-message-edit
Browse files Browse the repository at this point in the history
Added resetting editedAtDate
  • Loading branch information
MeyerPV committed Oct 7, 2024
1 parent 9b6a00c commit 193847d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/shared/components/Chat/ChatMessage/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ const ChatMessage = ({
: null;
const isNotCurrentUserMessage =
!isUserDiscussionMessage || userId !== discussionMessageUserId;
const initialEditedAtDate = new Date(
(discussionMessage.editedAt?.seconds ?? 0) * 1000,
);

const [replyMessageText, setReplyMessageText] = useState<
(string | JSX.Element)[]
Expand Down Expand Up @@ -178,9 +181,7 @@ const ChatMessage = ({
]);

const createdAtDate = new Date(discussionMessage.createdAt.seconds * 1000);
const [editedAtDate, setEditedAtDate] = useState(new Date(
(discussionMessage.editedAt?.seconds ?? 0) * 1000,
));
const [editedAtDate, setEditedAtDate] = useState(initialEditedAtDate);

const handleUserClick = () => {
if (onUserClick && discussionMessageUserId && !isBotMessage) {
Expand Down Expand Up @@ -260,6 +261,7 @@ const ChatMessage = ({
} else {
notify("Something went wrong");
setParsedMessage(discussionMessage.parsedText);
setEditedAtDate(initialEditedAtDate);
}
},
}),
Expand All @@ -279,6 +281,7 @@ const ChatMessage = ({
} catch (err) {
notify("Something went wrong");
setParsedMessage(discussionMessage.parsedText);
setEditedAtDate(initialEditedAtDate);
} finally {
setIsMessageEditLoading(false);
}
Expand Down

0 comments on commit 193847d

Please sign in to comment.