refactor : move dayjs.extend to module scope and extract useLastModified hook#442
refactor : move dayjs.extend to module scope and extract useLastModified hook#442adithya-naik wants to merge 3 commits into
Conversation
Removed console log for repository details.
|
Hi Team, Its been too long, please do consider this PR |
|
@mrecachinas @csmlo is there any thing going wrong with the changes ? Please let me know |
|
Hi, I am happy to make any recommended changes. Please consider review |
There was a problem hiding this comment.
Pull request overview
This PR updates RepositoryItem so each repository item computes and displays its own “Last activity” relative timestamp consistently, by moving Day.js relative-time initialization to module scope and extracting the last-modified computation into a dedicated custom hook.
Changes:
- Moved
dayjs.extend(relativeTime)out of the component to avoid re-running it on every render. - Extracted
useLastModifiedto module scope so hook definitions are not recreated per render. - Minor string formatting change in the issues wrapper className expression.
Show a summary per file
| File | Description |
|---|---|
| components/RepositoryItem.tsx | Centralizes Day.js relative-time setup and refactors last-activity computation into a reusable hook for per-repository correctness. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 1
| const [lastModified, setLastModified] = useState(""); | ||
|
|
||
| useEffect(() => setLastModified(dayjs(date).fromNow()), [date]); | ||
|
|
mrecachinas
left a comment
There was a problem hiding this comment.
👋 Apologies for the delay.
I don’t think this PR closes #440 as-is. The change is a nice cleanup -- e.g., dayjs.extend(relativeTime) no longer runs during every render and useLastModified is no longer redefined inside RepositoryItem.
But the rendered value is still just dayjs(repository.last_modified).fromNow(), so it will continue to display whatever is in generated.json. On main, the checked-in generated.json has all last_modified values from Oct–Nov 2023, which is why every repository collapses to the same “2/3 years ago” label. This PR doesn’t change the data generation/deploy path or refresh the underlying last_modified values.
My suggestion is either retitling this as a small React cleanup, or updating the PR to address the real data freshness issue before closing #440.
|
@mrecachinas Thanks for the review! That totally makes sense. I will retitle it as a React cleanup and remove closes #440 link. |
|
@mrecachinas This is ready for review, Thanks again |
What does this PR do?
This PR refactors how the last activity time is calculated in
RepositoryItem.What was changed?
dayjs.extend(relativeTime)to module scope so it runs once instead of on every renderuseLastModifiedinto a proper custom hook outside the componentWhat this PR does NOT do
This does not fix the root cause of #440. The underlying issue is that
generated.jsononmainhas stalelast_modifiedvalues from Oct–Nov 2023. That is a data generation/pipeline problem, not a rendering problem. A separate issue/PR should address that.Technical Notes
Checklist
dayjs.extendruns at module scope only