From 25abab54589576399156e96282861d2ce98927b0 Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 12 Sep 2021 17:29:29 +0200 Subject: [PATCH] Refactoring --- src/combination/dimensions.js | 19 ++++--------------- src/combination/user_ids.js | 7 ++++--- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/combination/dimensions.js b/src/combination/dimensions.js index d7d52d78f..71d8795d0 100644 --- a/src/combination/dimensions.js +++ b/src/combination/dimensions.js @@ -10,9 +10,13 @@ // previews and `dev` export const DIMENSIONS = [ { + // Name used internally or in error messages dimension: 'task', + // Property name for the identifier idName: 'taskId', + // Property name for the title titleName: 'taskTitle', + // Whether dimension was created by users or by plugins createdByUser: true, }, { @@ -28,18 +32,3 @@ export const DIMENSIONS = [ createdByUser: true, }, ] - -// Dimensions created by users, not by plugins -const getUserDimensions = function () { - return new Set(DIMENSIONS.filter(isUserDimension).map(getDimensionName)) -} - -const isUserDimension = function ({ createdByUser }) { - return createdByUser -} - -const getDimensionName = function ({ dimension }) { - return dimension -} - -export const USER_DIMENSIONS = getUserDimensions() diff --git a/src/combination/user_ids.js b/src/combination/user_ids.js index 443a71f4e..77ee99930 100644 --- a/src/combination/user_ids.js +++ b/src/combination/user_ids.js @@ -1,4 +1,4 @@ -import { USER_DIMENSIONS } from './dimensions.js' +import { DIMENSIONS } from './dimensions.js' import { getCombinationsIds } from './ids.js' import { getInputIds } from './inputs.js' @@ -9,8 +9,9 @@ export const getUserIds = function (combinations, inputs) { return [...combinationsUserIds, ...nonCombinationsIds] } -const isUserId = function ({ dimension }) { - return USER_DIMENSIONS.has(dimension) +const isUserId = function (idInfo) { + return DIMENSIONS.find(({ dimension }) => idInfo.dimension === dimension) + .createdByUser } // Identifiers that do not relate to dimensions/combinations