commit 4bacbb0f8605a34379ac234545cbc650ca4bc785 Author: Ole Date: Fri Oct 9 17:19:34 2020 +0200 Refactor reload 4: Separate await diff and asset This function is very hard to follow. Making small steps to ensure careful review. Loading assets is anyways blocked on loading diffs, so make that sequence more obvious. Change-Id: I7cf0d994989bd5b6d9a7e1f11956d228ac3c7ef6 diff --git a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts index 009bfbb..916b632 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts +++ b/polygerrit-ui/app/elements/diff/gr-diff-host/gr-diff-host.ts @@ -363,24 +363,19 @@ export class GrDiffHost extends GestureEventListeners( return null; }); - const assetRequest = diffRequest.then(diff => { - // If the diff is null, then it's failed to load. + try { + const diff = await diffRequest; + if (!diff) { - return null; + this._loading = false; + return; } - return this._loadDiffAssets(diff); - }); + await this._loadDiffAssets(diff); - try { // Not waiting for coverage ranges intentionally as // plugin loading should not block the content rendering - const results = await Promise.all([diffRequest, assetRequest]); - const diff = results[0]; - if (!diff) { - this._loading = false; - return; - } + this.filesWeblinks = this._getFilesWeblinks(diff); this.diff = diff; const event = await new Promise(resolve => {