Skip to content
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

Sticky date markers should show full date, messages should just show time #2745

Open
holmesworcester opened this issue Feb 12, 2025 · 2 comments

Comments

@holmesworcester
Copy link
Contributor

holmesworcester commented Feb 12, 2025

While working on #505 I wanted to match the sticky date marker designs and make date markers show "Today" or "Jan 2, 2024" while the messages themselves just show the time (or "Today"). However, this required a larger refactor and I wasn't sure the best option, or if there are other options.

The issue

In ChannelMessages.tsx we're getting a list of messages and their dates/times. The dates/times have been formatted already by a helper function. It then uses these (I think) to group the messages and insert dividers appropriately. So different kinds of functionality (timestamp formatting, grouping, date divider insertion) are all tangled together.

Option 1: Move responsibility for grouping and date markers out of the frontend

It seems that the message grouping should be in state manager or maybe backend, since we reuse it across desktop and mobile, so that the frontend simply gets a list of items to display and can display those items in the proper components. Some could be informative messages (like "alice joined" or "jane set disappearing messages") some could be normal messages or a group of messages, and others could be date dividers.

The frontend would then display the correct type in a list. Alternately, we could skip state manager and pass dates to the frontend, and test the logic there. The issue with that is that dates are finnicky and important, and it would be nice to handle them the same across desktop and mobile.

Option 2: Move responsibility for date formatting to the frontend

This takes things in the other direction, where we pass raw dates (and locales) to the frontend and let the different components format the date appropriately depending on the context. For example, date markers would format the date for messages as 3:06pm while they would format the date markers as Feb 28, 2020. I believe this will require a significant change to how we group messages and format the sticky date marker.

@holmesworcester holmesworcester moved this to Backlog - Desktop & Backend in Quiet Feb 12, 2025
@holmesworcester holmesworcester moved this from Backlog - Desktop & Backend to Blocked in Quiet Feb 12, 2025
@adrastaea
Copy link
Collaborator

To restate the current situation to check my understanding, ChannelMessages.tsx currently gets a map of messages MessagesDailyGroups = Record<string, DisplayableMessage[][]> from the state manager where the key is a human readable string of the day. DisplayableMessage includes createdAt which is the number representing ms since null that is source of truth for its chronological time and date which is the string that is generated from createdAt in the state-manager.

It seems to me like your Option 1 explanation is how things currently work. You should just be able to change the selector function in the state manager to put the date string format of the group key and the messages contained within in your preferred format.

@holmesworcester
Copy link
Contributor Author

I missed createdAt and I should be able to use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Blocked
Development

No branches or pull requests

2 participants