Skip to content

Commit

Permalink
add yesterday to conversation list
Browse files Browse the repository at this point in the history
  • Loading branch information
anish-work committed Aug 28, 2024
1 parent 78276f5 commit 8314b0d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/shared/Layout/SideNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ const SideNavbar = () => {
const now = new Date().getTime();
const today = new Date().setHours(0, 0, 0, 0);
const endToday = new Date().setHours(23, 59, 59, 999);
const yesterday = new Date(today - 1).setHours(0, 0, 0, 0);
const endYesterday = new Date(today - 1).setHours(23, 59, 59, 999);
const sevenDaysInMs = 7 * 24 * 60 * 60 * 1000; // days x hours x minutes x seconds x milliseconds
const thirtyDaysInMs = 30 * 24 * 60 * 60 * 1000; // days x hours x minutes x seconds x milliseconds

const grouped: any = {
Today: [],
Yesterday: [],
"Previous 7 Days": [],
"Previous 30 Days": [],
Months: {},
Expand All @@ -57,6 +60,10 @@ const SideNavbar = () => {

if (lastMessageTimestamp >= today && lastMessageTimestamp <= endToday) {
subheading = "Today";
} else if (
lastMessageTimestamp >= yesterday && lastMessageTimestamp <= endYesterday
) {
subheading = "Yesterday";
} else if (
lastMessageTimestamp > endToday - sevenDaysInMs &&
lastMessageTimestamp <= endToday
Expand Down Expand Up @@ -91,6 +98,7 @@ const SideNavbar = () => {
// Combine all groups into a single array
return [
{ subheading: "Today", conversations: grouped.Today },
{ subheading: "Yesterday", conversations: grouped.Yesterday },
{
subheading: "Previous 7 Days",
conversations: grouped["Previous 7 Days"],
Expand All @@ -102,6 +110,7 @@ const SideNavbar = () => {
...monthEntries,
].filter((group) => group?.conversations?.length > 0);
}, [conversations]);

if (config?.disableConversations) return null;
return (
<nav
Expand Down

0 comments on commit 8314b0d

Please sign in to comment.