diff --git a/client/src/pages/NotesPage.vue b/client/src/pages/NotesPage.vue index d027acf..602615d 100644 --- a/client/src/pages/NotesPage.vue +++ b/client/src/pages/NotesPage.vue @@ -376,8 +376,7 @@ //If greater than 80 of the way down the page, load the next batch if(percentageDown >= 80){ - - console.log('loading next batch') + this.search(false, this.batchSize, true) } diff --git a/server/models/Attachment.js b/server/models/Attachment.js index 112af8f..0d8261a 100644 --- a/server/models/Attachment.js +++ b/server/models/Attachment.js @@ -123,16 +123,6 @@ Attachment.delete = (userId, attachmentId, urlDelete = false) => { let url = row.url const noteId = row.note_id - //Do not delete link attachments, just hide them. They will be deleted if removed from note - if(row.attachment_type == 1 && !urlDelete){ - db.promise() - .query(`UPDATE attachment SET visible = 0 WHERE id = ?`, [attachmentId]) - .then((rows, fields) => { }) - .catch(console.log) - - return resolve(true) - } - //Try to delete file and thumbnail try { fs.unlinkSync(filePath+row.file_location) @@ -141,41 +131,22 @@ Attachment.delete = (userId, attachmentId, urlDelete = false) => { fs.unlinkSync(filePath+'thumb_'+row.file_location) } catch(err) { console.error('Thumbnail Does not exist') } - db.promise() - .query(`DELETE FROM attachment WHERE id = ?`, [attachmentId]) - .then((rows, fields) => { }) - .catch(console.log) + //Do not delete link attachments, just hide them. They will be deleted if removed from note + if(row.attachment_type == 1 && !urlDelete){ + db.promise() + .query(`UPDATE attachment SET visible = 0 WHERE id = ?`, [attachmentId]) + .then((rows, fields) => { }) + .catch(console.log) - //Normal notes are done, for links, remove the link from the note - // if(row.attachment_type != 1){ return resolve(true) - // } + } - //The code below will delete URL text for note - db.promise().query('SELECT text FROM note WHERE id = ? AND user_id = ?', [noteId, userId]) - .then((rows, fields) => { - - //Grab note text - let text = rows[0][0]['text'] - //Remove URL from text, then remove A tags with empty hrefs - let newText = text.replace(url, '').replace(/[^<]*<\/a>/g, '') + db.promise() + .query(`DELETE FROM attachment WHERE id = ?`, [attachmentId]) + .then((rows, fields) => { }) + .catch(console.log) - db.promise().query('UPDATE note SET text = ? WHERE id = ? AND user_id = ? LIMIT 1 ', [newText, noteId, userId]) - .then((rows, fields) => { - - //Only reindex if note was deleted from menu - if(reindex){ - const Note = require('@models/Note') - //Reindex Note after updating text - Note.reindex(userId, noteId) - } - - - return resolve(true) - }) - - - }) + return resolve(true) }) }) } diff --git a/server/models/Note.js b/server/models/Note.js index f33101f..e574b82 100644 --- a/server/models/Note.js +++ b/server/models/Note.js @@ -451,10 +451,9 @@ Note.search = (userId, searchQuery, searchTags, fastFilters) => { JOIN note_raw_text ON (note_raw_text.id = note.note_raw_text_id) LEFT JOIN note_tag ON (note.id = note_tag.note_id) LEFT JOIN tag ON (tag.id = note_tag.tag_id) - LEFT JOIN attachment ON (note.id = attachment.note_id) + LEFT JOIN attachment ON (note.id = attachment.note_id AND attachment.visible = 1) LEFT JOIN user as shareUser ON (note.share_user_id = shareUser.id) WHERE note.user_id = ? - AND attachment.visible = 1 ` //Show shared notes