Skip to content

Commit 8391985

Browse files
authored
small refactor to clarify logic (#362)
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`.
1 parent 3c63b8d commit 8391985

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

js-pkg/client/src/provider.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,16 +309,10 @@ export class YSweetProvider {
309309
}
310310

311311
private async ensureClientToken(): Promise<ClientToken> {
312-
if (this.clientToken) {
313-
return this.clientToken
314-
}
315-
if (typeof this.authEndpoint === 'string') {
312+
if (this.clientToken === null) {
316313
this.clientToken = await getClientToken(this.authEndpoint, this.docId)
317-
return this.clientToken
318-
} else {
319-
this.clientToken = await this.authEndpoint()
320-
return this.clientToken
321314
}
315+
return this.clientToken
322316
}
323317

324318
/**

0 commit comments

Comments
 (0)