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

feat: history timeline shows relative time, such as today and yesterday #6864

Merged
merged 1 commit into from May 13, 2024

Conversation

akumatus
Copy link
Member

@akumatus akumatus commented May 10, 2024

TL;DR

First, fixed an i18n issue in history panel. When the browser language is set to Chinese, and the AFFiNE application language is set to English, the language supposed to be English global. But now the language is a mixture of Chinese and English, which is obviously wrong.

截屏2024-05-08 18.23.21.png

Second, design a time formatter to convert timestamp into relative calendar date, such today and yesterday and so on. Long-ago edits will show the exact date like before.

截屏2024-05-10 15.30.57.png

What changed?

  • new Intl.DateTimeFormat with language option form document.documentElement.lang
  • Added timestampToCalendarDate function to convert timestamp into relative calendar date
  • Updated unit tests
  • Updated i18n copywriting

How to test?

  1. Open view history version
  2. Check edit timeline

Copy link

graphite-app bot commented May 10, 2024

Your org has enabled the Graphite merge queue for merging into canary

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@akumatus
Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @akumatus and the rest of your teammates on Graphite Graphite

@github-actions github-actions bot added mod:i18n Related to i18n test Related to test cases app:core labels May 10, 2024
@akumatus akumatus changed the title feat: history timeline shows relative time, such as today and yesterday Update history list grouping function to use calendar translation May 10, 2024
@akumatus akumatus changed the title Update history list grouping function to use calendar translation feat: history timeline shows relative time, such as today and yesterday May 10, 2024
Copy link
Collaborator

@pengx17 pengx17 left a comment

Choose a reason for hiding this comment

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

cool

Copy link

codecov bot commented May 10, 2024

Codecov Report

Attention: Patch coverage is 84.21053% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 66.65%. Comparing base (b723dd8) to head (261d413).

Files Patch % Lines
packages/frontend/core/src/utils/intl-formatter.ts 84.21% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           canary    #6864      +/-   ##
==========================================
+ Coverage   66.64%   66.65%   +0.01%     
==========================================
  Files         582      582              
  Lines       27169    27184      +15     
  Branches     2529     2535       +6     
==========================================
+ Hits        18106    18119      +13     
- Misses       8795     8797       +2     
  Partials      268      268              
Flag Coverage Δ
server-test 77.22% <ø> (ø)
unittest 40.32% <84.21%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@akumatus akumatus marked this pull request as ready for review May 10, 2024 07:52
@akumatus akumatus force-pushed the feat/history-version-with-calendar-date branch from a6860dd to 37f09de Compare May 10, 2024 07:56
@akumatus akumatus requested a review from pengx17 May 10, 2024 07:56
@akumatus akumatus force-pushed the feat/history-version-with-calendar-date branch 5 times, most recently from 5c662be to 018a234 Compare May 13, 2024 08:27
@akumatus akumatus force-pushed the feat/history-version-with-calendar-date branch 2 times, most recently from e4d9a55 to 870bf20 Compare May 13, 2024 11:13
Copy link

graphite-app bot commented May 13, 2024

Merge activity

…ay (#6864)

### TL;DR
First, fixed an i18n issue in history panel. When the browser language is set to Chinese, and the AFFiNE application language is set to English, the language supposed to be English global. But now the language is a mixture of Chinese and English, which is obviously wrong.

![截屏2024-05-08 18.23.21.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/93d8218a-3b26-4b0c-9f15-71a8996556db.png)

Second, design a time formatter to convert timestamp into relative calendar date, such today and yesterday and so on. Long-ago edits will show the exact date like before.

![截屏2024-05-10 15.30.57.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/dbc59e80-9504-40b1-b712-5c155cb6fa63.png)

### What changed?
- `new Intl.DateTimeFormat` with language option form  `document.documentElement.lang`
- Added `timestampToCalendarDate` function to convert timestamp into relative calendar date
- Updated unit tests
- Updated i18n copywriting

### How to test?
1. Open view history version
2. Check edit timeline
@Brooooooklyn Brooooooklyn force-pushed the feat/history-version-with-calendar-date branch from 870bf20 to 261d413 Compare May 13, 2024 12:00
@graphite-app graphite-app bot merged commit 261d413 into canary May 13, 2024
33 checks passed
@graphite-app graphite-app bot deleted the feat/history-version-with-calendar-date branch May 13, 2024 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:core mod:i18n Related to i18n test Related to test cases
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

3 participants