fix: load blocking by network await (#1989)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { isString, joinPaths } from '@standardnotes/utils'
|
import { isString, joinPaths, sleep } from '@standardnotes/utils'
|
||||||
import { Environment } from '@standardnotes/models'
|
import { Environment } from '@standardnotes/models'
|
||||||
import { HttpRequestParams } from './HttpRequestParams'
|
import { HttpRequestParams } from './HttpRequestParams'
|
||||||
import { HttpVerb } from './HttpVerb'
|
import { HttpVerb } from './HttpVerb'
|
||||||
@@ -13,6 +13,7 @@ import { HttpErrorResponseBody } from './HttpErrorResponseBody'
|
|||||||
|
|
||||||
export class HttpService implements HttpServiceInterface {
|
export class HttpService implements HttpServiceInterface {
|
||||||
private authorizationToken?: string
|
private authorizationToken?: string
|
||||||
|
private __latencySimulatorMs?: number
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private environment: Environment,
|
private environment: Environment,
|
||||||
@@ -78,6 +79,10 @@ export class HttpService implements HttpServiceInterface {
|
|||||||
private async runHttp(httpRequest: HttpRequest): Promise<HttpResponse> {
|
private async runHttp(httpRequest: HttpRequest): Promise<HttpResponse> {
|
||||||
const request = this.createXmlRequest(httpRequest)
|
const request = this.createXmlRequest(httpRequest)
|
||||||
|
|
||||||
|
if (this.__latencySimulatorMs) {
|
||||||
|
await sleep(this.__latencySimulatorMs, true)
|
||||||
|
}
|
||||||
|
|
||||||
const response = await this.runRequest(request, this.createRequestBody(httpRequest))
|
const response = await this.runRequest(request, this.createRequestBody(httpRequest))
|
||||||
|
|
||||||
if (response.meta) {
|
if (response.meta) {
|
||||||
|
|||||||
@@ -124,7 +124,6 @@ export class SNSessionManager extends AbstractService<SessionEvent> implements S
|
|||||||
if (rawSession) {
|
if (rawSession) {
|
||||||
const session = SessionFromRawStorageValue(rawSession)
|
const session = SessionFromRawStorageValue(rawSession)
|
||||||
this.setSession(session, false)
|
this.setSession(session, false)
|
||||||
await this.webSocketsService.startWebSocketConnection()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,6 +131,8 @@ export class SNSessionManager extends AbstractService<SessionEvent> implements S
|
|||||||
this.httpService.setAuthorizationToken(session.authorizationValue)
|
this.httpService.setAuthorizationToken(session.authorizationValue)
|
||||||
|
|
||||||
this.apiService.setSession(session, persist)
|
this.apiService.setSession(session, persist)
|
||||||
|
|
||||||
|
void this.webSocketsService.startWebSocketConnection()
|
||||||
}
|
}
|
||||||
|
|
||||||
public online() {
|
public online() {
|
||||||
@@ -625,8 +626,6 @@ export class SNSessionManager extends AbstractService<SessionEvent> implements S
|
|||||||
this.httpService.setHost(host)
|
this.httpService.setHost(host)
|
||||||
|
|
||||||
this.setSession(session)
|
this.setSession(session)
|
||||||
|
|
||||||
await this.webSocketsService.startWebSocketConnection()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleAuthResponse(body: UserRegistrationResponseBody, rootKey: SNRootKey, wrappingKey?: SNRootKey) {
|
private async handleAuthResponse(body: UserRegistrationResponseBody, rootKey: SNRootKey, wrappingKey?: SNRootKey) {
|
||||||
|
|||||||
Reference in New Issue
Block a user