Shared notes now share updated times
* Updating a shared note, updates the information for other shared users * Unread shared notes now have a badge * Updated shared notes now have a badge * Shared notes can not be reshared, sharer username appears in interface to stop sharing fixes #15
This commit is contained in:
parent
596703a963
commit
f0b6d7b85e
@ -11,12 +11,23 @@
|
||||
<div class="ui grid max-height">
|
||||
|
||||
<!-- Show title and snippet below it -->
|
||||
<div class="top aligned row" @click.self="onClick(note.id)">
|
||||
<div class="top aligned row" @click.self="cardClicked">
|
||||
|
||||
<div class="sixteen wide column overflow-hidden note-card-text" @click="e => onClick(note.id, e)">
|
||||
<div class="sixteen wide column overflow-hidden note-card-text" @click="cardClicked">
|
||||
|
||||
<div class="subtext" v-if="note.shareUsername">Shared by {{ note.shareUsername }}</div>
|
||||
<div class="subtext" v-if="note.shared == 2">You Shared</div>
|
||||
<span class="subtext" v-if="note.shareUsername">
|
||||
Shared by {{ note.shareUsername }}
|
||||
<span v-if="note.updated > note.opened && !beenClicked" class="ui tiny green compact right floated button">
|
||||
Unread
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span class="subtext" v-if="note.shared == 2">
|
||||
You Shared
|
||||
<span v-if="note.updated > note.opened && !beenClicked" class="ui tiny green compact right floated button">
|
||||
Updated
|
||||
</span>
|
||||
</span>
|
||||
|
||||
|
||||
<!-- Title display -->
|
||||
@ -46,11 +57,11 @@
|
||||
|
||||
|
||||
<!-- Toolbar on the bottom -->
|
||||
<div class="bottom aligned row" @click.self="onClick(note.id)">
|
||||
<div class="bottom aligned row" @click.self="cardClicked">
|
||||
<div class="sixteen wide column">
|
||||
<div class="ui grid reduced-padding">
|
||||
|
||||
<div class="thirteen wide column clickable icon-bar" @click="onClick(note.id)">
|
||||
<div class="thirteen wide column clickable icon-bar" @click="cardClicked">
|
||||
<!-- {{$helpers.timeAgo(note.updated)}} -->
|
||||
<span v-if="note.tags">
|
||||
<span v-for="tag in (note.tags.split(','))" class="little-tag">{{ tag }}</span>
|
||||
@ -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(/<br>/g,'')
|
||||
@ -116,6 +131,7 @@
|
||||
fontColor: null,
|
||||
noteIcon: null,
|
||||
iconColor: null,
|
||||
beenClicked: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) => {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user