Skip to content

Conversation

Linhead
Copy link
Collaborator

@Linhead Linhead commented Sep 12, 2025

Fixes #862

Fix: Dates in chats not refreshing when day changes while app is in background

Problem
When user opens a chat late at night (e.g., 23:55) and messages display "Today", then switches to another tab/app, and returns after midnight (e.g., 00:05), the dates still incorrectly show "Today" instead of "Yesterday". The dates only refresh when opening another chat and coming back.

Solution

  • Added reactive dateRefreshKey that triggers component re-render on visibility change
  • Used existing Visibility.change handler to update the key when app becomes visible
  • Applied :key attribute to component for force re-render
  • Utilized existing maintainScrollPosition() method to preserve scroll position during re-render

Test instructions

  1. Change the system time to 23:55 or any other time close to midnight.
  2. Send any message in any chat.
  3. Verify that the message time in the chat is displayed as Today.
  4. Minimize the tab or the browser.
  5. After midnight (according to the system clock), return to the tab:
    • The sent message should now display the date as Yesterday.

@Linhead Linhead requested a review from a team as a code owner September 12, 2025 15:02
Copy link

vercel bot commented Sep 12, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
adamant-im Ready Ready Preview Comment Sep 24, 2025 8:47am

@Linhead
Copy link
Collaborator Author

Linhead commented Sep 12, 2025

Copy link

github-actions bot commented Sep 12, 2025

Deployed to https://msg-adamant-pr-863.surge.sh 🚀

@Linhead Linhead linked an issue Sep 15, 2025 that may be closed by this pull request
@adamantmm adamantmm assigned adamantmm and Linhead and unassigned adamantmm Sep 28, 2025
@adamantmm adamantmm added bug Something isn't working JavaScript Frontend or backend code in JavaScript UX/UI User interface and experience improvements labels Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working JavaScript Frontend or backend code in JavaScript UX/UI User interface and experience improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Dates in chats are not refreshing
3 participants