mirror of https://github.com/status-im/codimd.git
Refactor, variable naming and myNoteList mapping
Signed-off-by: James Tsai <jamesscamel@gmail.com>
This commit is contained in:
parent
dcf48e749e
commit
a22cf73f60
|
@ -189,30 +189,26 @@ async function noteActions (req, res) {
|
|||
}
|
||||
}
|
||||
|
||||
async function getMyNoteList (userid, callback) {
|
||||
async function getMyNoteList(userId, callback) {
|
||||
const myNotes = await Note.findAll({
|
||||
where: {
|
||||
ownerId: userid
|
||||
ownerId: userId
|
||||
}
|
||||
})
|
||||
if (!myNotes) {
|
||||
return callback(null, null)
|
||||
}
|
||||
try {
|
||||
const myNoteList = []
|
||||
for (let i = 0; i < myNotes.length; i++) {
|
||||
const note = myNotes[i]
|
||||
myNoteList[i] = {
|
||||
const myNoteList = myNotes.map(note => ({
|
||||
id: Note.encodeNoteId(note.id),
|
||||
text: note.title,
|
||||
tags: Note.parseNoteInfo(note.content).tags,
|
||||
createdAt: note.createdAt,
|
||||
lastchangeAt: note.lastchangeAt,
|
||||
shortId: note.shortid
|
||||
}
|
||||
}
|
||||
}))
|
||||
if (config.debug) {
|
||||
logger.info('Parse myNoteList success: ' + userid)
|
||||
logger.info('Parse myNoteList success: ' + userId)
|
||||
}
|
||||
return callback(null, myNoteList)
|
||||
} catch (err) {
|
||||
|
|
Loading…
Reference in New Issue