mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-03-02 12:00:45 -08:00
feat: parse githubUsername from oauth data
This commit is contained in:
parent
e98b542066
commit
0fcabf83d4
2 changed files with 15 additions and 3 deletions
|
|
@ -121,6 +121,8 @@ function AddWorkspace({ wikiCreationMessage, onUpdateForm, onSave, onSetWikiCrea
|
|||
homeUrl: `http://localhost:${wikiPort}/`,
|
||||
picturePath: getIconPath(),
|
||||
};
|
||||
|
||||
const githubUsername = getGithubUsername();
|
||||
return (
|
||||
<ClientContext.Provider value={graphqlClient}>
|
||||
<Container>
|
||||
|
|
@ -152,13 +154,19 @@ function AddWorkspace({ wikiCreationMessage, onUpdateForm, onSave, onSetWikiCrea
|
|||
scope="repo"
|
||||
onSuccess={response => {
|
||||
const accessToken = response?.userInfo?.thirdPartyIdentity?.accessToken;
|
||||
const authData = response?.userInfo?.oauth;
|
||||
if (accessToken) {
|
||||
setGraphqlClientHeader(accessToken);
|
||||
}
|
||||
if (authData) {
|
||||
setGithubUsername(JSON.parse(authData).login);
|
||||
}
|
||||
}}
|
||||
onFailure={response => console.log(response)}
|
||||
/>
|
||||
{Object.keys(graphqlClient.headers).length > 0 && <SearchRepo />}
|
||||
{Object.keys(graphqlClient.headers).length > 0 && githubUsername && (
|
||||
<SearchRepo githubUsername={githubUsername} />
|
||||
)}
|
||||
</SyncContainer>
|
||||
|
||||
<CreateContainer elevation={2} square>
|
||||
|
|
|
|||
|
|
@ -28,13 +28,17 @@ const SEARCH_REPO_QUERY = `
|
|||
}
|
||||
}
|
||||
`;
|
||||
export default function SearchRepo() {
|
||||
|
||||
interface Props {
|
||||
githubUsername: string;
|
||||
}
|
||||
export default function SearchRepo({ githubUsername }: Props) {
|
||||
const [githubRepoSearchString, githubRepoSearchStringSetter] = useState('wiki');
|
||||
const loadCount = 10;
|
||||
const { loading, error, data } = useQuery(SEARCH_REPO_QUERY, {
|
||||
variables: {
|
||||
first: loadCount,
|
||||
queryString: `user:linonetwo ${githubRepoSearchString}`,
|
||||
queryString: `user:${githubUsername} ${githubRepoSearchString}`,
|
||||
},
|
||||
});
|
||||
const repositoryCount = data?.search?.repositoryCount;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue