proper syncing of note positions

This commit is contained in:
azivner
2017-11-02 22:55:22 -04:00
parent c3d776ae13
commit a7f95e95e9
5 changed files with 72 additions and 14 deletions

View File

@@ -55,6 +55,15 @@ router.get('/options/:optName', auth.checkApiAuth, async (req, res, next) => {
}
});
router.get('/notes_reordering/:noteParentId', auth.checkApiAuth, async (req, res, next) => {
const noteParentId = req.params.noteParentId;
res.send({
note_pid: noteParentId,
ordering: await sql.getMap("SELECT note_id, note_pos FROM notes_tree WHERE note_pid = ?", [noteParentId])
});
});
router.put('/notes', auth.checkApiAuth, async (req, res, next) => {
await sync.updateNote(req.body.entity, req.body.links, req.body.sourceId);
@@ -73,6 +82,12 @@ router.put('/notes_history', auth.checkApiAuth, async (req, res, next) => {
res.send({});
});
router.put('/notes_reordering', auth.checkApiAuth, async (req, res, next) => {
await sync.updateNoteReordering(req.body.entity, req.body.sourceId);
res.send({});
});
router.put('/options', auth.checkApiAuth, async (req, res, next) => {
await sync.updateOptions(req.body.entity, req.body.sourceId);