From efa752d1777aa19ed30c2f789b0a3648433d0091 Mon Sep 17 00:00:00 2001 From: Yury Bondarenko Date: Wed, 7 Feb 2024 10:49:37 +0100 Subject: [PATCH] Clean up draft version pipe --- src/app/core/data/version-history-data.service.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/app/core/data/version-history-data.service.ts b/src/app/core/data/version-history-data.service.ts index 0e0082e1b6e..82290835355 100644 --- a/src/app/core/data/version-history-data.service.ts +++ b/src/app/core/data/version-history-data.service.ts @@ -170,14 +170,13 @@ export class VersionHistoryDataService extends IdentifiableDataService { return this.versionDataService.findByHref(versionHref, false, true, followLink('versionhistory')).pipe( getFirstCompletedRemoteData(), - switchMap((res) => { - if (res.hasSucceeded && !res.hasNoContent) { - return res.payload.versionhistory.pipe( + switchMap((versionRD: RemoteData) => { + if (versionRD.hasSucceeded && !versionRD.hasNoContent) { + return versionRD.payload.versionhistory.pipe( getFirstCompletedRemoteData(), - map((versionHistoryRD) => { - if (res.hasSucceeded) { - const versionHistory = versionHistoryRD.payload; - return versionHistory ? versionHistory.draftVersion : false; + map((versionHistoryRD: RemoteData) => { + if (versionHistoryRD.hasSucceeded && !versionHistoryRD.hasNoContent) { + return versionHistoryRD.payload.draftVersion; } else { return false; }