|
|
|
@ -12,17 +12,19 @@ router.get('', auth.checkApiAuth, async (req, res, next) => {
|
|
|
|
res.send(await getRecentNotes());
|
|
|
|
res.send(await getRecentNotes());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
router.put('/:notePath', auth.checkApiAuth, async (req, res, next) => {
|
|
|
|
router.put('/:noteTreeId/:notePath', auth.checkApiAuth, async (req, res, next) => {
|
|
|
|
|
|
|
|
const noteTreeId = req.params.noteTreeId;
|
|
|
|
const notePath = req.params.notePath;
|
|
|
|
const notePath = req.params.notePath;
|
|
|
|
|
|
|
|
|
|
|
|
await sql.doInTransaction(async () => {
|
|
|
|
await sql.doInTransaction(async () => {
|
|
|
|
await sql.replace('recent_notes', {
|
|
|
|
await sql.replace('recent_notes', {
|
|
|
|
|
|
|
|
note_tree_id: noteTreeId,
|
|
|
|
note_path: notePath,
|
|
|
|
note_path: notePath,
|
|
|
|
date_accessed: utils.nowTimestamp(),
|
|
|
|
date_accessed: utils.nowTimestamp(),
|
|
|
|
is_deleted: 0
|
|
|
|
is_deleted: 0
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await sync_table.addRecentNoteSync(notePath);
|
|
|
|
await sync_table.addRecentNoteSync(noteTreeId);
|
|
|
|
|
|
|
|
|
|
|
|
await options.setOption('start_note_tree_id', notePath);
|
|
|
|
await options.setOption('start_note_tree_id', notePath);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -30,18 +32,6 @@ router.put('/:notePath', auth.checkApiAuth, async (req, res, next) => {
|
|
|
|
res.send(await getRecentNotes());
|
|
|
|
res.send(await getRecentNotes());
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
router.delete('/:notePath', auth.checkApiAuth, async (req, res, next) => {
|
|
|
|
|
|
|
|
const notePath = req.params.notePath;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await sql.doInTransaction(async () => {
|
|
|
|
|
|
|
|
await sql.execute('UPDATE recent_notes SET is_deleted = 1 WHERE note_path = ?', [notePath]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await sync_table.addRecentNoteSync(notePath);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res.send(await getRecentNotes());
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getRecentNotes() {
|
|
|
|
async function getRecentNotes() {
|
|
|
|
await deleteOld();
|
|
|
|
await deleteOld();
|
|
|
|
|
|
|
|
|
|
|
|
|