mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 10:34:15 +00:00
Merge branch 'followlink-refactor' into metadata-and-relationships-combined-in-submission
This commit is contained in:
21
src/app/core/cache/object-cache.reducer.ts
vendored
21
src/app/core/cache/object-cache.reducer.ts
vendored
@@ -1,3 +1,5 @@
|
||||
import { HALLink } from '../shared/hal-link.model';
|
||||
import { HALResource } from '../shared/hal-resource.model';
|
||||
import {
|
||||
ObjectCacheAction,
|
||||
ObjectCacheActionTypes,
|
||||
@@ -10,13 +12,6 @@ import { hasValue, isNotEmpty } from '../../shared/empty.util';
|
||||
import { CacheEntry } from './cache-entry';
|
||||
import { ResourceType } from '../shared/resource-type';
|
||||
import { applyPatch, Operation } from 'fast-json-patch';
|
||||
import { NormalizedItem } from './models/normalized-item.model';
|
||||
|
||||
export enum DirtyType {
|
||||
Created = 'Created',
|
||||
Updated = 'Updated',
|
||||
Deleted = 'Deleted'
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface to represent a JsonPatch
|
||||
@@ -35,6 +30,7 @@ export interface Patch {
|
||||
|
||||
export abstract class TypedObject {
|
||||
static type: ResourceType;
|
||||
type: ResourceType;
|
||||
}
|
||||
|
||||
/* tslint:disable:max-classes-per-file */
|
||||
@@ -43,10 +39,13 @@ export abstract class TypedObject {
|
||||
*
|
||||
* A cacheable object should have a self link
|
||||
*/
|
||||
export class CacheableObject extends TypedObject {
|
||||
export class CacheableObject extends TypedObject implements HALResource {
|
||||
uuid?: string;
|
||||
handle?: string;
|
||||
self: string;
|
||||
|
||||
_links: {
|
||||
self: HALLink;
|
||||
}
|
||||
// isNew: boolean;
|
||||
// dirtyType: DirtyType;
|
||||
// hasDirtyAttributes: boolean;
|
||||
@@ -131,9 +130,9 @@ export function objectCacheReducer(state = initialState, action: ObjectCacheActi
|
||||
* the new state, with the object added, or overwritten.
|
||||
*/
|
||||
function addToObjectCache(state: ObjectCacheState, action: AddToObjectCacheAction): ObjectCacheState {
|
||||
const existing = state[action.payload.objectToCache.self];
|
||||
const existing = state[action.payload.objectToCache._links.self.href];
|
||||
return Object.assign({}, state, {
|
||||
[action.payload.objectToCache.self]: {
|
||||
[action.payload.objectToCache._links.self.href]: {
|
||||
data: action.payload.objectToCache,
|
||||
timeAdded: action.payload.timeAdded,
|
||||
msToLive: action.payload.msToLive,
|
||||
|
Reference in New Issue
Block a user