mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
used findStorage function in the updateFolder
This commit is contained in:
@@ -2,6 +2,7 @@ const _ = require('lodash')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
const resolveStorageData = require('./resolveStorageData')
|
const resolveStorageData = require('./resolveStorageData')
|
||||||
const CSON = require('@rokt33r/season')
|
const CSON = require('@rokt33r/season')
|
||||||
|
const { findStorage } = require('browser/lib/findStorage')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {String} storageKey
|
* @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.name)) throw new Error('Name must be a string.')
|
||||||
if (!_.isString(input.color)) throw new Error('Color must be a string.')
|
if (!_.isString(input.color)) throw new Error('Color must be a string.')
|
||||||
|
|
||||||
rawStorages = JSON.parse(localStorage.getItem('storages'))
|
targetStorage = findStorage(storageKey)
|
||||||
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.')
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return Promise.reject(e)
|
return Promise.reject(e)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user