From ff85771c681aa25bc5e13f40caf41f408ce71ecc Mon Sep 17 00:00:00 2001 From: axolotle Date: Thu, 1 Jul 2021 16:01:05 +0200 Subject: [PATCH] fix orderedTextDepart getter --- src/store/modules/library.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/store/modules/library.js b/src/store/modules/library.js index 597eeaa..228cf65 100644 --- a/src/store/modules/library.js +++ b/src/store/modules/library.js @@ -15,7 +15,7 @@ export default { state: { trees: {}, randomNodes: undefined, - nodebook: undefined, + nodebook: [], // LibraryOptions options tagsOptions: [], @@ -219,20 +219,20 @@ export default { nodesDepartsOptions: (state, getters, rootState) => { const departIds = rootState.ids.depart - if (departIds === undefined || rootState.nodes[departIds[0]] === undefined) return - return departIds.map(id => { - const text = rootState.nodes[id] - const firstAuthor = text.authors !== null ? text.authors[0].name : 'Pad de noms' + if (departIds === undefined) return + const nodes = departIds.map(id => rootState.nodes[id]) + if (nodes.some(node => node === undefined)) return + return nodes.map(node => { + const firstAuthor = node.authors !== null ? node.authors[0].name : 'Pad de noms' return { - text: `${firstAuthor}, ${text.title} (${id})`, - value: id + text: `${firstAuthor}, ${node.title} (${node.id})`, + value: node.id } }) }, // Library nodebook: (state, getters, rootState) => { - if (!state.nodebook) return [] return state.nodebook.map(([parentId, ...childrenIds]) => { return { parent: rootState.nodes[parentId],