refactor: http service (#2233)

This commit is contained in:
Mo
2023-02-28 20:43:25 -06:00
committed by GitHub
parent 6e7618b258
commit e7f1d35341
142 changed files with 1116 additions and 1307 deletions

View File

@@ -7,7 +7,7 @@ import {
lastElement,
isString,
} from '@standardnotes/utils'
import { ClientDisplayableError, UserFeaturesResponse } from '@standardnotes/responses'
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
import { ContentType } from '@standardnotes/common'
import { RoleName } from '@standardnotes/domain-core'
import { FillItemContent, PayloadEmitSource } from '@standardnotes/models'
@@ -417,8 +417,8 @@ export class SNFeaturesService
if (shouldDownloadRoleBasedFeatures) {
const featuresResponse = await this.apiService.getUserFeatures(userUuid)
if (!featuresResponse.error && featuresResponse.data && !this.deinited) {
const features = (featuresResponse as UserFeaturesResponse).data.features
if (!isErrorResponse(featuresResponse) && !this.deinited) {
const features = featuresResponse.data.features
await this.didDownloadFeatures(features)
}
}
@@ -747,7 +747,7 @@ export class SNFeaturesService
private async performDownloadExternalFeature(url: string): Promise<Models.SNComponent | undefined> {
const response = await this.apiService.downloadFeatureUrl(url)
if (response.error) {
if (response.data?.error) {
await this.alertService.alert(API_MESSAGE_FAILED_DOWNLOADING_EXTENSION)
return undefined
}