Changes to OAuth service and update undefined state#585
Conversation
| import { PromiseAdapter, promiseFromEvent } from "../helpers/eventEmitter.helper"; | ||
| import { ErrorResponse, IOAuthService, OAuthPath, OAuthPlatform, UserInfo } from "../models/shared/IOAuthService"; | ||
|
|
||
| import {ErrorResponse, IOAuthService, OAuthPath, OAuthPlatform, UserInfo} from "../models/shared/IOAuthService"; |
There was a problem hiding this comment.
Break this import into multiple lines, way too long
There was a problem hiding this comment.
@echolayer-stag can you break this import into multiple lines
There was a problem hiding this comment.
Sorry, I couldn't find a solution for this task. I'll polish up on the docs for next time.
| public async authenticate(oAuthPath: OAuthPath): Promise<UserInfo | ErrorResponse> { | ||
| const oAuthPlatform: OAuthPlatform = oAuthPath === OAuthPath.google ? OAuthPlatform.google : OAuthPlatform.github; | ||
| const eventEmitter = OAuthUrlHandler.getInstance().getEventEmitter(); | ||
| const ee = OAuthUrlHandler.getInstance().getEventEmitter(); |
There was a problem hiding this comment.
Change for a much more descriptive variable name
There was a problem hiding this comment.
@echolayer-stag rename this to be a much more descriptive variable name
There was a problem hiding this comment.
EchoLayer posted a change for your review: #586
| // before completing it. | ||
| if (!OAuthService.codeExchangePromise) { | ||
| OAuthService.codeExchangePromise = promiseFromEvent(eventEmitter.event, this.postAuthorization()); | ||
| OAuthService.codeExchangePromise = promiseFromEvent( |
There was a problem hiding this comment.
Not sure why this is multiple lines
There was a problem hiding this comment.
@echolayer-stag can you collapse this all into one line
There was a problem hiding this comment.
EchoLayer posted a change for your review: #588
| OAuthService.codeExchangePromise.promise, | ||
| new Promise<ErrorResponse>((_, reject) => | ||
| setTimeout(() => { | ||
| // TODO we should make this alot simpler |
There was a problem hiding this comment.
We fixed this already, maybe add some comments
There was a problem hiding this comment.
@echolayer-stag remove this TODO and instead add comments to the return Promise.race on how it works
There was a problem hiding this comment.
EchoLayer posted a change for your review: #589
| this.clearCodeExchangePromise(); | ||
| const parsedQuery = this.parseQuery(uri) as AuthorizeResponse | ErrorResponse; | ||
| if ((parsedQuery as AuthorizeResponse).code) { | ||
| const parsed_query = this.parseQuery(uri) as AuthorizeResponse | ErrorResponse; |
There was a problem hiding this comment.
We don't use snake case in this file
There was a problem hiding this comment.
@echolayer-stag change this to camelCasing please
There was a problem hiding this comment.
EchoLayer posted a change for your review: #587
|
|
||
| private parseQuery(uri: vscode.Uri) { | ||
| return uri.query.split("&").reduce((prev: any, current) => { | ||
| // important to split |
There was a problem hiding this comment.
Not a helpful comment to explain
There was a problem hiding this comment.
@echolayer-stag can you remove this unhelpful comment and instead actually comment what this code block is doing
There was a problem hiding this comment.
EchoLayer posted a change for your review: #590
| if (force) { | ||
| await this.getContexts(force); | ||
| } | ||
| if (force) await this.getContexts(force); |
There was a problem hiding this comment.
This shouldn't all be on one line
There was a problem hiding this comment.
@echolayer-stag split this into multiple lines so it's easier to read for my future self
There was a problem hiding this comment.
EchoLayer posted a change for your review: #595
| } | ||
|
|
||
| public async getDefaultCodexServiceForRepo(repositoryService: RepositoryService): Promise<CodexService> { | ||
| public async getDefaultCodexServiceForRepo(repositoryService: any): Promise<CodexService> { |
There was a problem hiding this comment.
Add some comments explaining what this is for
There was a problem hiding this comment.
@echolayer-stag add comments explaining what this is for
There was a problem hiding this comment.
EchoLayer posted a change for your review: #591
| return this.ccl.getContextsService(); | ||
| } | ||
|
|
||
| // TODO clean up comments |
There was a problem hiding this comment.
Would replace this with a valid comment, in fact this file doesn't have any comments explaining the functions
There was a problem hiding this comment.
@echolayer-stag remove this todo and add comments that explain all functions in this file
There was a problem hiding this comment.
EchoLayer posted a change for your review: #593
| OAuthService.codeExchangePromise = promiseFromEvent( | ||
| ee.event, | ||
| this.postAuthorization() | ||
| ); |
There was a problem hiding this comment.
@echolayer-stag can you collapse this all into one line
There was a problem hiding this comment.
EchoLayer posted a change for your review: #594
| @@ -16,21 +17,25 @@ export class OAuthService implements IOAuthService { | |||
| */ | |||
| public async authenticate(oAuthPath: OAuthPath): Promise<UserInfo | ErrorResponse> { | |||
There was a problem hiding this comment.
@echolayer rename this function to oAuthenticate
There was a problem hiding this comment.
EchoLayer posted a change for your review: #596
There was a problem hiding this comment.
EchoLayer posted a change for your review: #597
There was a problem hiding this comment.
EchoLayer posted a change for your review: #598
This pull request introduces a series of code quality improvements across multiple services. In
oauth.service.ts, variable names have been refactored for clarity, code formatting enhanced, and a TODO added to address future simplification of timeout rejection logic. TheundefinedTextEditor.service.tshas been updated for better readability with new lines, a streamlined if-statement, and a more flexible method parameter type, whileuser.service.tsnow includes a reminder to clean up comments.File Changes
oauth.service.ts: Refactored variable names and improved code formatting. Added a TODO comment regarding simplification of a timeout rejection logic.undefinedTextEditor.service.ts: Inserted new lines for readability, simplified an if-statement, and changed a parameter type to 'any' in a method signature.user.service.ts: Added a TODO comment to remind of cleaning up comments in the future.