Add refresh button to functions list page#26
Conversation
|
There is potential bug if the user disconnects while a refresh is in flight. But I am not sure. As of now we cannot really disconnect. |
twoGiants
left a comment
There was a problem hiding this comment.
Will finish review tomorrow.
Add a manual refresh button to the functions list that re-fetches repos from GitHub on click. The button uses the PF Button isLoading prop for a native spinner and is disabled while a fetch is in flight. Place create and refresh buttons in a PF Toolbar above the table, separated by a vertical divider. Fix a caching bug in GithubService where deleted repos persisted after refresh. Replace the stale merge logic with a pendingRepos buffer that only keeps locally created repos until GitHub's search index catches up. Signed-off-by: Matej Vašek <matejvasek@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com>
22145e8 to
ac2a97c
Compare
| const [prevConnectionId, setPrevConnectionId] = useState(connectionId); | ||
|
|
||
| const [error, setError] = useState<string>(''); | ||
| const [refreshKey, setRefreshKey] = useState(0); |
There was a problem hiding this comment.
No need for this. Extract the fetch logic into a standalone async function, call it from the useEffect for the initial load (and when connectionId changes), and call it directly from onRefresh.
There was a problem hiding this comment.
Well the Jira said:
Add a refreshKey counter state...
So I let Claude go with what was in Jira.
There was a problem hiding this comment.
But yes, it might not be necessary now.
There was a problem hiding this comment.
Claude at first tried to replace it with const fetchIdRef = useRef(0);
after some convincing it removed even that fetchIdRef but warns that it can cause some troubles in unlikely cases.
❯ so having fetchIdRef is better?
● Yes, it's strictly more correct. Without it, a connection change during an in-flight fetch could briefly show >stale data. With it, that can't happen.
Remove tooltip from refresh button. Drop useCallback from onRefresh. Extract loadFunctions as a standalone async function called directly from onRefresh and from useEffect for initial load, eliminating the refreshKey state. Signed-off-by: Matej Vašek <matejvasek@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com>

Summary
pendingReposbuffer that only keeps locally-created repos until GitHub's search index catches up.Test plan
listFunctionReposagain