recent notes are now keyed by note tree id which simplifies things

This commit is contained in:
azivner
2017-12-03 10:06:53 -05:00
parent 41f089b3f4
commit 15faefe8a3
10 changed files with 36 additions and 54 deletions

View File

@@ -12,17 +12,19 @@ router.get('', auth.checkApiAuth, async (req, res, next) => {
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;
await sql.doInTransaction(async () => {
await sql.replace('recent_notes', {
note_tree_id: noteTreeId,
note_path: notePath,
date_accessed: utils.nowTimestamp(),
is_deleted: 0
});
await sync_table.addRecentNoteSync(notePath);
await sync_table.addRecentNoteSync(noteTreeId);
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());
});
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() {
await deleteOld();