diff --git a/src/app/core/data/version-history-data.service.ts b/src/app/core/data/version-history-data.service.ts index 659feb9276d..f968b9e61da 100644 --- a/src/app/core/data/version-history-data.service.ts +++ b/src/app/core/data/version-history-data.service.ts @@ -16,7 +16,12 @@ import { VERSION_HISTORY } from '../shared/version-history.resource-type'; import { followLink, FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; import { VersionDataService } from './version-data.service'; import { HttpOptions } from '../dspace-rest/dspace-rest.service'; -import { getAllSucceededRemoteData, getFirstCompletedRemoteData, getFirstSucceededRemoteDataPayload, getRemoteDataPayload } from '../shared/operators'; +import { + getAllSucceededRemoteData, + getFirstCompletedRemoteData, + getFirstSucceededRemoteDataPayload, + getRemoteDataPayload +} from '../shared/operators'; import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model'; import { hasValueOperator } from '../../shared/empty.util'; import { Item } from '../shared/item.model'; diff --git a/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.spec.ts b/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.spec.ts index fc5c1dafc97..a8db842070e 100644 --- a/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.spec.ts +++ b/src/app/shared/dso-page/dso-versioning-modal-service/dso-versioning-modal.service.spec.ts @@ -18,6 +18,7 @@ describe('DsoVersioningModalService', () => { let router; let workspaceItemDataService; let itemService; + let editItemService; const mockItem: Item = Object.assign(new Item(), { bundles: createSuccessfulRemoteDataObject$(buildPaginatedList(new PageInfo(), [])), @@ -48,6 +49,7 @@ describe('DsoVersioningModalService', () => { router = jasmine.createSpyObj('router', ['navigateByUrl']); workspaceItemDataService = jasmine.createSpyObj('workspaceItemDataService', ['findByItem']); itemService = jasmine.createSpyObj('itemService', ['findByHref']); + editItemService = jasmine.createSpyObj('editItemService', ['invalidateItemCache']); service = new DsoVersioningModalService( modalService, @@ -56,7 +58,8 @@ describe('DsoVersioningModalService', () => { itemVersionShared, router, workspaceItemDataService, - itemService + itemService, + editItemService, ); })); describe('when onCreateNewVersion() is called', () => { 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..e66a6f5e146 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 @@ -16,6 +16,8 @@ import { ItemVersionsSharedService } from '../../../item-page/versions/item-vers import { ItemVersionsSummaryModalComponent } from '../../../item-page/versions/item-versions-summary-modal/item-versions-summary-modal.component'; +import { EditItemDataService } from '../../../core/submission/edititem-data.service'; +import { fromPromise } from 'rxjs/internal/observable/innerFrom'; /** * Service to take care of all the functionality related to the version creation modal @@ -34,6 +36,7 @@ export class DsoVersioningModalService { protected router: Router, protected workspaceItemDataService: WorkspaceitemDataService, protected itemService: ItemDataService, + protected editItemService: EditItemDataService, ) { } @@ -71,11 +74,9 @@ export class DsoVersioningModalService { getFirstSucceededRemoteDataPayload(), switchMap((newVersionItem: Item) => this.workspaceItemDataService.findByItem(newVersionItem.uuid, true, false)), getFirstSucceededRemoteDataPayload(), - ).subscribe((wsItem) => { - const wsiId = wsItem.id; - const route = 'workspaceitems/' + wsiId + '/edit'; - this.router.navigateByUrl(route); - }); + map((wsItem: WorkspaceItem) => `workspaceitems/${wsItem?.id}/edit`), + switchMap((route: string) => fromPromise(this.router.navigateByUrl(route))), + ).subscribe(() => this.editItemService.invalidateItemCache(item.uuid)); } /**