* 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 committed 2020-05-18 07:45:35 +00:00
1 parent e87e8513bc
commit 5096e74a60
18 files changed
+644 -368

No files matched your search

+22 -8
View File
@@ -117,6 +117,9 @@ Attachment.update = (userId, attachmentId, updatedText, noteId) => {
Attachment.delete = (userId, attachmentId, urlDelete = false) => {
let attachment = null
let noteExists = true
return new Promise((resolve, reject) => {
db.promise()
.query('SELECT * FROM attachment WHERE id = ? AND user_id = ? LIMIT 1', [attachmentId, userId])
@@ -127,21 +130,32 @@ Attachment.delete = (userId, attachmentId, urlDelete = false) => {
return resolve(true)
}
//Pull data we want out of
let row = rows[0][0]
let url = row.url
const noteId = row.note_id
attachment = rows[0][0]
return db.promise().query('SELECT count(id) as `exists` FROM note WHERE id = ?', [attachment.note_id])
})
.then((rows, fields) => {
noteExists = (rows[0]['exists'] > 0)
let url = attachment.url
const noteId = attachment.note_id
//Try to delete file and thumbnail
try {
fs.unlinkSync(filePath+row.file_location)
fs.unlinkSync(filePath+attachment.file_location)
} catch(err) { console.error('File Does not exist') }
try {
fs.unlinkSync(filePath+'thumb_'+row.file_location)
fs.unlinkSync(filePath+'thumb_'+attachment.file_location)
} catch(err) { console.error('Thumbnail Does not exist') }
//Do not delete link attachments, just hide them. They will be deleted if removed from note
if(row.attachment_type == 1 && !urlDelete){
//Do not delete link attachments, just hide them. They will be deleted if removed from note or if note is deleted
if(attachment.attachment_type == 1 && !urlDelete && noteExists){
db.promise()
.query(`UPDATE attachment SET visible = 0 WHERE id = ?`, [attachmentId])
.then((rows, fields) => { })