mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
fix moveNote Api
This commit is contained in:
@@ -65,15 +65,13 @@ function moveNote (storageKey, noteKey, newStorageKey, newFolderKey) {
|
|||||||
noteData.folder = newFolderKey
|
noteData.folder = newFolderKey
|
||||||
noteData.key = newNoteKey
|
noteData.key = newNoteKey
|
||||||
noteData.storage = newStorageKey
|
noteData.storage = newStorageKey
|
||||||
|
noteData.updatedAt = new Date()
|
||||||
|
|
||||||
return noteData
|
return noteData
|
||||||
})
|
})
|
||||||
.then(function writeAndReturn (noteData) {
|
.then(function writeAndReturn (noteData) {
|
||||||
CSON.writeFileSync(path.join(newStorage.path, 'notes', noteData.key + '.cson'), _.omit(noteData, ['key', 'storage']))
|
CSON.writeFileSync(path.join(newStorage.path, 'notes', noteData.key + '.cson'), _.omit(noteData, ['key', 'storage']))
|
||||||
return {
|
return noteData
|
||||||
oldStorageKey: storageKey,
|
|
||||||
oldNoteKey: noteKey,
|
|
||||||
note: noteData
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.then(function deleteOldNote (data) {
|
.then(function deleteOldNote (data) {
|
||||||
if (storageKey !== newStorageKey) {
|
if (storageKey !== newStorageKey) {
|
||||||
|
|||||||
@@ -42,12 +42,12 @@ test.serial('Move a note', (t) => {
|
|||||||
let data1 = data[0]
|
let data1 = data[0]
|
||||||
let data2 = data[1]
|
let data2 = data[1]
|
||||||
|
|
||||||
let jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.note.key + '.cson'))
|
let jsonData1 = CSON.readFileSync(path.join(storagePath, 'notes', data1.key + '.cson'))
|
||||||
|
|
||||||
t.is(jsonData1.folder, folderKey1)
|
t.is(jsonData1.folder, folderKey1)
|
||||||
t.is(jsonData1.title, note1.title)
|
t.is(jsonData1.title, note1.title)
|
||||||
|
|
||||||
let jsonData2 = CSON.readFileSync(path.join(storagePath2, 'notes', data2.note.key + '.cson'))
|
let jsonData2 = CSON.readFileSync(path.join(storagePath2, 'notes', data2.key + '.cson'))
|
||||||
t.is(jsonData2.folder, folderKey2)
|
t.is(jsonData2.folder, folderKey2)
|
||||||
t.is(jsonData2.title, note2.title)
|
t.is(jsonData2.title, note2.title)
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user