Skip to content

feat: Grouped messages based on date and added time for the messages #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

balaraju-nerati
Copy link
Contributor

I have added time for the messages and Organized the messages based on date.

Screenshot of the feature
Screenshot 2024-06-09 200035

Closes #242

Copy link

vercel bot commented Jun 9, 2024

@balaraju-nerati is attempting to deploy a commit to the samarthkadam's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Jun 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
chat-box-jyxx ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 15, 2024 11:10am

@SamarthKadam
Copy link
Owner

@balaraju-nerati great work. But make a little change that box appears a liltle big decrease its font a little bit and also decrease the padding as it looks big
Screenshot (606)

@balaraju-nerati
Copy link
Contributor Author

@SamarthKadam sure! I'll update it

@balaraju-nerati
Copy link
Contributor Author

Hey, @SamarthKadam , I modified the code regarding the changes u mentioned.

@SamarthKadam
Copy link
Owner

@balaraju-nerati why am I not able to see timestamps in some messages
Screenshot (607)

@balaraju-nerati
Copy link
Contributor Author

Hey, @SamarthKadam sry for that bug. Didn't see that. Now it's been solved. Please check now and let me know if there are any issues.

@Spiral-Memory
Copy link
Collaborator

Hey @SamarthKadam
Could you please approve my request for Vercel deployment preview? After that I'll review the PR and test the changes.

image

@SamarthKadam
Copy link
Owner

@Spiral-Memory now is it visible?

@Spiral-Memory
Copy link
Collaborator

Spiral-Memory commented Jun 12, 2024

@Spiral-Memory now is it visible?

Nope

Edit: Yes it's visible now

@SamarthKadam
Copy link
Owner

@Spiral-Memory @souravbhunia07 Are you reviewing the code?

@Spiral-Memory
Copy link
Collaborator

Yes, I've started the review and have suggested some changes.. Waiting for the contributor to reply !

@balaraju-nerati
Copy link
Contributor Author

Hey, @Spiral-Memory I don't know what changes you requested to me regarding this Pull request. Can you please explain?

"emoji-mart": "^5.6.0",
"gender-detection-from-name": "^1.8.0",
"javascript-time-ago": "^2.5.10",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can see, you are using date-fns in the code. So, consider removing another library that you have tried.

@@ -28,6 +30,7 @@
"react-router-dom": "^6.15.0",
"react-scripts": "5.0.1",
"react-speech-recognition": "^3.10.0",
"react-time-ago": "^7.3.3",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

@@ -110,8 +112,33 @@ export default function ChatMessages() {
};
}, [data]);


const groupedMessagesByDate = (data) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is grouping messages explicitly necessary in this case? Can't we have a simple function that tests whether the previous message has a difference of 24 hours or if prev message doesn't exist ? If yes, then simply append the date label like 'Today' or 'Yesterday' or the exact date. I think that will be a more efficient approach. Adding a code sample for your reference

import { isSameDay } from 'date-fns';

const isMessageNewDay = (current, previous) =>
    !previous || !isSameDay(new Date(current.ts), new Date(previous.ts));

></RecieverMessage>
);
})}
{Object.keys(groupedMessages).map(date => (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once you utilize that approach, you will be then iterating with data as it was previously and checks if is this Message a message of new day, if it is, add the message divider

@Spiral-Memory
Copy link
Collaborator

Hey, @Spiral-Memory I don't know what changes you requested to me regarding this Pull request. Can you please explain?

Sorry ! Haven't submitted the review.. check now !

@SamarthKadam
Copy link
Owner

@Spiral-Memory @souravbhunia07 done reviewing. As this pr was made 5 days ago. Please make this fast

@Spiral-Memory
Copy link
Collaborator

@Spiral-Memory @souravbhunia07 done reviewing. As this pr was made 5 days ago. Please make this fast

I have finished reviewing @SamarthKadam . I am waiting for the contributor to make the suggested changes. Aren't my review comments available?

@Spiral-Memory
Copy link
Collaborator

If my review comments are not available for any reason, i am attaching the screenshot of the same.

image
image
image

@Spiral-Memory
Copy link
Collaborator

@balaraju-nerati Please make the required changes.

@balaraju-nerati
Copy link
Contributor Author

Hey, @Spiral-Memory I'm working on the changes you suggested. I'll update by the end of tomorrow. Sry about the delay.

@Spiral-Memory
Copy link
Collaborator

Hey, @Spiral-Memory I'm working on the changes you suggested. I'll update by the end of tomorrow. Sry about the delay.

Okay @balaraju-nerati Sure. Thanks

@balaraju-nerati
Copy link
Contributor Author

Hey, @Spiral-Memory Please check now....I have optimized the code as per your suggestions.

@Spiral-Memory
Copy link
Collaborator

LGTM @balaraju-nerati, I am approving this PR, please make sure to remove the console logs after that it can be merged. Thanks!

@SamarthKadam SamarthKadam merged commit 15b36ab into SamarthKadam:main Jun 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Time at which message was sent.
4 participants