From 43c49f54d29a2789381f811dcd680e47cf874878 Mon Sep 17 00:00:00 2001 From: Matus Benko Date: Mon, 11 Sep 2017 21:10:44 +0200 Subject: [PATCH] used findStorage function in the updateFolder --- browser/main/lib/dataApi/updateFolder.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/browser/main/lib/dataApi/updateFolder.js b/browser/main/lib/dataApi/updateFolder.js index e128a2d3..6c6e587b 100644 --- a/browser/main/lib/dataApi/updateFolder.js +++ b/browser/main/lib/dataApi/updateFolder.js @@ -2,6 +2,7 @@ const _ = require('lodash') const path = require('path') const resolveStorageData = require('./resolveStorageData') const CSON = require('@rokt33r/season') +const { findStorage } = require('browser/lib/findStorage') /** * @param {String} storageKey @@ -29,11 +30,7 @@ function updateFolder (storageKey, folderKey, input) { if (!_.isString(input.name)) throw new Error('Name must be a string.') if (!_.isString(input.color)) throw new Error('Color must be a string.') - rawStorages = JSON.parse(localStorage.getItem('storages')) - if (!_.isArray(rawStorages)) throw new Error('Target storage doesn\'t exist.') - - targetStorage = _.find(rawStorages, {key: storageKey}) - if (targetStorage == null) throw new Error('Target storage doesn\'t exist.') + targetStorage = findStorage(storageKey) } catch (e) { return Promise.reject(e) }