Skip to content

Commit

Permalink
refactor: Display 'Could not load Github username' when rate limit or…
Browse files Browse the repository at this point in the history
… max retries are reached
  • Loading branch information
EGAMAGZ committed Jan 16, 2025
1 parent 2cc9ec1 commit 1ac5f58
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion frontend/islands/GithubUserLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@ import { cachedGitHubLogin } from "../utils/github.ts";

export function GitHubUserLink({ user }: { user?: User }) {
const login = useSignal("");
const error = useSignal(false);

useEffect(() => {
if (user) {
cachedGitHubLogin(user)
.then((login_) => {
login.value = login_;
})
.catch(console.error);
.catch(error_ =>{
console.error(error_);

error.value = true;
});
}
});

if(error.value){
return <span>Could not load GitHub username</span>;
}

return login.value == ""
? <span>loading...</span>
: <a class="link" href={"https://github.com/" + login.value}>GitHub</a>;
Expand Down

0 comments on commit 1ac5f58

Please sign in to comment.