Skip to content

Conversation

@HuberTRoy
Copy link
Member

@HuberTRoy HuberTRoy commented Jul 21, 2025

Description

  • Fix my project flash when loading.
  • Improve load speed.
  • Auto reload after account switched.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvements (ie: code cleaning or remove unused codes or performance issue)

@HuberTRoy HuberTRoy requested a review from Copilot July 21, 2025 04:56
@HuberTRoy HuberTRoy merged commit 869bbd3 into main Jul 21, 2025
2 checks passed
Copy link
Contributor

Copilot AI left a comment

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 addresses performance issues and user experience improvements in the project list functionality by fixing loading flashes, improving load speeds, and implementing auto-reload when accounts are switched.

  • Replaces the useGetProjectsLazyQuery hook with an inline GraphQL query using useLazyQuery for better control
  • Increases page size from 10 to 30 projects to reduce the number of API calls
  • Adds account switching detection and automatic project list refresh when the account changes

Reviewed Changes

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

File Description
src/hooks/useProjectList.tsx Replaces query hook with inline GraphQL, adds account change detection, and increases page size
src/hooks/useLocalProjects.ts Adds account parameter to search function for proper filtering

// setTopProject(res.data?.project);
// }
// };
const [previouseAccount, setPreviouseAccount] = useState(account);
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Variable name contains a typo: 'previouseAccount' should be 'previousAccount'.

Suggested change
const [previouseAccount, setPreviouseAccount] = useState(account);
const [previousAccount, setPreviousAccount] = useState(account);

Copilot uses AI. Check for mistakes.
Comment on lines +483 to +490
if (account && account !== previouseAccount) {
setProjects([]);
loadMore({
refresh: true,
}).then((res) => {
mutate(res);
});
setPreviouseAccount(account);
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Function call uses misspelled variable name: 'setPreviouseAccount' should be 'setPreviousAccount'.

Suggested change
if (account && account !== previouseAccount) {
setProjects([]);
loadMore({
refresh: true,
}).then((res) => {
mutate(res);
});
setPreviouseAccount(account);
if (account && account !== previousAccount) {
setProjects([]);
loadMore({
refresh: true,
}).then((res) => {
mutate(res);
});
setPreviousAccount(account);

Copilot uses AI. Check for mistakes.
.filter((i) =>
`${i.name}-${i.versionDescription}-${i.description}`.toLowerCase().includes(params.keywords.toLowerCase()),
)
.filter((i) => (params.account ? i.owner.toLocaleLowerCase() == params.account.toLocaleLowerCase() : true));
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

Method name contains a typo: 'toLocaleLowerCase()' should be 'toLowerCase()'.

Suggested change
.filter((i) => (params.account ? i.owner.toLocaleLowerCase() == params.account.toLocaleLowerCase() : true));
.filter((i) => (params.account ? i.owner.toLowerCase() == params.account.toLowerCase() : true));

Copilot uses AI. Check for mistakes.
});
setPreviouseAccount(account);
}
}, [account]);
Copy link

Copilot AI Jul 21, 2025

Choose a reason for hiding this comment

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

The useEffect dependency array is missing 'loadMore' and 'mutate' which are used inside the effect. This could cause stale closures or missed updates.

Suggested change
}, [account]);
}, [account, loadMore, mutate]);

Copilot uses AI. Check for mistakes.
@HuberTRoy HuberTRoy deleted the fix/my-projects branch September 9, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants