* Removed arrows from notification

* Added trash can function
* Tweaked status text to always be the same
* Removed some open second note code
* Edior always focuses on text now
* Added some extra loading note messages
* Notes are now removed from search index when deleted
* Lots more things happen and update in real time on multiple machines
* Shared notes can be reverted
* WAY more tests
* Note Categories are much more reliable
* Lots of code is much cleaner
This commit is contained in:
Max G
2020-05-18 07:45:35 +00:00
parent e87e8513bc
commit 5096e74a60
18 changed files with 644 additions and 368 deletions

View File

@@ -1,7 +1,7 @@
var express = require('express')
var router = express.Router()
let Notes = require('@models/Note')
let Note = require('@models/Note')
let User = require('@models/User')
let ShareNote = require('@models/ShareNote')
@@ -22,36 +22,36 @@ router.use(function setUserId (req, res, next) {
// Note actions
//
router.post('/get', function (req, res) {
Notes.get(userId, req.body.noteId, masterKey)
Note.get(userId, req.body.noteId, masterKey)
.then( data => {
res.send(data)
})
})
router.post('/delete', function (req, res) {
Notes.delete(userId, req.body.noteId)
Note.delete(userId, req.body.noteId)
.then( data => res.send(data) )
})
router.post('/create', function (req, res) {
Notes.create(req.io, userId, req.body.title, req.body.text, masterKey)
Note.create(userId, req.body.title, req.body.text, masterKey)
.then( id => res.send({id}) )
})
router.post('/update', function (req, res) {
Notes.update(req.io, userId, req.body.noteId, req.body.text, req.body.title, req.body.color, req.body.pinned, req.body.archived, req.body.hash, masterKey)
Note.update(userId, req.body.noteId, req.body.text, req.body.title, req.body.color, req.body.pinned, req.body.archived, req.body.hash, masterKey)
.then( id => res.send({id}) )
})
router.post('/search', function (req, res) {
Notes.search(userId, req.body.searchQuery, req.body.searchTags, req.body.fastFilters, masterKey)
.then( notesAndTags => {
res.send(notesAndTags)
Note.search(userId, req.body.searchQuery, req.body.searchTags, req.body.fastFilters, masterKey)
.then( NoteAndTags => {
res.send(NoteAndTags)
})
})
router.post('/difftext', function (req, res) {
Notes.getDiffText(userId, req.body.noteId, req.body.text, req.body.updated)
Note.getDiffText(userId, req.body.noteId, req.body.text, req.body.updated)
.then( fullDiffText => {
//Response should be full diff text
res.send(fullDiffText)
@@ -59,7 +59,7 @@ router.post('/difftext', function (req, res) {
})
router.post('/reindex', function (req, res) {
Notes.reindex(userId, masterKey)
Note.reindex(userId, masterKey)
.then( data => {
res.send(data)
})
@@ -70,13 +70,19 @@ router.post('/reindex', function (req, res) {
// Update single note attributes
//
router.post('/setpinned', function (req, res) {
Notes.setPinned(userId, req.body.noteId, req.body.pinned)
Note.setPinned(userId, req.body.noteId, req.body.pinned)
.then( results => {
res.send(results)
})
})
router.post('/setarchived', function (req, res) {
Notes.setArchived(userId, req.body.noteId, req.body.archived)
Note.setArchived(userId, req.body.noteId, req.body.archived)
.then( results => {
res.send(results)
})
})
router.post('/settrashed', function (req, res) {
Note.setTrashed(userId, req.body.noteId, req.body.trashed)
.then( results => {
res.send(results)
})
@@ -98,15 +104,13 @@ router.post('/shareadduser', function (req, res) {
})
.then( ({success, shareUserId}) => {
//Emit update count event to user shared with - so they see the note in real time
req.io.to(shareUserId).emit('update_counts')
res.send(success)
})
})
router.post('/shareremoveuser', function (req, res) {
ShareNote.removeUser(userId, req.body.noteId)
// (userId, noteId, shareNoteUserId, shareUserId, masterKey)
ShareNote.removeUserFromShared(userId, req.body.noteId, req.body.shareUserNoteId, masterKey)
.then(results => res.send(results))
})
@@ -114,10 +118,10 @@ router.post('/shareremoveuser', function (req, res) {
//
// Testing Action
//
//Reindex all notes. Not a very good function, not public
//Reindex all Note. Not a very good function, not public
router.get('/reindex5yu43prchuj903mrc', function (req, res) {
Notes.migrateNoteTextToNewTable().then(status => {
Note.migrateNoteTextToNewTable().then(status => {
return res.send(status)
})

View File

@@ -24,7 +24,7 @@ router.post('/get', function (req, res) {
//Push text to quick note
router.post('/update', function (req, res) {
QuickNote.update(req.io, userId, req.body.pushText, masterKey)
QuickNote.update(userId, req.body.pushText, masterKey)
.then( data => res.send(data) )
})