* 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

+99 -11
View File
@@ -40,11 +40,10 @@ var io = require('socket.io')(http, {
//Set socket IO as a global in the app
global.SocketIo = io
let noteDiffs = {}
io.on('connection', function(socket){
// console.log('New user ', socket.id)
//When a user connects, add them to their own room
// This allows the server to emit events to that specific user
// access socket.io in the controller with SocketIo global
@@ -58,14 +57,43 @@ io.on('connection', function(socket){
})
})
socket.on('join_room', roomId => {
// console.log('Join room ', roomId)
socket.join(roomId)
socket.on('join_room', rawTextId => {
// Join user to rawtextid room when they enter
socket.join(rawTextId)
const usersInRoom = io.sockets.adapter.rooms[roomId]
//If there are past diffs for this note, send them to the user
if(noteDiffs[rawTextId] != undefined){
//Sort all note diffs by when they were created.
noteDiffs[rawTextId].sort((a,b) => { return a.time - b.time })
//Emit all sorted diffs to user
socket.emit('past_diffs', noteDiffs[rawTextId])
} else {
socket.emit('past_diffs', null)
}
const usersInRoom = io.sockets.adapter.rooms[rawTextId]
if(usersInRoom){
// console.log('Users in room', usersInRoom.length)
io.to(roomId).emit('update_user_count', usersInRoom.length)
//Update users in room count
io.to(rawTextId).emit('update_user_count', usersInRoom.length)
//Debugging text
console.log('Note diff object')
console.log(noteDiffs)
let noteDiffKeys = Object.keys(noteDiffs)
let totalDiffs = 0
noteDiffKeys.forEach(diffSetKey => {
if(noteDiffs[diffSetKey]){
totalDiffs += noteDiffs[diffSetKey].length
}
})
console.log('Total notes in limbo -> ', noteDiffKeys.length)
console.log('Total Diffs for all notes -> ', totalDiffs)
}
})
@@ -83,13 +111,41 @@ io.on('connection', function(socket){
socket.on('note_diff', data => {
//Log each diff for note
const noteId = data.id
delete data.id
if(noteDiffs[noteId] == undefined){ noteDiffs[noteId] = [] }
data.time = +new Date
noteDiffs[noteId].push(data)
//Remove duplicate diffs if they exist
for (var i = noteDiffs[noteId].length - 1; i >= 0; i--) {
let pastDiff = noteDiffs[noteId][i]
for (var j = noteDiffs[noteId].length - 1; j >= 0; j--) {
let currentDiff = noteDiffs[noteId][j]
if(i == j){
continue
}
if(currentDiff.diff == pastDiff.diff || currentDiff.time == pastDiff.time){
console.log('Removing Duplicate')
noteDiffs[noteId].splice(i,1)
}
}
}
//Each user joins a room when they open the app.
io.in(data.id).clients((error, clients) => {
io.in(noteId).clients((error, clients) => {
if (error) throw error;
//Go through each client in note room and send them the diff
clients.forEach(socketId => {
if(socketId != socket.id){
io.to(socketId).emit('incoming_diff', data.diff)
io.to(socketId).emit('incoming_diff', data)
}
})
@@ -97,6 +153,38 @@ io.on('connection', function(socket){
})
socket.on('truncate_diffs_at_save', checkpoint => {
let diffSet = noteDiffs[checkpoint.rawTextId]
if(diffSet && diffSet.length > 0){
//Make sure all diffs are sorted before cleaning
noteDiffs[checkpoint.rawTextId].sort((a,b) => { return a.time - b.time })
// Remove all diffs until it reaches the current hash
let sliceTo = 0
for (var i = 0; i < diffSet.length; i++) {
if(diffSet[i].hash == checkpoint){
sliceTo = i
break
}
}
noteDiffs[checkpoint.rawTextId] = diffSet.slice(0, sliceTo)
if(noteDiffs[checkpoint.rawTextId].length == 0){
delete noteDiffs[checkpoint.rawTextId]
}
//Debugging
else {
console.log('Diffset after save')
console.log(noteDiffs[checkpoint.rawTextId])
}
}
})
socket.on('disconnect', function(){
// console.log('user disconnected');
});
@@ -139,7 +227,7 @@ app.use(function(req, res, next){
const printResults = false
let UserTest = require('@models/User')
let NoteTest = require('@models/Note')
UserTest.keyPairTest('genMan2', '1', printResults)
UserTest.keyPairTest('genMan12', '1', printResults)
.then( ({testUserId, masterKey}) => NoteTest.test(testUserId, masterKey, printResults))
.then( message => {
if(printResults) console.log(message)