* Adjusted theme colors to add more contrast on white theme while making black more OLED friendly

* Links now get an underline on hover
* Cleaned up CSS variable names, added another theme color for more control
* Cleaned up unused CSS, removed scrollbars popping up, tons of other little UI tweaks
* Renamed shared notes to inbox
* Tweaked form display, seperated login and create accouts
* Put login/sign up form on home page
* Created more legitimate marketing for home page
* Tons up updates to note page and note input panel
* Better support for two users editing a note
* MUCH better diff handling, web sockets restore notes with unsaved diffs
* Moved all squire text modifier functions into a mixin class
* It now says saving when closing a note
* Lots of cleanup and better handiling of events on mount and destroy
* Scroll behavior modified to load notes when closer to bottom of page
* Pretty decent shared notes and sharable link support
* Updated help text
* Search now includes tag suggestions and attachment suggestions
* Cleaned up scratch pad a ton, allow for users to create new scratch pads
* Created a 404 Page and a Shared note page
* So many other small improvements. Oh my god, what is wrong with me, not doing commits!?
This commit is contained in:
Max G committed 2020-06-07 20:57:35 +00:00
1 parent 8e5e06be9b
commit 6bb856689d
31 files changed
+1605 -1095

No files matched your search

+46 -84
View File
@@ -72,7 +72,7 @@ Note.test = (userId, masterKey, printResults) => {
if(printResults) console.log('Test: Normal Note Search Index - Pass')
} else { console.log('Test: Search Index - Fail') }
return ShareNote.migrateNoteToShared(userId, testNoteId, shareUserId, masterKey)
return ShareNote.addUserToSharedNote(userId, testNoteId, shareUserId, masterKey)
})
.then(({success, shareUserId, sharedUserNoteId}) => {
@@ -134,13 +134,13 @@ Note.test = (userId, masterKey, printResults) => {
if(printResults) console.log('Test: Delete Shared Note - Pass')
return ShareNote.migrateNoteToShared(userId, testNoteId2, shareUserId, masterKey)
return ShareNote.addUserToSharedNote(userId, testNoteId2, shareUserId, masterKey)
})
.then(({success, shareUserId, sharedUserNoteId}) => {
if(printResults) console.log('Test: Created Another New Shared Note - pass')
return ShareNote.removeUserFromShared(userId, testNoteId2, sharedUserNoteId, masterKey)
return ShareNote.removeUserFromSharedNote(userId, testNoteId2, sharedUserNoteId, masterKey)
})
.then(() => {
@@ -162,75 +162,6 @@ Note.test = (userId, masterKey, printResults) => {
return resolve('Test: Complete ---')
})
})
}
//User doesn't have an encrypted note set. Encrypt all notes
Note.encryptEveryNote = (userId, masterKey) => {
return new Promise((resolve, reject) => {
//Select all the user notes
db.promise().query(`
SELECT * FROM note
JOIN note_raw_text ON (note_raw_text.id = note.note_raw_text_id)
WHERE salt IS NULL AND user_id = ? AND shared = 0`, [userId])
.then((rows, fields) => {
let foundNotes = rows[0]
console.log('Encrypting user notes ',rows[0].length)
// return resolve(true)
let allTheUpdates = []
let timeoutAdder = 0
foundNotes.forEach(note => {
timeoutAdder += 100
const newUpdate = new Promise((resolve, reject) => {
setTimeout(() => {
console.log('Encrypting Note ', note.id)
const created = Math.round((+new Date)/1000)
const salt = cs.createSmallSalt()
const noteText = note.text
const noteTitle = note.title
const snippet = JSON.stringify([noteTitle, noteText.substring(0, 500)])
const noteSnippet = cs.encrypt(masterKey, salt, snippet)
const textObject = JSON.stringify([noteTitle, noteText])
const encryptedText = cs.encrypt(masterKey, salt, textObject)
db.promise()
.query('UPDATE note_raw_text SET title = ?, text = ?, snippet = ?, salt = ? WHERE id = ?',
[null, encryptedText, noteSnippet, salt, note.note_raw_text_id])
.then(() => {
resolve(true)
})
}, timeoutAdder)
})
allTheUpdates.push(newUpdate)
})
Promise.all(allTheUpdates).then(done => {
console.log('Indexing first 100')
return Note.reindex(userId, masterKey)
}).then(results => {
console.log('Done')
resolve(true)
})
})
})
}
@@ -490,7 +421,8 @@ Note.reindex = (userId, masterKey, removeId = null) => {
Note.update = (userId, noteId, noteText, noteTitle, color, pinned, archived, hash, masterKey) => {
return new Promise((resolve, reject) => {
const now = Math.round((+new Date)/1000)
// const now = Math.round((+new Date)/1000)
const now = +new Date
let noteSnippet = ''
@@ -691,10 +623,6 @@ Note.delete = (userId, noteId, masterKey = null) => {
// delete tags
return db.promise()
.query('DELETE FROM note_tag WHERE note_tag.note_id = ? AND note_tag.user_id = ?', [noteId,userId])
})
.then((rows, fields) => {
})
.then((rows, fields) => {
@@ -706,6 +634,8 @@ Note.delete = (userId, noteId, masterKey = null) => {
}
})
SocketIo.to(userId).emit('update_counts')
if(masterKey){
//Remove note ID from index
Note.reindex(userId, masterKey, [noteId])
@@ -803,6 +733,7 @@ Note.get = (userId, noteId, masterKey) => {
note.archived,
note.trashed,
note.color,
note.shared,
note.encrypted_share_password_key,
count(distinct attachment.id) as attachment_count,
note.note_raw_text_id as rawTextId,
@@ -845,8 +776,8 @@ Note.get = (userId, noteId, masterKey) => {
db.promise().query(`UPDATE note SET opened = ? WHERE (id = ?)`, [nowTime, noteId])
//Return note data
delete noteData.salt //remove salt from return data
delete noteData.encrypted_share_password_key
// delete noteData.salt //remove salt from return data
// delete noteData.encrypted_share_password_key
noteData.lockedOut = noteLockedOut
resolve(noteData)
@@ -859,17 +790,48 @@ Note.get = (userId, noteId, masterKey) => {
}
//Public note share action -> may not be used
Note.getShared = (noteId) => {
Note.getShared = (noteId, sharedKey) => {
return new Promise((resolve, reject) => {
db.promise()
.query('SELECT text, color FROM note WHERE id = ? AND shared = 1 LIMIT 1', [noteId])
.query(`
SELECT
note_raw_text.text,
note_raw_text.salt,
note_raw_text.updated as updated,
note.id,
note.user_id,
note.created,
note.pinned,
note.archived,
note.trashed,
note.color,
note.shared,
note.encrypted_share_password_key,
note.note_raw_text_id as rawTextId
FROM note
JOIN note_raw_text ON (note_raw_text.id = note.note_raw_text_id)
WHERE note.id = ? LIMIT 1`, [noteId])
.then((rows, fields) => {
//Return note data
resolve(rows[0][0])
let noteData = rows[0][0]
const decipheredText = cs.decrypt(sharedKey, noteData.salt, noteData.text)
if(decipheredText == null){
throw new Error('Unable to decropt note text')
}
const success = true
const noteObject = JSON.parse(decipheredText)
const title = noteObject[0]
const text = noteObject[1]
const styleObject = JSON.parse(noteData.color)
return resolve({success, title, text, styleObject})
})
.catch(console.log)
.catch(error => {
resolve({'success':false})
})
})
}