Init assets in dialog model (#15533)

* check that there are assets before filtering

* init assets as empty array
This commit is contained in:
Barbara Valdez
2021-05-20 15:11:15 -07:00
committed by GitHub
parent a187e8f2de
commit 4c66b04572
2 changed files with 5 additions and 3 deletions

View File

@@ -250,13 +250,15 @@ export class RemoteBookDialog {
}
public async fillVersionDropdown(): Promise<void> {
let filtered_assets = (await this.controller.getAssets()).filter(asset => asset.book === this.bookDropdown.value);
const assets = await this.controller.getAssets();
let filtered_assets = assets.filter(asset => asset.book === this.bookDropdown.value);
this.versionDropdown.values = ['-'].concat(filtered_assets.map(asset => asset.version));
this.checkValues();
}
public async fillLanguageDropdown(): Promise<void> {
let filtered_assets = (await this.controller.getAssets()).filter(asset => asset.book === this.bookDropdown.value &&
const assets = await this.controller.getAssets();
let filtered_assets = assets.filter(asset => asset.book === this.bookDropdown.value &&
asset.version === this.versionDropdown.value);
this.languageDropdown.values = ['-'].concat(filtered_assets.map(asset => asset.language));
this.checkValues();

View File

@@ -9,7 +9,7 @@ import { IRelease, IAsset } from '../book/remoteBookController';
export class RemoteBookDialogModel {
private _remoteLocation: string;
private _releases: IRelease[] = [];
private _assets: IAsset[];
private _assets: IAsset[] = [];
private _book: RemoteBook;
constructor() {