mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
fixed eslint error & integrated with prettier as well as formatted the whole codebase (#3450)
This commit is contained in:
@@ -16,7 +16,7 @@ const CSON = require('@rokt33r/season')
|
||||
* 3. fetch notes & folders
|
||||
* 4. return `{storage: {...} folders: [folder]}`
|
||||
*/
|
||||
function addStorage (input) {
|
||||
function addStorage(input) {
|
||||
if (!_.isString(input.path)) {
|
||||
return Promise.reject(new Error('Path must be a string.'))
|
||||
}
|
||||
@@ -29,7 +29,7 @@ function addStorage (input) {
|
||||
rawStorages = []
|
||||
}
|
||||
let key = keygen()
|
||||
while (rawStorages.some((storage) => storage.key === key)) {
|
||||
while (rawStorages.some(storage => storage.key === key)) {
|
||||
key = keygen()
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ function addStorage (input) {
|
||||
|
||||
return Promise.resolve(newStorage)
|
||||
.then(resolveStorageData)
|
||||
.then(function saveMetadataToLocalStorage (resolvedStorage) {
|
||||
.then(function saveMetadataToLocalStorage(resolvedStorage) {
|
||||
newStorage = resolvedStorage
|
||||
rawStorages.push({
|
||||
key: newStorage.key,
|
||||
@@ -56,27 +56,29 @@ function addStorage (input) {
|
||||
localStorage.setItem('storages', JSON.stringify(rawStorages))
|
||||
return newStorage
|
||||
})
|
||||
.then(function (storage) {
|
||||
return resolveStorageNotes(storage)
|
||||
.then((notes) => {
|
||||
let unknownCount = 0
|
||||
notes.forEach((note) => {
|
||||
if (!storage.folders.some((folder) => note.folder === folder.key)) {
|
||||
unknownCount++
|
||||
storage.folders.push({
|
||||
key: note.folder,
|
||||
color: consts.FOLDER_COLORS[(unknownCount - 1) % 7],
|
||||
name: 'Unknown ' + unknownCount
|
||||
})
|
||||
}
|
||||
})
|
||||
if (unknownCount > 0) {
|
||||
CSON.writeFileSync(path.join(storage.path, 'boostnote.json'), _.pick(storage, ['folders', 'version']))
|
||||
.then(function(storage) {
|
||||
return resolveStorageNotes(storage).then(notes => {
|
||||
let unknownCount = 0
|
||||
notes.forEach(note => {
|
||||
if (!storage.folders.some(folder => note.folder === folder.key)) {
|
||||
unknownCount++
|
||||
storage.folders.push({
|
||||
key: note.folder,
|
||||
color: consts.FOLDER_COLORS[(unknownCount - 1) % 7],
|
||||
name: 'Unknown ' + unknownCount
|
||||
})
|
||||
}
|
||||
return notes
|
||||
})
|
||||
if (unknownCount > 0) {
|
||||
CSON.writeFileSync(
|
||||
path.join(storage.path, 'boostnote.json'),
|
||||
_.pick(storage, ['folders', 'version'])
|
||||
)
|
||||
}
|
||||
return notes
|
||||
})
|
||||
})
|
||||
.then(function returnValue (notes) {
|
||||
.then(function returnValue(notes) {
|
||||
return {
|
||||
storage: newStorage,
|
||||
notes
|
||||
|
||||
Reference in New Issue
Block a user