From 4c93b89fa00e00f1bbe8462ccc61589b919ac73d Mon Sep 17 00:00:00 2001 From: Yury Bondarenko Date: Wed, 7 Feb 2024 10:37:31 +0100 Subject: [PATCH] Don't start out as draft, clean up pipe --- src/app/core/data/version-history-data.service.ts | 13 ++++++------- .../dso-versioning-modal.service.ts | 4 ++-- 2 files changed, 8 insertions(+), 9 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; } diff --git a/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.ts b/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.ts index 46792294dd8..b509b597eb6 100644 --- a/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.ts +++ b/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.ts @@ -1,7 +1,7 @@ import { getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload } from '../../../core/shared/operators'; import { RemoteData } from '../../../core/data/remote-data'; import { Version } from '../../../core/shared/version.model'; -import { map, startWith, switchMap, tap } from 'rxjs/operators'; +import { map, switchMap, tap } from 'rxjs/operators'; import { Item } from '../../../core/shared/item.model'; import { WorkspaceItem } from '../../../core/submission/models/workspaceitem.model'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; @@ -86,7 +86,7 @@ export class DsoVersioningModalService { // button is disabled if hasDraftVersion = true, and enabled if hasDraftVersion = false or null // (hasDraftVersion is null when a version history does not exist) map((res) => Boolean(res)), - startWith(true), + // startWith(true), ); }