Skip to content

Commit

Permalink
small refactor to clarify logic (#362)
Browse files Browse the repository at this point in the history
Small logic clarification I came across as I was catching up on the new
provider. `getClientToken` already handles the `AuthEndpoint` type for
both cases: when it's a `function` and when it's a `string`.
  • Loading branch information
rolyatmax authored Dec 18, 2024
1 parent 3c63b8d commit 8391985
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions js-pkg/client/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,16 +309,10 @@ export class YSweetProvider {
}

private async ensureClientToken(): Promise<ClientToken> {
if (this.clientToken) {
return this.clientToken
}
if (typeof this.authEndpoint === 'string') {
if (this.clientToken === null) {
this.clientToken = await getClientToken(this.authEndpoint, this.docId)
return this.clientToken
} else {
this.clientToken = await this.authEndpoint()
return this.clientToken
}
return this.clientToken
}

/**
Expand Down

0 comments on commit 8391985

Please sign in to comment.