You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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 asFeb 28, 2020
. I believe this will require a significant change to how we group messages and format the sticky date marker.The text was updated successfully, but these errors were encountered: