Skip to content

Commit

Permalink
tdl: use objects instead of arrays for preinit requests
Browse files Browse the repository at this point in the history
  • Loading branch information
eilvelia committed Jul 15, 2024
1 parent 2b0f0e0 commit d67c381
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/tdl/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class Client {
private readonly _client: TdjsonAnyClient
private _requestId: number = 0
private _initialized: boolean = false
private _preinitRequests: Array<[request: any, extra: unknown]> = []
private _preinitRequests: Array<{ request: any, id: unknown }> = []
private _version: Version = TDLIB_DEFAULT
private _connectionStateName: Td.ConnectionState['_'] = 'connectionStateWaitingForNetwork'
private _authorizationState: Td.AuthorizationState | null = null
Expand Down Expand Up @@ -320,8 +320,8 @@ export class Client {
private _finishInit (): void {
debug('Finished initialization')
this._initialized = true
for (const [request, id] of this._preinitRequests)
this._send(request, id)
for (const r of this._preinitRequests)
this._send(r.request, r.id)
this._preinitRequests = []
}

Expand All @@ -334,7 +334,7 @@ export class Client {
this._pending.set(id, { resolve, reject })
})
if (this._initialized === false) {
this._preinitRequests.push([request, id])
this._preinitRequests.push({ request, id })
return responsePromise
}
this._send(request, id)
Expand Down

0 comments on commit d67c381

Please sign in to comment.