fix user load

pull/4791/head
filip mertens 6 months ago
parent 2c9ecd01c0
commit 38d518d551
  1. 6
      apps/remix-ide/src/app/files/dgitProvider.ts
  2. 7
      libs/remix-ui/git/src/components/github/devicecode.tsx
  3. 2
      libs/remix-ui/git/src/components/panels/commands.tsx
  4. 2
      libs/remix-ui/git/src/components/panels/log.tsx
  5. 20
      libs/remix-ui/git/src/lib/gitactions.ts

@ -1016,14 +1016,12 @@ class DGitProvider extends Plugin {
const user = await octokit.request('GET /user') const user = await octokit.request('GET /user')
const emails = await octokit.request('GET /user/emails') const emails = await octokit.request('GET /user/emails')
const scopes = user.headers['x-oauth-scopes']; const scopes = user.headers['x-oauth-scopes'] || ''
console.log('scopes', scopes)
return { return {
user: user.data, user: user.data,
emails: emails.data, emails: emails.data,
scopes: scopes.split(',') scopes: scopes && scopes.split(',')
} }
} catch (e) { } catch (e) {
return null return null

@ -73,13 +73,6 @@ export const GetDeviceCode = () => {
await actions.loadGitHubUserFromToken() await actions.loadGitHubUserFromToken()
} }
const checkConnection = async () => {
//await actions.loadGitHubUserFromToken()
}
useEffect(() => {
}, [])
return ( return (
<> <>

@ -10,7 +10,5 @@ export const Commands = () => {
<PushPull></PushPull> <PushPull></PushPull>
<hr></hr> <hr></hr>
<Fetch></Fetch> <Fetch></Fetch>
<hr></hr>
<Merge></Merge>
</>) </>)
} }

@ -24,7 +24,7 @@ const LogViewer = () => {
return ( return (
<div className="p-1"> <div className="p-1">
{context.log && context.log.map((log, index) => ( {context.log && context.log.reverse().map((log, index) => (
<div key={index} className={`log-entry ${typeToCssClass(log.type)}`}> <div key={index} className={`log-entry ${typeToCssClass(log.type)}`}>
[{log.type.toUpperCase()}] {log.message} [{log.type.toUpperCase()}] {log.message}
</div> </div>

@ -559,14 +559,22 @@ export const loadGitHubUserFromToken = async () => {
dispatch(setGitHubUser(data.user)) dispatch(setGitHubUser(data.user))
dispatch(setScopes(data.scopes)) dispatch(setScopes(data.scopes))
dispatch(setUserEmails(data.emails)) dispatch(setUserEmails(data.emails))
sendToGitLog({
type: 'success',
message: `Github user loaded...`
})
}else{
sendToGitLog({
type: 'error',
message: `Please check your GitHub token in the GitHub settings.`
})
dispatch(setGitHubUser(null))
} }
} else { } else {
const credentials = await getGitHubCredentialsFromLocalStorage() sendToGitLog({
if (credentials) { type: 'error',
//dispatch(setGitHubUser({ login: credentials.username })) message: `Please check your GitHub token in the GitHub settings.`
//dispatch(setUserEmails([{ email: credentials.email, primary: true, visibility: 'public', verified: true }])) })
}
dispatch(setGitHubUser(null)) dispatch(setGitHubUser(null))
} }
} catch (e) { } catch (e) {

Loading…
Cancel
Save