Skip to content

Commit

Permalink
feat: rdf resource object as state
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Jan 3, 2022
1 parent fc446f3 commit 0d8caf0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/long-dryers-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hydrofoil/shell-core": patch
---

Preserve entire RdfResource when set to core state
15 changes: 12 additions & 3 deletions packages/core/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { HydraClient } from 'alcaeus/alcaeus'
import type { GraphPointer } from 'clownface'
import type { Term } from '@rdfjs/types'
import type { Store } from '@hydrofoil/shell'
import type { RdfResource } from 'alcaeus'
import type { Model } from './store.js'

export interface CoreState {
Expand All @@ -13,7 +14,7 @@ export interface CoreState {
contentResource?: {
id: Term
pointer?: GraphPointer
}
} | RdfResource
entrypoint?: GraphPointer
client?: HydraClient
}
Expand All @@ -24,7 +25,7 @@ declare module '@hydrofoil/shell-core/store' {
}
}

interface SetContentResource {
type SetContentResource = RdfResource | {
id?: Term
pointer: GraphPointer
}
Expand All @@ -44,7 +45,15 @@ const reducers = {
},
}
},
setContentResource(state: CoreState, { id, pointer }: SetContentResource): CoreState {
setContentResource(state: CoreState, arg: SetContentResource): CoreState {
if ('types' in arg) {
return {
...state,
contentResource: arg,
}
}

const { id, pointer } = arg
return {
...state,
contentResource: {
Expand Down

0 comments on commit 0d8caf0

Please sign in to comment.