commit 8fcddcc09bd17679aae379b792b9bf7f6548c7eb Author: Ole Date: Fri Oct 9 17:49:34 2020 +0200 Refactor reload 5: Await _getDiff() This function is very hard to follow. Making small steps to ensure careful review. Get rid of one more then block. I kept the two try blocks in this change in order to preserve the runtime behavior and make this a pure refactoring. Change-Id: I3e49f6f84d71d9321bac1c7bbfa23680571fbb00 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 916b632..093b1c3 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 @@ -352,25 +352,19 @@ export class GrDiffHost extends GestureEventListeners( this._coverageRanges = []; this._getCoverageData(); - const diffRequest = this._getDiff() - .then(diff => { - this._loadedWhitespaceLevel = whitespaceLevel; - this._reportDiff(diff); - return diff; - }) - .catch(e => { - this._handleGetDiffError(e); - return null; - }); + let diff: DiffInfo; try { - const diff = await diffRequest; - - if (!diff) { - this._loading = false; - return; - } + diff = await this._getDiff(); + this._loadedWhitespaceLevel = whitespaceLevel; + this._reportDiff(diff); + } catch (e) { + this._handleGetDiffError(e); + this._loading = false; + return; + } + try { await this._loadDiffAssets(diff); // Not waiting for coverage ranges intentionally as