Skip to content

fix: last activity timestamp shows incorrectly for all projects#482

Open
uddhav05-cyber wants to merge 3 commits into
github:mainfrom
uddhav05-cyber:fix/last-modified-display
Open

fix: last activity timestamp shows incorrectly for all projects#482
uddhav05-cyber wants to merge 3 commits into
github:mainfrom
uddhav05-cyber:fix/last-modified-display

Conversation

@uddhav05-cyber

Copy link
Copy Markdown

Fixes #440

Problem

dayjs.extend(relativeTime) was being called inside the component on every render, causing all repositories to display an incorrect/stale relative timestamp.

Fix

  • Extracted useLastModified into a proper custom hook in hooks/useLastModified.tsx
  • dayjs.extend(relativeTime) now runs once at module scope
  • RepositoryItem.tsx imports and uses the new hook cleanly

Changes

  • hooks/useLastModified.tsx — new custom hook
  • components/RepositoryItem.tsx — removed inline dayjs.extend, uses new hook

Note: PR #442 addressed the same issue but has been unreviewed for several months.

Copilot AI review requested due to automatic review settings May 16, 2026 19:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes incorrect/stale “Last Activity” relative timestamps by moving dayjs.extend(relativeTime) out of the RepositoryItem component and extracting the logic into a reusable useLastModified hook.

Changes:

  • Added hooks/useLastModified.tsx custom hook and initialized dayjs relative-time plugin at module scope.
  • Updated components/RepositoryItem.tsx to consume useLastModified and removed inline dayjs/hook logic.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
hooks/useLastModified.tsx New hook for computing “last modified” relative time; initializes dayjs plugin once.
components/RepositoryItem.tsx Uses the new hook instead of defining it inline; removes repeated dayjs.extend.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hooks/useLastModified.tsx Outdated
Comment on lines +3 to +16
import { useEffect, useState } from "react";

// Extend dayjs with relativeTime plugin at module scope
dayjs.extend(relativeTime);

export const useLastModified = (date: string) => {
const [lastModified, setLastModified] = useState("");

useEffect(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect
setLastModified(dayjs(date).fromNow());
}, [date]);

return lastModified;
Comment on lines 20 to +29
useEffect(() => {
if (isIssueOpen) {
// eslint-disable-next-line react-hooks/set-state-in-effect
setIsIssuesListVisible(true);
} else {
// Delay unmounting to allow close animation to complete
const timer = setTimeout(() => setIsIssuesListVisible(false), 300);
const timer = setTimeout(() => {
// eslint-disable-next-line react-hooks/set-state-in-effect
setIsIssuesListVisible(false);
}, 300);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants