diff --git a/src/common/chatsManage/getChatLastMessage.ts b/src/common/chatsManage/getChatLastMessage.ts
index d3b99f1..6dccc4f 100644
--- a/src/common/chatsManage/getChatLastMessage.ts
+++ b/src/common/chatsManage/getChatLastMessage.ts
@@ -2,7 +2,7 @@ import { IChat } from '@/types/chat';
export default function getChatNewestMessage(chat: IChat) {
const sortedMessages = [...chat.messages].sort(
- (a, b) => b.createdAt.seconds - a.createdAt.seconds,
+ (a, b) => b.createdAt?.seconds - a.createdAt?.seconds,
);
return sortedMessages[0];
}
diff --git a/src/common/misc/photoManagment/getPicturesSortedByDate.ts b/src/common/misc/photoManagment/getPicturesSortedByDate.ts
index 183f484..7729073 100644
--- a/src/common/misc/photoManagment/getPicturesSortedByDate.ts
+++ b/src/common/misc/photoManagment/getPicturesSortedByDate.ts
@@ -9,6 +9,6 @@ export default function getPicturesSortedByDate({ picturesMap, type }: IGetPictu
return picturesMap
? Object.values(picturesMap[type])
.filter((picture) => !!picture.createdAt)
- .sort((a, b) => b.createdAt.seconds - a.createdAt.seconds)
+ .sort((a, b) => b.createdAt?.seconds - a.createdAt?.seconds)
: [];
}
diff --git a/src/components/molecules/Comments/Comment/index.tsx b/src/components/molecules/Comments/Comment/index.tsx
index 7f471ac..f3fa6eb 100644
--- a/src/components/molecules/Comments/Comment/index.tsx
+++ b/src/components/molecules/Comments/Comment/index.tsx
@@ -123,7 +123,7 @@ export default function Comment({
- {getShortDate(comment.createdAt.seconds)}
+ {getShortDate(comment.createdAt?.seconds)}
diff --git a/src/components/molecules/Comments/index.tsx b/src/components/molecules/Comments/index.tsx
index 48ffa32..d264f7f 100644
--- a/src/components/molecules/Comments/index.tsx
+++ b/src/components/molecules/Comments/index.tsx
@@ -24,7 +24,7 @@ export default function Comments({
const sortedComments = Object.values(comments || {})
.filter((picture) => !!picture.createdAt)
- .sort((a, b) => b.createdAt.seconds - a.createdAt.seconds);
+ .sort((a, b) => b.createdAt?.seconds - a.createdAt?.seconds);
const commentsToRender = onlyUniqueUsers
? sortedComments.filter((comment, i, self) => {
diff --git a/src/components/molecules/ElementOwnerInfoDisplay/index.tsx b/src/components/molecules/ElementOwnerInfoDisplay/index.tsx
index 06aca50..224c4e6 100644
--- a/src/components/molecules/ElementOwnerInfoDisplay/index.tsx
+++ b/src/components/molecules/ElementOwnerInfoDisplay/index.tsx
@@ -64,7 +64,7 @@ export default function ElementOwnerInfoDisplay({
lineHeight='1rem'
/>
- {getShortDate(createdAt.seconds, 'week')}
+ {getShortDate(createdAt?.seconds, 'week')}
{loggedUser?.id === element.ownerId && (
diff --git a/src/components/organisms/ChatsListPopper/ListUserButton/index.tsx b/src/components/organisms/ChatsListPopper/ListUserButton/index.tsx
index c8ce971..2a2646d 100644
--- a/src/components/organisms/ChatsListPopper/ListUserButton/index.tsx
+++ b/src/components/organisms/ChatsListPopper/ListUserButton/index.tsx
@@ -23,7 +23,7 @@ export default function ListUserButton({
const lastMessage = getChatNewestMessage(chat);
const handleChatOpen = useHandleOpenChat(friendId);
- const { largestDiff } = getDateDiffs(lastMessage.createdAt.seconds);
+ const { largestDiff } = getDateDiffs(lastMessage.createdAt?.seconds);
return (
- getChatNewestMessage(b).createdAt.seconds - getChatNewestMessage(a).createdAt.seconds,
+ getChatNewestMessage(b).createdAt?.seconds - getChatNewestMessage(a).createdAt?.seconds,
);
if (!open) return null;