diff --git a/package.json b/package.json index 3b912f2..f3970f8 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "dotenv": "^4.0.0", "express": "~4.14.0", "helmet": "^3.9.0", + "loadash": "^1.0.0", "marked": "^0.3.6", "morgan": "~1.7.0", "pug": "~2.0.0-beta6" diff --git a/routes/settings.js b/routes/settings.js index ff2e3a8..ebd01c8 100644 --- a/routes/settings.js +++ b/routes/settings.js @@ -6,7 +6,7 @@ const { createClient } = require('contentful') const { initClients, getSpace } = require('./../services/contentful') const { updateCookie } = require('../lib/cookies') const { translate } = require('../i18n/i18n') - +const { uniqWith, isEqual } = require('lodash') const SETTINGS_NAME = 'theExampleAppSettings' async function renderSettings (response, opts) { @@ -58,7 +58,7 @@ module.exports.getSettings = async (request, response, next) => { */ module.exports.postSettings = async (request, response, next) => { const currentLocale = response.locals.currentLocale - const errorList = [] + let errorList = [] const { spaceId, deliveryToken, previewToken, editorialFeatures } = request.body const settings = { spaceId, @@ -143,7 +143,7 @@ module.exports.postSettings = async (request, response, next) => { } } } - + errorList = uniqWith(errorList, isEqual) // If no errors, then cache the new settings in the cookie if (!errorList.length) { // Store new settings