diff --git a/client/src/components/NoteTitleDisplayCard.vue b/client/src/components/NoteTitleDisplayCard.vue index 15520cd..66eaebf 100644 --- a/client/src/components/NoteTitleDisplayCard.vue +++ b/client/src/components/NoteTitleDisplayCard.vue @@ -11,12 +11,23 @@
-
+
-
+
-
Shared by {{ note.shareUsername }}
-
You Shared
+ + Shared by {{ note.shareUsername }} + + Unread + + + + + You Shared + + Updated + + @@ -46,11 +57,11 @@ -
+
-
+
{{ tag }} @@ -89,6 +100,10 @@ 'delete-button': require('@/components/NoteDeleteButtonComponent.vue').default, }, methods:{ + cardClicked(){ + this.beenClicked = true + this.onClick(this.note.id) + }, cleanHighlight(text){ //Basically just remove whitespace let updated = text.replace(/ /g, '').replace(/
/g,'') @@ -116,6 +131,7 @@ fontColor: null, noteIcon: null, iconColor: null, + beenClicked: false, } }, computed: { diff --git a/server/models/Note.js b/server/models/Note.js index e149511..4fd6497 100644 --- a/server/models/Note.js +++ b/server/models/Note.js @@ -106,14 +106,14 @@ Note.create = (userId, noteText, quickNote = 0) => { const created = Math.round((+new Date)/1000) db.promise() - .query(`INSERT INTO note_raw_text (text) VALUE (?)`, [noteText]) + .query(`INSERT INTO note_raw_text (text, updated) VALUE (?, ?)`, [noteText, created]) .then( (rows, fields) => { const rawTextId = rows[0].insertId return db.promise() - .query('INSERT INTO note (user_id, note_raw_text_id, updated, created, quick_note) VALUES (?,?,?,?,?)', - [userId, rawTextId, created, created, quickNote]) + .query('INSERT INTO note (user_id, note_raw_text_id, created, quick_note) VALUES (?,?,?,?)', + [userId, rawTextId, created, quickNote]) }) .then((rows, fields) => { // Indexing is done on save @@ -177,14 +177,14 @@ Note.update = (io, userId, noteId, noteText, color, pinned, archived) => { //Update Note text return db.promise() - .query('UPDATE note_raw_text SET text = ? WHERE id = ?', [noteText, textId]) + .query('UPDATE note_raw_text SET text = ?, updated = ? WHERE id = ?', [noteText, now, textId]) }) .then( (rows, fields) => { //Update other note attributes return db.promise() - .query('UPDATE note SET pinned = ?, archived = ?, updated = ?, color = ? WHERE id = ? AND user_id = ? LIMIT 1', - [pinned, archived, now, color, noteId, userId]) + .query('UPDATE note SET pinned = ?, archived = ?, color = ? WHERE id = ? AND user_id = ? LIMIT 1', + [pinned, archived, color, noteId, userId]) }) .then((rows, fields) => { @@ -330,16 +330,17 @@ Note.get = (userId, noteId) => { .query(` SELECT note_raw_text.text, - note.updated, + note_raw_text.updated as updated, note.pinned, note.archived, note.color, count(distinct attachment.id) as attachment_count, - note.note_raw_text_id as rawTextId + note.note_raw_text_id as rawTextId, + shareUser.username as shareUsername FROM note JOIN note_raw_text ON (note_raw_text.id = note.note_raw_text_id) LEFT JOIN attachment ON (note.id = attachment.note_id) - LEFT JOIN user ON (note.share_user_id = user.id) + LEFT JOIN user as shareUser ON (note.share_user_id = shareUser.id) WHERE note.user_id = ? AND note.id = ? LIMIT 1`, [userId,noteId]) .then((rows, fields) => { @@ -359,7 +360,7 @@ Note.get = (userId, noteId) => { Note.getShared = (noteId) => { return new Promise((resolve, reject) => { db.promise() - .query('SELECT text, updated, color FROM note WHERE id = ? AND shared = 1 LIMIT 1', [noteId]) + .query('SELECT text, color FROM note WHERE id = ? AND shared = 1 LIMIT 1', [noteId]) .then((rows, fields) => { //Return note data @@ -452,7 +453,8 @@ Note.search = (userId, searchQuery, searchTags, fastFilters) => { let noteSearchQuery = ` SELECT note.id, SUBSTRING(note_raw_text.text, 1, 1500) as text, - updated, + note_raw_text.updated as updated, + opened, color, count(distinct note_tag.id) as tag_count, count(distinct attachment.id) as attachment_count, @@ -532,15 +534,15 @@ Note.search = (userId, searchQuery, searchTags, fastFilters) => { // Always prioritize pinned notes in searches. //Default Sort, order by last updated - let defaultOrderBy = ' ORDER BY note.pinned DESC, note.updated DESC, note.created DESC, note.opened DESC, id DESC' + let defaultOrderBy = ' ORDER BY note.pinned DESC, updated DESC, note.created DESC, note.opened DESC, id DESC' //Order by Last Created Date if(fastFilters.lastCreated == 1){ - defaultOrderBy = ' ORDER BY note.pinned DESC, note.created DESC, note.updated DESC, note.opened DESC, id DESC' + defaultOrderBy = ' ORDER BY note.pinned DESC, note.created DESC, updated DESC, note.opened DESC, id DESC' } //Order by last Opened Date if(fastFilters.lastOpened == 1){ - defaultOrderBy = ' ORDER BY note.pinned DESC, opened DESC, note.updated DESC, note.created DESC, id DESC' + defaultOrderBy = ' ORDER BY note.pinned DESC, opened DESC, updated DESC, note.created DESC, id DESC' } //Append Order by to query diff --git a/server/models/Tag.js b/server/models/Tag.js index 188ae99..5bb88d9 100644 --- a/server/models/Tag.js +++ b/server/models/Tag.js @@ -211,12 +211,13 @@ Tag.latest = (userId, noteId) => { .query(`SELECT tag.text FROM note_tag JOIN tag ON note_tag.tag_id = tag.id JOIN note ON note_tag.note_id = note.id + JOIN note_raw_text ON (note_raw_text.id = note.note_raw_text_id) WHERE note_tag.user_id = ? AND note_tag.tag_id NOT IN ( SELECT note_tag.tag_id FROM note_tag WHERE note_tag.note_id = ? ) - GROUP BY tag.text, note.updated - ORDER BY note.updated DESC + GROUP BY tag.text, note_raw_text.updated + ORDER BY note_raw_text.updated DESC LIMIT 8;`, [userId, noteId]) .then((rows, fields) => { resolve(rows[0]) //Return found tags diff --git a/server/models/User.js b/server/models/User.js index 3584cd0..f9dd030 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -126,8 +126,9 @@ User.getCounts = (userId) => { SUM(archived = 1 && share_user_id IS NULL) AS archivedNotes, SUM(share_user_id IS NULL) AS totalNotes, SUM(share_user_id != ?) AS sharedToNotes, - SUM( (share_user_id != ? && opened IS null) || (share_user_id != ? && updated > opened) ) AS unreadNotes + SUM( (share_user_id != ? && opened IS null) || (share_user_id != ? && note_raw_text.updated > opened) ) AS unreadNotes FROM note + JOIN note_raw_text ON (note_raw_text.id = note.note_raw_text_id) WHERE user_id = ?`, [userId, userId, userId, userId]) .then( (rows, fields) => {