* Removed arrows from notification
* Added trash can function * Tweaked status text to always be the same * Removed some open second note code * Edior always focuses on text now * Added some extra loading note messages * Notes are now removed from search index when deleted * Lots more things happen and update in real time on multiple machines * Shared notes can be reverted * WAY more tests * Note Categories are much more reliable * Lots of code is much cleaner
This commit is contained in:
		@@ -70,9 +70,7 @@
 | 
			
		||||
<template>
 | 
			
		||||
	<div class="popup-body slide-in-bottom" v-on:click="dismiss" v-if="notifications.length > 0">
 | 
			
		||||
		<div class="popup-row color-fade" v-for="item in notifications">
 | 
			
		||||
			<i class="disabled angle left icon"></i>
 | 
			
		||||
			<span>{{ item }}</span>
 | 
			
		||||
			<i class="disabled angle right icon"></i>
 | 
			
		||||
		</div>
 | 
			
		||||
	</div>
 | 
			
		||||
</template>
 | 
			
		||||
 
 | 
			
		||||
@@ -257,7 +257,7 @@
 | 
			
		||||
		},
 | 
			
		||||
		data: function(){ 
 | 
			
		||||
			return {
 | 
			
		||||
				version: '2.1.2',
 | 
			
		||||
				version: '2.2.2',
 | 
			
		||||
				username: '',
 | 
			
		||||
				collapsed: false,
 | 
			
		||||
				mobile: false,
 | 
			
		||||
@@ -329,7 +329,7 @@
 | 
			
		||||
				.then(response => {
 | 
			
		||||
 | 
			
		||||
					if(response.data && response.data.id){
 | 
			
		||||
						// this.$router.push('/notes/open/'+response.data.id)
 | 
			
		||||
						//Redirect to note page if user is not on it
 | 
			
		||||
						this.$bus.$emit('open_note', response.data.id)
 | 
			
		||||
						this.disableNewNote = false
 | 
			
		||||
					}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
<template>
 | 
			
		||||
	<span>
 | 
			
		||||
		<span class="clickable" @click="confirmDelete()" v-if="click == 0" data-tooltip="Delete" data-inverted="" data-position="top right">
 | 
			
		||||
		<span class="clickable" @click="confirmDelete()" v-if="click == 0" data-tooltip="Delete Forever" data-inverted="" data-position="top right">
 | 
			
		||||
			<i class="trash alternate icon"></i>
 | 
			
		||||
		</span>
 | 
			
		||||
		<span class="clickable" @click="actuallyDelete()" @mouseleave="reset" v-if="click == 1" data-tooltip="Click again to delete." data-position="top right" data-inverted="">
 | 
			
		||||
 
 | 
			
		||||
@@ -265,7 +265,7 @@
 | 
			
		||||
				updated: '',
 | 
			
		||||
				shareUsername: null,
 | 
			
		||||
				diffNoteText: '',
 | 
			
		||||
				statusText: 'Saved',
 | 
			
		||||
				statusText: 'Saved.',
 | 
			
		||||
				lastNoteHash: null,
 | 
			
		||||
				saveDebounce: null, //Prevent save from being called numerous times quickly
 | 
			
		||||
				updated: 'Never',
 | 
			
		||||
@@ -306,16 +306,16 @@
 | 
			
		||||
		watch: {
 | 
			
		||||
			noteid:function(newVal, oldVal){
 | 
			
		||||
 | 
			
		||||
				if(newVal == this.currentNoteId){
 | 
			
		||||
					return
 | 
			
		||||
				}
 | 
			
		||||
				// if(newVal == this.currentNoteId){
 | 
			
		||||
				// 	return
 | 
			
		||||
				// }
 | 
			
		||||
 | 
			
		||||
				if(newVal == oldVal){
 | 
			
		||||
					return
 | 
			
		||||
				}
 | 
			
		||||
				// if(newVal == oldVal){
 | 
			
		||||
				// 	return
 | 
			
		||||
				// }
 | 
			
		||||
				
 | 
			
		||||
				this.currentNoteId = newVal
 | 
			
		||||
				this.loadNote(this.currentNoteId)
 | 
			
		||||
				// this.currentNoteId = newVal
 | 
			
		||||
				// this.loadNote(this.currentNoteId)
 | 
			
		||||
				
 | 
			
		||||
			},
 | 
			
		||||
			urlData(newVal, oldVal){
 | 
			
		||||
@@ -388,17 +388,10 @@
 | 
			
		||||
				this.lastNoteHash = this.hashString(this.getText())
 | 
			
		||||
				// console.log('hash on load', this.lastNoteHash)
 | 
			
		||||
 | 
			
		||||
				//focus on open, not on mobile, thats annoying
 | 
			
		||||
				//focus on open, not on mobile, it causes the keyboard to pop up, thats annoying
 | 
			
		||||
				if(!this.$store.getters.getIsUserOnMobile){
 | 
			
		||||
					// this.editor.focus()
 | 
			
		||||
 | 
			
		||||
					if(this.noteTitle.length == 0){
 | 
			
		||||
						this.$refs.titleTextarea.focus()
 | 
			
		||||
					} else {
 | 
			
		||||
						this.editor.focus()
 | 
			
		||||
						this.editor.moveCursorToEnd()
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					this.editor.focus()
 | 
			
		||||
					this.editor.moveCursorToEnd()
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				//Change button states on editor when element is active
 | 
			
		||||
@@ -812,11 +805,14 @@
 | 
			
		||||
			loadNote(noteId){
 | 
			
		||||
 | 
			
		||||
				//Generate a random loading message
 | 
			
		||||
				let mod = ['Gently','Calmly','Lovingly','Quickly','','','','','','','','','','','','','']
 | 
			
		||||
				let doing = ['Loading','Loading','Getting','Fetching','Grabbing','Sequencing','Organizing','Untangling','Processing','Refining','Extracting','Fusing','Pruning','Expanding','Enlarging','Transfiguring','Quantizing','Ingratiating','Lumping']
 | 
			
		||||
				let thing = ['Note','Note','Note','Note','Data','Text','Document','Algorithm','Buffer','Client','Download','File','Frame','Graphics','Hardware','HTML','Interface','Logic','Mainframe','Memory','Media','Nodes','Network','Chaos']
 | 
			
		||||
				let p1 = doing[Math.floor(Math.random() * doing.length)]
 | 
			
		||||
				let p2 = thing[Math.floor(Math.random() * thing.length)]
 | 
			
		||||
				this.loadingMessage = p1 + ' ' + p2
 | 
			
		||||
 | 
			
		||||
				let p1 = mod[Math.floor(Math.random() * mod.length)]
 | 
			
		||||
				let p2 = doing[Math.floor(Math.random() * doing.length)]
 | 
			
		||||
				let p3 = thing[Math.floor(Math.random() * thing.length)]
 | 
			
		||||
				this.loadingMessage = `${p1} ${p2} ${p3}`
 | 
			
		||||
				
 | 
			
		||||
				//Component is activated with NoteId in place, lookup text with associated ID
 | 
			
		||||
				if(this.$store.getters.getLoggedIn){
 | 
			
		||||
@@ -1039,7 +1035,7 @@
 | 
			
		||||
			},
 | 
			
		||||
			onKeyup(){
 | 
			
		||||
 | 
			
		||||
				this.statusText = ''
 | 
			
		||||
				this.statusText = 'Modded'
 | 
			
		||||
 | 
			
		||||
				// this.diffText()
 | 
			
		||||
 | 
			
		||||
@@ -1067,7 +1063,7 @@
 | 
			
		||||
					const currentNoteText = this.getText()
 | 
			
		||||
					const currentHash = this.hashString( currentNoteText )
 | 
			
		||||
					if( this.lastNoteHash == currentHash){
 | 
			
		||||
						this.statusText = 'Saved'
 | 
			
		||||
						this.statusText = 'Saved.'
 | 
			
		||||
						return resolve(true)
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
@@ -1090,7 +1086,7 @@
 | 
			
		||||
 | 
			
		||||
					this.statusText = 'Saving'
 | 
			
		||||
					axios.post('/api/note/update', postData).then( response => {
 | 
			
		||||
						this.statusText = 'Saved'
 | 
			
		||||
						this.statusText = 'Saved.'
 | 
			
		||||
						this.updated = Math.round((+new Date)/1000)
 | 
			
		||||
						this.modified = true
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -29,12 +29,10 @@
 | 
			
		||||
 | 
			
		||||
				<!-- Title display  -->
 | 
			
		||||
				<span v-if="note.title.length > 0" 
 | 
			
		||||
					data-test-id="title"
 | 
			
		||||
					class="big-text"><p>{{ note.title }}</p></span>
 | 
			
		||||
 | 
			
		||||
				<!-- Sub text display -->
 | 
			
		||||
				<span v-if="note.subtext.length > 0 && !isShowingSearchResults()"
 | 
			
		||||
					data-test-id="subtext"
 | 
			
		||||
					class="small-text"
 | 
			
		||||
					v-html="note.subtext"></span>
 | 
			
		||||
 | 
			
		||||
@@ -71,13 +69,6 @@
 | 
			
		||||
			<!-- Toolbar on the bottom  -->
 | 
			
		||||
			<div class="tool-bar" @click.self="cardClicked" v-if="!titleView">
 | 
			
		||||
				<div class="icon-bar">
 | 
			
		||||
 | 
			
		||||
					<!-- <span v-if="note.pinned == 1" data-position="top left" data-tooltip="Pinned" data-inverted>
 | 
			
		||||
						<i class="green pin icon"></i>
 | 
			
		||||
					</span>
 | 
			
		||||
					<span v-if="note.archived == 1" data-position="top left" data-tooltip="Archived" data-inverted>
 | 
			
		||||
						<i class="green archive icon"></i>
 | 
			
		||||
					</span> -->
 | 
			
		||||
					
 | 
			
		||||
					<span class="tags" v-if="note.tags">
 | 
			
		||||
						<span  v-for="tag in (note.tags.split(','))" class="little-tag">{{ tag }}</span>
 | 
			
		||||
@@ -90,24 +81,43 @@
 | 
			
		||||
 | 
			
		||||
					<span class="teeny-buttons" :class="{ 'hover-hide':(!$store.getters.getIsUserOnMobile) }">
 | 
			
		||||
 | 
			
		||||
						<i class="teeny-button" data-tooltip="Tags" data-inverted v-on:click="toggleTags(true)">
 | 
			
		||||
							<i class="tags icon"></i>
 | 
			
		||||
						</i>
 | 
			
		||||
						<span v-if="!note.trashed">
 | 
			
		||||
 | 
			
		||||
						<i class="teeny-button"
 | 
			
		||||
							data-tooltip="Archive"
 | 
			
		||||
							:data-tooltip="note.archived ? 'Un-Archive':'Archive' " 
 | 
			
		||||
							data-inverted v-on:click="archiveNote">
 | 
			
		||||
							<i class="archive icon" :class="{'green':note.archived}"></i>
 | 
			
		||||
						</i>
 | 
			
		||||
							<i class="teeny-button" data-tooltip="Tags" data-inverted v-on:click="toggleTags(true)">
 | 
			
		||||
								<i class="tags icon"></i>
 | 
			
		||||
							</i>
 | 
			
		||||
 | 
			
		||||
						<i class="teeny-button" 
 | 
			
		||||
							:data-tooltip="note.pinned ? 'Un-Pin':'Pin' " 
 | 
			
		||||
							data-inverted v-on:click="pinNote">
 | 
			
		||||
							<i class="pin icon" :class="{'green':note.pinned}"></i>
 | 
			
		||||
						</i>
 | 
			
		||||
							<i class="teeny-button"
 | 
			
		||||
								data-tooltip="Archive"
 | 
			
		||||
								:data-tooltip="note.archived ? 'Un-Archive':'Archive' " 
 | 
			
		||||
								data-inverted v-on:click="archiveNote">
 | 
			
		||||
								<i class="archive icon" :class="{'green':note.archived}"></i>
 | 
			
		||||
							</i>
 | 
			
		||||
 | 
			
		||||
						<delete-button class="teeny-button" :note-id="note.id" />
 | 
			
		||||
							<i class="teeny-button" 
 | 
			
		||||
								:data-tooltip="note.pinned ? 'Un-Pin':'Pin' " 
 | 
			
		||||
								data-inverted v-on:click="pinNote">
 | 
			
		||||
								<i class="pin icon" :class="{'green':note.pinned}"></i>
 | 
			
		||||
							</i>
 | 
			
		||||
 | 
			
		||||
							<i class="teeny-button"
 | 
			
		||||
								data-tooltip="Move to Trash" 
 | 
			
		||||
								data-inverted v-on:click="trashNote()">
 | 
			
		||||
								<i class="trash icon"></i>
 | 
			
		||||
							</i>
 | 
			
		||||
						</span>
 | 
			
		||||
 | 
			
		||||
						<!-- Trash note options -->
 | 
			
		||||
						<span v-if="note.trashed">
 | 
			
		||||
							<i class="teeny-button" 
 | 
			
		||||
								data-tooltip="Un-Trash" 
 | 
			
		||||
								data-inverted v-on:click="trashNote()">
 | 
			
		||||
								<i class="reply icon"></i>
 | 
			
		||||
							</i>
 | 
			
		||||
							<delete-button class="teeny-button" :note-id="note.id" />
 | 
			
		||||
						</span>
 | 
			
		||||
 | 
			
		||||
						
 | 
			
		||||
 | 
			
		||||
					</span>
 | 
			
		||||
				</div>
 | 
			
		||||
@@ -185,7 +195,7 @@
 | 
			
		||||
				let postData = {'pinned': !this.note.pinned, 'noteId':this.note.id}
 | 
			
		||||
				axios.post('/api/note/setpinned', postData)
 | 
			
		||||
				.then(data => {
 | 
			
		||||
					this.$bus.$emit('update_single_note', this.note.id)
 | 
			
		||||
					// this.$bus.$emit('update_single_note', this.note.id)
 | 
			
		||||
				})
 | 
			
		||||
				.catch(error => { this.$bus.$emit('notification', 'Failed to Pin Note') })
 | 
			
		||||
			},
 | 
			
		||||
@@ -197,20 +207,35 @@
 | 
			
		||||
					//Show message so no one worries where note went
 | 
			
		||||
					let message = 'Moved to Archive'
 | 
			
		||||
					if(postData.archived != 1){
 | 
			
		||||
						message = 'Move to main list'
 | 
			
		||||
						message = 'Moved to main list'
 | 
			
		||||
					}
 | 
			
		||||
					this.$bus.$emit('notification', message)
 | 
			
		||||
 | 
			
		||||
					this.$bus.$emit('update_single_note', this.note.id)
 | 
			
		||||
					// this.$bus.$emit('update_single_note', this.note.id)
 | 
			
		||||
				})
 | 
			
		||||
				.catch(error => { this.$bus.$emit('notification', 'Failed to Archive Note') })
 | 
			
		||||
			},
 | 
			
		||||
			trashNote(){ //toggleArchived() <- old name
 | 
			
		||||
				let postData = {'trashed': !this.note.trashed, 'noteId':this.note.id}
 | 
			
		||||
				axios.post('/api/note/settrashed', postData)
 | 
			
		||||
				.then(data => {
 | 
			
		||||
 | 
			
		||||
					//Show message so no one worries where note went
 | 
			
		||||
					let message = 'Moved to Trash'
 | 
			
		||||
					if(postData.trashed == 0){
 | 
			
		||||
						message = 'Moved to main list'
 | 
			
		||||
					}
 | 
			
		||||
					this.$bus.$emit('notification', message)
 | 
			
		||||
 | 
			
		||||
				})
 | 
			
		||||
				.catch(error => { this.$bus.$emit('notification', 'Failed to Trash Note') })
 | 
			
		||||
			},
 | 
			
		||||
			toggleTags(state){
 | 
			
		||||
 | 
			
		||||
				this.showTagSlideMenu = state
 | 
			
		||||
 | 
			
		||||
				if(state == false){
 | 
			
		||||
					this.$bus.$emit('update_single_note', this.note.id)
 | 
			
		||||
					// this.$bus.$emit('update_single_note', this.note.id)
 | 
			
		||||
				}
 | 
			
		||||
				
 | 
			
		||||
			},
 | 
			
		||||
@@ -330,6 +355,10 @@
 | 
			
		||||
		color: var(--text_color);
 | 
			
		||||
		background-color: var(--background_color);
 | 
			
		||||
	}
 | 
			
		||||
	.subtext {
 | 
			
		||||
		display: inline-block;
 | 
			
		||||
		width: 100%;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/*Strict font sizes for card display*/
 | 
			
		||||
	.small-text {
 | 
			
		||||
 
 | 
			
		||||
@@ -80,8 +80,14 @@
 | 
			
		||||
				})
 | 
			
		||||
				.catch(error => { this.$bus.$emit('notification', 'Failed to Load Shared') })
 | 
			
		||||
			},
 | 
			
		||||
			onRevokeAccess(noteId){
 | 
			
		||||
				axios.post('/api/note/shareremoveuser', {'noteId':noteId})
 | 
			
		||||
			onRevokeAccess(sharedNoteId){
 | 
			
		||||
 | 
			
		||||
				const postData = {
 | 
			
		||||
					'noteId': this.noteId,
 | 
			
		||||
					'shareUserNoteId': sharedNoteId
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				axios.post('/api/note/shareremoveuser', postData)
 | 
			
		||||
				.then( ({data}) => {
 | 
			
		||||
					console.log(data)
 | 
			
		||||
					if(data == true){
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,9 @@
 | 
			
		||||
					<div class="two wide middle aligned center aligned column" v-on:click="menuOpen = false">
 | 
			
		||||
						<i class="grey close icon"></i>
 | 
			
		||||
					</div>
 | 
			
		||||
					<div class="sixteen wide middle aligned column" v-if="loadedTags.length == 0">
 | 
			
		||||
						Tags added to Notes will appear here.
 | 
			
		||||
					</div>
 | 
			
		||||
					<div class="row hover-row" v-for="tag in loadedTags" v-on:click="onClick(tag.id)" :class="{'green':(activeTags[0] == tag.id)}">
 | 
			
		||||
						<div class="two wide center aligned column">
 | 
			
		||||
							<i class="grey tag icon"></i>
 | 
			
		||||
 
 | 
			
		||||
@@ -82,10 +82,13 @@
 | 
			
		||||
						const username = response.data.username
 | 
			
		||||
						const masterKey = response.data.masterKey
 | 
			
		||||
 | 
			
		||||
						vm.$store.commit('setLoginToken', {token, username, masterKey})
 | 
			
		||||
						this.$store.commit('setLoginToken', {token, username, masterKey})
 | 
			
		||||
 | 
			
		||||
						//Setup socket io after user logs in
 | 
			
		||||
						this.$io.emit('user_connect', token)
 | 
			
		||||
 | 
			
		||||
						//Redirect user to notes section after login
 | 
			
		||||
						vm.$router.push('/notes')
 | 
			
		||||
						this.$router.push('/notes')
 | 
			
		||||
					} else {
 | 
			
		||||
						// this.password = ''
 | 
			
		||||
						this.$bus.$emit('notification', 'Incorrect Username or Password')
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,10 @@
 | 
			
		||||
							<!-- <span>{{ $store.getters.totals['archivedNotes'] }}</span> -->
 | 
			
		||||
						</div>
 | 
			
		||||
 | 
			
		||||
						<div class="ui basic icon button shrinking" v-on:click="updateFastFilters(4)" v-if="$store.getters.totals && $store.getters.totals['trashedNotes'] > 0">
 | 
			
		||||
							<i class="trash alternate outline icon"></i>
 | 
			
		||||
						</div>
 | 
			
		||||
 | 
			
		||||
						<tag-display 
 | 
			
		||||
							:active-tags="searchTags"
 | 
			
		||||
							v-on:tagClick="tagId => toggleTagFilter(tagId)"
 | 
			
		||||
@@ -66,11 +70,23 @@
 | 
			
		||||
				</h2>
 | 
			
		||||
			</div>
 | 
			
		||||
 | 
			
		||||
			<h2 v-if="fastFilters['withLinks'] == 1">Notes with Links</h2>
 | 
			
		||||
			<h2 v-if="fastFilters['withTags'] == 1">Notes with Tags</h2>
 | 
			
		||||
			<h2 v-if="fastFilters['onlyArchived'] == 1">Archived Notes</h2>
 | 
			
		||||
			<h2 v-if="fastFilters['onlyShowSharedNotes'] == 1">Shared Notes</h2>
 | 
			
		||||
			<h2 v-if="fastFilters['onlyShowEncrypted'] == 1">Password Protected - No longer supported</h2>
 | 
			
		||||
			<div v-if="fastFilters['onlyArchived'] == 1" class="sixteen wide column">
 | 
			
		||||
				<h2>Archived Notes</h2>
 | 
			
		||||
			</div>
 | 
			
		||||
 | 
			
		||||
			<div class="sixteen wide column" v-if="fastFilters['onlyShowTrashed'] == 1">
 | 
			
		||||
				<h2 >Trash
 | 
			
		||||
					<span>({{ $store.getters.totals['trashedNotes'] }})</span>
 | 
			
		||||
					<div class="ui right floated basic button" data-tooltip="This doesn't work yet">
 | 
			
		||||
						<i class="poo storm icon"></i>
 | 
			
		||||
						Empty Trash
 | 
			
		||||
					</div>
 | 
			
		||||
				</h2>
 | 
			
		||||
			</div>
 | 
			
		||||
			
 | 
			
		||||
			<div class="sixteen wide column" v-if="fastFilters['onlyShowSharedNotes'] == 1">
 | 
			
		||||
				<h2>Shared Notes</h2>
 | 
			
		||||
			</div>
 | 
			
		||||
 | 
			
		||||
			<!-- Note title card display  -->
 | 
			
		||||
			<div class="sixteen wide column">
 | 
			
		||||
@@ -124,15 +140,11 @@
 | 
			
		||||
		
 | 
			
		||||
		<input-notes 
 | 
			
		||||
			v-if="activeNoteId1 != null" 
 | 
			
		||||
			:key="'active_note_'+activeNoteId1"
 | 
			
		||||
			:noteid="activeNoteId1" 
 | 
			
		||||
			:position="activeNote1Position"
 | 
			
		||||
			:url-data="$route.params"
 | 
			
		||||
			ref="note1" />
 | 
			
		||||
		<input-notes 
 | 
			
		||||
			v-if="activeNoteId2 != null" 
 | 
			
		||||
			:noteid="activeNoteId2" 
 | 
			
		||||
			:position="activeNote2Position" 
 | 
			
		||||
			ref="note2" />
 | 
			
		||||
 | 
			
		||||
	</div>
 | 
			
		||||
</template>
 | 
			
		||||
@@ -148,7 +160,7 @@
 | 
			
		||||
			'input-notes': () => import(/* webpackChunkName: "NoteInputPanel" */ '@/components/NoteInputPanel.vue'),
 | 
			
		||||
 | 
			
		||||
			'note-title-display-card': require('@/components/NoteTitleDisplayCard.vue').default,
 | 
			
		||||
			'fast-filters': require('@/components/FastFilters.vue').default,
 | 
			
		||||
			// 'fast-filters': require('@/components/FastFilters.vue').default,
 | 
			
		||||
			'search-input': require('@/components/SearchInput.vue').default,
 | 
			
		||||
			'attachment-display': require('@/components/AttachmentDisplayCard').default,
 | 
			
		||||
			'counter':require('@/components/AnimatedCounterComponent.vue').default,
 | 
			
		||||
@@ -205,7 +217,8 @@
 | 
			
		||||
					'shared': 		['envelope outline', 'Received Notes'],
 | 
			
		||||
					'sent': 		['paper plane outline', 'Shared Notes'],
 | 
			
		||||
					'notes': 		['file','Notes'],
 | 
			
		||||
					'highlights': 	['paragraph', 'Found In Text']
 | 
			
		||||
					'highlights': 	['paragraph', 'Found In Text'],
 | 
			
		||||
					'trashed': 		['poop', 'Trashed Notes']
 | 
			
		||||
				},
 | 
			
		||||
				noteSections: {
 | 
			
		||||
					pinned: [],
 | 
			
		||||
@@ -213,7 +226,8 @@
 | 
			
		||||
					shared:[],
 | 
			
		||||
					sent:[],
 | 
			
		||||
					notes: [],
 | 
			
		||||
					highlights: []
 | 
			
		||||
					highlights: [],
 | 
			
		||||
					trashed: []
 | 
			
		||||
				},
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
@@ -223,35 +237,47 @@
 | 
			
		||||
			this.$parent.loginGateway()
 | 
			
		||||
 | 
			
		||||
			this.$io.on('new_note_created', noteId => {
 | 
			
		||||
 | 
			
		||||
				//Do not update note if its open
 | 
			
		||||
				if(this.activeNoteId1 != noteId){
 | 
			
		||||
					this.updateSingleNote(parseInt(noteId))
 | 
			
		||||
					this.$store.dispatch('fetchAndUpdateUserTotals')
 | 
			
		||||
					this.updateSingleNote(noteId)
 | 
			
		||||
				}
 | 
			
		||||
			})
 | 
			
		||||
 | 
			
		||||
			this.$io.on('note_attribute_modified', noteId => {
 | 
			
		||||
				//Do not update note if its open
 | 
			
		||||
				if(this.activeNoteId1 != noteId){
 | 
			
		||||
					this.$store.dispatch('fetchAndUpdateUserTotals')
 | 
			
		||||
					this.updateSingleNote(noteId)
 | 
			
		||||
				}	
 | 
			
		||||
			})
 | 
			
		||||
 | 
			
		||||
			//Update title cards when new note text is saved
 | 
			
		||||
			this.$io.on('new_note_text_saved', ({noteId, hash}) => {
 | 
			
		||||
 | 
			
		||||
				//Do not update note if its open
 | 
			
		||||
				if(this.activeNoteId1 != noteId){
 | 
			
		||||
					this.updateSingleNote(parseInt(noteId))
 | 
			
		||||
					this.updateSingleNote(noteId)
 | 
			
		||||
				}
 | 
			
		||||
			})
 | 
			
		||||
 | 
			
		||||
			//Update totals for app
 | 
			
		||||
			this.$store.dispatch('fetchAndUpdateUserTotals')
 | 
			
		||||
 | 
			
		||||
			//Close note event
 | 
			
		||||
			this.$bus.$on('close_active_note', ({position, noteId, modified}) => {
 | 
			
		||||
 | 
			
		||||
				this.closeNote(position)
 | 
			
		||||
				this.$store.dispatch('fetchAndUpdateUserTotals')
 | 
			
		||||
				this.closeNote()
 | 
			
		||||
				if(modified){
 | 
			
		||||
					this.$store.dispatch('fetchAndUpdateUserTotals')
 | 
			
		||||
					this.updateSingleNote(parseInt(noteId))
 | 
			
		||||
				}
 | 
			
		||||
			})
 | 
			
		||||
 | 
			
		||||
			this.$bus.$on('update_single_note', (noteId) => {
 | 
			
		||||
				this.updateSingleNote(noteId)
 | 
			
		||||
			})
 | 
			
		||||
			// this.$bus.$on('update_single_note', (noteId) => {
 | 
			
		||||
			// 	this.updateSingleNote(noteId)
 | 
			
		||||
			// })
 | 
			
		||||
 | 
			
		||||
			this.$bus.$on('note_deleted', (noteId) => {
 | 
			
		||||
				//Remove deleted note from set, its deleted
 | 
			
		||||
@@ -320,7 +346,7 @@
 | 
			
		||||
 | 
			
		||||
			this.$bus.$off('note_reload')
 | 
			
		||||
			this.$bus.$off('close_active_note')
 | 
			
		||||
			this.$bus.$off('update_single_note')
 | 
			
		||||
			// this.$bus.$off('update_single_note')
 | 
			
		||||
			this.$bus.$off('note_deleted')
 | 
			
		||||
			this.$bus.$off('update_fast_filters')
 | 
			
		||||
			this.$bus.$off('update_search_term')
 | 
			
		||||
@@ -364,30 +390,8 @@
 | 
			
		||||
				}
 | 
			
		||||
			},
 | 
			
		||||
			closeNote(position){
 | 
			
		||||
				//One note open, close that note
 | 
			
		||||
				if(position == 0){
 | 
			
		||||
					this.activeNoteId1 = null
 | 
			
		||||
					this.activeNoteId2 = null
 | 
			
		||||
				}
 | 
			
		||||
				//Right note closed, thats 1
 | 
			
		||||
				if(position == 1){
 | 
			
		||||
					this.activeNoteId1 = null
 | 
			
		||||
				}
 | 
			
		||||
				if(position == 2){
 | 
			
		||||
					this.activeNoteId2 = null
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				//IF two notes get opened, update ID of open note
 | 
			
		||||
				if(this.activeNoteId1 || this.activeNoteId2){
 | 
			
		||||
					this.$router.push('/notes/open/'+Math.max(this.activeNoteId1, this.activeNoteId2))
 | 
			
		||||
				} else {
 | 
			
		||||
					//No notes are open, just show notes page
 | 
			
		||||
					this.$router.push('/notes')
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
				this.activeNote1Position = 0
 | 
			
		||||
				this.activeNote2Position = 0
 | 
			
		||||
 | 
			
		||||
				this.activeNoteId1 = null
 | 
			
		||||
				this.$router.push('/notes')
 | 
			
		||||
			},
 | 
			
		||||
			toggleTagFilter(tagId){
 | 
			
		||||
 | 
			
		||||
@@ -479,6 +483,8 @@
 | 
			
		||||
			// @TODO Don't even trigger this if the note wasn't changed
 | 
			
		||||
			updateSingleNote(noteId){
 | 
			
		||||
 | 
			
		||||
				noteId = parseInt(noteId)
 | 
			
		||||
 | 
			
		||||
				//Find local note, if it exists; continue
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -656,33 +662,58 @@
 | 
			
		||||
				//Sort notes into defined sections
 | 
			
		||||
				notes.forEach(note => {
 | 
			
		||||
 | 
			
		||||
					//Only show trashed notes when trashed
 | 
			
		||||
					if(this.fastFilters.onlyShowTrashed == 1){
 | 
			
		||||
 | 
			
		||||
						if(note.trashed == 1){
 | 
			
		||||
							this.noteSections.trashed.push(note)
 | 
			
		||||
						}
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
					if(note.trashed == 1){
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					//Show archived notes
 | 
			
		||||
					if(note.archived == 1 && this.fastFilters.onlyArchived == 1){
 | 
			
		||||
						this.noteSections.archived.push(note)
 | 
			
		||||
					if(this.fastFilters.onlyArchived == 1){
 | 
			
		||||
 | 
			
		||||
						if(note.pinned == 1 && note.archived == 1){
 | 
			
		||||
							this.noteSections.pinned.push(note)
 | 
			
		||||
							return
 | 
			
		||||
						}
 | 
			
		||||
						if(note.archived == 1){
 | 
			
		||||
							this.noteSections.archived.push(note)
 | 
			
		||||
						}
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
					if(note.shareUsername != null){
 | 
			
		||||
						this.noteSections.shared.push(note)
 | 
			
		||||
					if(note.archived == 1){
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					//Only show sent notes section if shared is selected
 | 
			
		||||
					if(note.shared == 2 && this.fastFilters.onlyShowSharedNotes == 1){
 | 
			
		||||
						this.noteSections.sent.push(note)
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
					if(note.note_highlights.length > 0){
 | 
			
		||||
						this.noteSections.highlights.push(note)
 | 
			
		||||
					if(this.fastFilters.onlyShowSharedNotes == 1){
 | 
			
		||||
 | 
			
		||||
						if(note.shared == 2){
 | 
			
		||||
							this.noteSections.sent.push(note)
 | 
			
		||||
						}
 | 
			
		||||
						if(note.shareUsername != null){
 | 
			
		||||
							this.noteSections.shared.push(note)
 | 
			
		||||
						}
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
					//Show shared notes on main list but not notes shared with you
 | 
			
		||||
					if(note.shareUsername != null){ return }
 | 
			
		||||
 | 
			
		||||
					// Pinned notes are always first, they can appear in the archive
 | 
			
		||||
					if(note.pinned == 1){
 | 
			
		||||
						this.noteSections.pinned.push(note)
 | 
			
		||||
						return
 | 
			
		||||
					}
 | 
			
		||||
					//If the note is not archived, push it.
 | 
			
		||||
					if(note.archived != 1 && this.fastFilters.onlyArchived != 1){
 | 
			
		||||
						this.noteSections.notes.push(note)
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					//Push to default note section 
 | 
			
		||||
					this.noteSections.notes.push(note)
 | 
			
		||||
					
 | 
			
		||||
					return
 | 
			
		||||
				})
 | 
			
		||||
 | 
			
		||||
			},
 | 
			
		||||
@@ -692,14 +723,13 @@
 | 
			
		||||
				this.searchTerm = ''
 | 
			
		||||
				this.searchTags = []
 | 
			
		||||
				this.fastFilters = {}
 | 
			
		||||
				this.updateFastFilters(5)
 | 
			
		||||
				this.foundAttachments = [] //Remove all attachments 
 | 
			
		||||
				this.$bus.$emit('reset_fast_filters')
 | 
			
		||||
				// this.$bus.$emit('reset_fast_filters')
 | 
			
		||||
 | 
			
		||||
				//Load initial batch, then tags, then other batch
 | 
			
		||||
				this.search(true, this.firstLoadBatchSize)
 | 
			
		||||
				.then( () => {
 | 
			
		||||
 | 
			
		||||
					
 | 
			
		||||
					//Load a larger batch once first batch has loaded
 | 
			
		||||
					return this.search(false, this.batchSize, true)
 | 
			
		||||
				})
 | 
			
		||||
@@ -711,6 +741,7 @@
 | 
			
		||||
 | 
			
		||||
				//clear out tags
 | 
			
		||||
				this.searchTags = []
 | 
			
		||||
				this.loadingInProgress = false
 | 
			
		||||
 | 
			
		||||
				//A little hacky, brings user to notes page then filters on click
 | 
			
		||||
				if(this.$route.name != 'Note Page'){
 | 
			
		||||
@@ -725,7 +756,8 @@
 | 
			
		||||
					'withTags', // 'Only Show Notes with Tags'
 | 
			
		||||
					'onlyArchived', //'Only Show Archived Notes'
 | 
			
		||||
					'onlyShowSharedNotes', //Only show shared notes
 | 
			
		||||
					'onlyShowEncrypted',
 | 
			
		||||
					'onlyShowTrashed',
 | 
			
		||||
					'notesHome',
 | 
			
		||||
				]
 | 
			
		||||
 | 
			
		||||
				let filter = {}
 | 
			
		||||
 
 | 
			
		||||
@@ -123,6 +123,7 @@ export default new Vuex.Store({
 | 
			
		||||
			//Save all the totals for the user
 | 
			
		||||
			state.userTotals = totalsObject
 | 
			
		||||
 | 
			
		||||
			// console.log('-------------')
 | 
			
		||||
			// Object.keys(totalsObject).forEach( key => {
 | 
			
		||||
			// 	console.log(key + ' -- ' + totalsObject[key])
 | 
			
		||||
			// })
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user