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" in chat page and in chat preview section as well . The dates only refresh when opening another chat and coming back or reload the page

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 and in chat preview 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 in chat and chat preview section

@Linhead Linhead requested a review from a team as a code owner September 12, 2025 15:02
@vercel
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 Oct 13, 2025 3:20pm

@Linhead
Copy link
Collaborator Author

Linhead commented Sep 12, 2025

@github-actions
Copy link

github-actions bot commented Sep 12, 2025

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

@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
@dev-adamant-im
Copy link
Member

@Linhead

Can we merge it?

@Linhead
Copy link
Collaborator Author

Linhead commented Oct 8, 2025

@dev-adamant-im
Yes. Should I do it?

@S-FrontendDev
Copy link
Member

@Linhead @dev-adamant-im need to test it

@S-FrontendDev
Copy link
Member

@Linhead check conflicts

@Linhead Linhead force-pushed the bug/dates-in-chats-are-not-refreshing branch from cd4c099 to d30c84d Compare October 10, 2025 14:59
@Linhead
Copy link
Collaborator Author

Linhead commented Oct 10, 2025

@S-FrontendDev Done

Copy link
Member

@al-onyxprotocol al-onyxprotocol left a comment

Choose a reason for hiding this comment

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

Test environment
App: https://adamant-9z47o72u4-adamant-team.vercel.app/chats/U15712150778664855297
Test ADM account
Browser: Vivaldi | 7.3.3635.14 (Stable channel) (arm64)
OS | macOS Version 15.5 (Build 24F74)
JavaScript | V8 13.4.114.21
User Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36

Test results: Failed

Test instructions

  1. Change the system time to 23:55
  2. Send any message in a chat
  3. Verify that the message time in the chat is displayed as Today
  4. Minimize the browser
  5. After midnight (according to the system clock), return to the browser
  6. The message time in the chat is still displayed as Today

Switching tabs: Works partly. In chat, date is "Yesterday". But in chat list, it's still "Today".

image

To fix:

  1. Listen "Minimize Browser/app" event, and update on restoring from background.
  2. Update date not only in chat, but also in chat list

@Linhead
Copy link
Collaborator Author

Linhead commented Oct 13, 2025

Fixed

Copy link
Member

@al-onyxprotocol al-onyxprotocol left a comment

Choose a reason for hiding this comment

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

Test passed ✅

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

7 participants