Bugfix Batch

* Animations disabled on remote events, closing note still triggers animation for local user
* Created save icons to fix display on mobile
* Hidden URLs are hidden until note is deleted or URL is removed from note
* Tags search all categories, but probably not trash
* Back to all notes button clears search
* Deleted Notes are removed from search index
This commit is contained in:
Max G
2020-05-19 03:38:43 +00:00
parent 5096e74a60
commit 543ecf0f2d
8 changed files with 58 additions and 45 deletions

View File

@@ -136,7 +136,7 @@ app.use(function(req, res, next){
// Test Area
const printResults = true
const printResults = false
let UserTest = require('@models/User')
let NoteTest = require('@models/Note')
UserTest.keyPairTest('genMan2', '1', printResults)

View File

@@ -138,11 +138,8 @@ Attachment.delete = (userId, attachmentId, urlDelete = false) => {
.then((rows, fields) => {
noteExists = (rows[0]['exists'] > 0)
noteExists = (rows[0][0]['exists'] > 0)
let url = attachment.url
const noteId = attachment.note_id
@@ -158,18 +155,16 @@ Attachment.delete = (userId, attachmentId, urlDelete = false) => {
if(attachment.attachment_type == 1 && !urlDelete && noteExists){
db.promise()
.query(`UPDATE attachment SET visible = 0 WHERE id = ?`, [attachmentId])
.then((rows, fields) => { })
.then((rows, fields) => resolve(true))
.catch(console.log)
return resolve(true)
} else {
db.promise()
.query(`DELETE FROM attachment WHERE id = ?`, [attachmentId])
.then((rows, fields) => resolve(true))
.catch(console.log)
}
db.promise()
.query(`DELETE FROM attachment WHERE id = ?`, [attachmentId])
.then((rows, fields) => { })
.catch(console.log)
return resolve(true)
})
})
}

View File

@@ -299,7 +299,7 @@ Note.reindex = (userId, masterKey, removeId = null) => {
return db.promise().query(`
SELECT note.id, text, salt, encrypted_share_password_key FROM note
JOIN note_raw_text ON note.note_raw_text_id = note_raw_text.id
WHERE indexed = 0 AND salt IS NOT NULL
WHERE indexed = 0 AND salt IS NOT NULL AND trashed = 0
AND user_id = ? LIMIT 100`, [userId])
})
@@ -610,7 +610,7 @@ Note.setArchived = (userId, noteId, archivedBoolead) => {
})
}
Note.setTrashed = (userId, noteId, trashedBoolean) => {
Note.setTrashed = (userId, noteId, trashedBoolean, masterKey) => {
return new Promise((resolve, reject) => {
const trashed = trashedBoolean ? 1:0
@@ -618,9 +618,18 @@ Note.setTrashed = (userId, noteId, trashedBoolean) => {
//Update other note attributes
return db.promise()
.query('UPDATE note JOIN note_raw_text ON note_raw_text_id = note_raw_text.id SET trashed = ?, updated = ? WHERE note.id = ? AND user_id = ?',
.query('UPDATE note JOIN note_raw_text ON note_raw_text_id = note_raw_text.id SET trashed = ?, updated = ?, indexed = 0 WHERE note.id = ? AND user_id = ?',
[trashed, now, noteId, userId])
.then((rows, fields) => {
const removeFromIndex = []
if(trashed){
//Remove note from index
removeFromIndex.push(noteId)
}
Note.reindex(userId, masterKey, removeFromIndex)
SocketIo.to(userId).emit('note_attribute_modified', noteId)
resolve(true)
})
@@ -1016,12 +1025,16 @@ Note.search = (userId, searchQuery, searchTags, fastFilters, masterKey) => {
//If tags are passed, use those tags in search
if(searchTags.length > 0){
searchParams.push(searchTags)
noteSearchQuery += ' AND note_tag.tag_id IN (?)'
noteSearchQuery += ' AND note_tag.tag_id IN (?) AND note.trashed = 0'
searchAllNotes = true
}
//Show archived notes, only if fast filter is set, default to not archived
if(searchAllNotes == false){
//Default set of filters for all notes
if(fastFilters.notesHome == 1){
noteSearchQuery += ' AND note.archived = 0 AND note.trashed = 0 AND note.share_user_id IS NULL'
}

View File

@@ -17,7 +17,7 @@ Tag.userTags = (userId, searchQuery, searchTags, fastFilters) => {
FROM tag
JOIN note_tag ON tag.id = note_tag.tag_id
JOIN note ON note.id = note_tag.note_id
WHERE note_tag.user_id = ?
WHERE note_tag.user_id = ? AND note.trashed = 0
`
query += ` GROUP BY tag.id

View File

@@ -29,7 +29,7 @@ router.post('/get', function (req, res) {
})
router.post('/delete', function (req, res) {
Note.delete(userId, req.body.noteId)
Note.delete(userId, req.body.noteId, masterKey)
.then( data => res.send(data) )
})
@@ -82,7 +82,7 @@ router.post('/setarchived', function (req, res) {
})
})
router.post('/settrashed', function (req, res) {
Note.setTrashed(userId, req.body.noteId, req.body.trashed)
Note.setTrashed(userId, req.body.noteId, req.body.trashed, masterKey)
.then( results => {
res.send(results)
})