From 588432a0db67bdb141f28e49221e5361e1337fdb Mon Sep 17 00:00:00 2001 From: George Date: Mon, 6 Feb 2023 14:49:38 +0200 Subject: [PATCH] RED-4590: Replace else statments with early returns. --- .../file-workload/file-workload.component.ts | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts index c48a9f3a5..a637a1dad 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts @@ -410,32 +410,32 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy private _navigatePages($event: KeyboardEvent) { const pageIdx = this.displayedPages.indexOf(this.activeViewerPage); - if ($event.key === 'ArrowDown') { - if (pageIdx !== -1) { - // If active page has annotations - if (pageIdx !== this.displayedPages.length - 1) { - this.pdf.navigateTo(this.displayedPages[pageIdx + 1]); - } - } else { - // If active page doesn't have annotations - const nextPage = this._nextPageWithAnnotations(); - if (nextPage) { - this.pdf.navigateTo(nextPage); - } - } - } else { - if (pageIdx !== -1) { - // If active page has annotations - if (pageIdx !== 0) { - this.pdf.navigateTo(this.displayedPages[pageIdx - 1]); - } - } else { + if ($event.key !== 'ArrowDown') { + if (pageIdx === -1) { // If active page doesn't have annotations const prevPage = this._prevPageWithAnnotations(); if (prevPage) { this.pdf.navigateTo(prevPage); } + return; } + // If active page has annotations + if (pageIdx !== 0) { + this.pdf.navigateTo(this.displayedPages[pageIdx - 1]); + } + return; + } + if (pageIdx === -1) { + // If active page doesn't have annotations + const nextPage = this._nextPageWithAnnotations(); + if (nextPage) { + this.pdf.navigateTo(nextPage); + } + return; + } + // If active page has annotations + if (pageIdx !== this.displayedPages.length - 1) { + this.pdf.navigateTo(this.displayedPages[pageIdx + 1]); } }