Skip to content

Commit

Permalink
Don't start out as draft, clean up pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
ybnd committed Feb 7, 2024
1 parent 54a720f commit 4c93b89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions src/app/core/data/version-history-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,13 @@ export class VersionHistoryDataService extends IdentifiableDataService<VersionHi
hasDraftVersion$(versionHref: string): Observable<boolean> {
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<Version>) => {
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<VersionHistory>) => {
if (versionHistoryRD.hasSucceeded && !versionHistoryRD.hasNoContent) {
return versionHistoryRD.payload.draftVersion;
} else {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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),
);
}

Expand Down

0 comments on commit 4c93b89

Please sign in to comment.