diff --git a/generators/app/templates/package.json b/generators/app/templates/package.json index c492c9cc..820c24bb 100644 --- a/generators/app/templates/package.json +++ b/generators/app/templates/package.json @@ -124,7 +124,8 @@ "@hocs": "./src/hocs", "@utils": "./src/utils", "@hooks": "./src/hooks", - "@constants": "./src/constants" + "@constants": "./src/constants", + "@vocabs": "./src/vocabs" } } ] diff --git a/generators/app/templates/src/containers/TicTacToe/GameListPage/children/List/list.component.js b/generators/app/templates/src/containers/TicTacToe/GameListPage/children/List/list.component.js index 6d66aa16..875b1bf9 100644 --- a/generators/app/templates/src/containers/TicTacToe/GameListPage/children/List/list.component.js +++ b/generators/app/templates/src/containers/TicTacToe/GameListPage/children/List/list.component.js @@ -12,6 +12,7 @@ import { notification as helperNotification } from '@utils'; import { GameStatusList, GameStatus, KnownInboxes } from '@constants'; +import { LDP } from '@vocabs'; import { Wrapper, ListWrapper, GameListContainers, GameListHeader } from './list.style'; import GameItem from './children'; @@ -187,10 +188,28 @@ const List = ({ webId, gamePath, sendNotification }: Props) => { const getGames = useCallback( async url => { try { + let gameItemPredicate; const document = await ldflexHelper.fetchLdflexDocument(url); let gameList = []; if (!document) return gameList; - for await (const item of document['schema:hasPart']) { + + const type = await document['rdf:type']; + const typeValue = type ? type.value : undefined; + + /** + * If the document is a container, then we want to loop over the ldp:contains property of the container + * If it is not a container, we are using schema:hasPart so we don't confuse it with a container + * schema:hasPart is used for externally linked games in other people's pods + */ + if (typeValue === LDP.BASICCONTAINER) { + gameItemPredicate = 'ldp:contains'; + } else { + gameItemPredicate = 'schema:hasPart'; + } + + for await (const item of document[gameItemPredicate]) { + // TODO: Add SHEX Validation here instead of checking manually for filenames and types + const { value } = item; if ( value.includes('.ttl') && diff --git a/generators/app/templates/src/vocabs/index.js b/generators/app/templates/src/vocabs/index.js new file mode 100644 index 00000000..2e834796 --- /dev/null +++ b/generators/app/templates/src/vocabs/index.js @@ -0,0 +1,3 @@ +import { LDP } from './predicates'; + +export { LDP }; diff --git a/generators/app/templates/src/vocabs/predicates.js b/generators/app/templates/src/vocabs/predicates.js new file mode 100644 index 00000000..69b00529 --- /dev/null +++ b/generators/app/templates/src/vocabs/predicates.js @@ -0,0 +1,7 @@ +/** + * Object containing a reference to the UI ontology's IRIs + */ +const ldpBase = 'http://www.w3.org/ns/ldp#'; +export const LDP = { + BASICCONTAINER: `${ldpBase}BasicContainer` +};