Added timeout to fetch user totals which prevents
Duplicate calls which would be really annoying
This commit is contained in:
parent
0202d1acda
commit
48c1fa8e69
@ -227,10 +227,12 @@
|
|||||||
},
|
},
|
||||||
pinNote(){ //togglePinned() <- old name
|
pinNote(){ //togglePinned() <- old name
|
||||||
this.showWorking = true
|
this.showWorking = true
|
||||||
let postData = {'pinned': !this.note.pinned, 'noteId':this.note.id}
|
this.note.pinned = this.note.pinned == 1 ? 0:1
|
||||||
|
let postData = {'pinned': this.note.pinned, 'noteId':this.note.id}
|
||||||
axios.post('/api/note/setpinned', postData)
|
axios.post('/api/note/setpinned', postData)
|
||||||
.then(data => {
|
.then(data => {
|
||||||
this.showWorking = false
|
this.showWorking = false
|
||||||
|
// this event is triggered by the server after note is saved
|
||||||
// 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') })
|
.catch(error => { this.$bus.$emit('notification', 'Failed to Pin Note') })
|
||||||
@ -246,11 +248,10 @@
|
|||||||
//Show message so no one worries where note went
|
//Show message so no one worries where note went
|
||||||
let message = 'Moved to Archive'
|
let message = 'Moved to Archive'
|
||||||
if(postData.archived != 1){
|
if(postData.archived != 1){
|
||||||
message = 'Moved to main list'
|
message = 'Moved out of Archive'
|
||||||
}
|
}
|
||||||
this.$bus.$emit('notification', message)
|
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') })
|
.catch(error => { this.$bus.$emit('notification', 'Failed to Archive Note') })
|
||||||
},
|
},
|
||||||
@ -265,9 +266,10 @@
|
|||||||
//Show message so no one worries where note went
|
//Show message so no one worries where note went
|
||||||
let message = 'Moved to Trash'
|
let message = 'Moved to Trash'
|
||||||
if(postData.trashed == 0){
|
if(postData.trashed == 0){
|
||||||
message = 'Moved to main list'
|
message = 'Moved out of Trash'
|
||||||
}
|
}
|
||||||
this.$bus.$emit('notification', message)
|
this.$bus.$emit('notification', message)
|
||||||
|
this.$bus.$emit('update_single_note', this.note.id)
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(error => { this.$bus.$emit('notification', 'Failed to Trash Note') })
|
.catch(error => { this.$bus.$emit('notification', 'Failed to Trash Note') })
|
||||||
|
@ -127,7 +127,7 @@
|
|||||||
:data="note"
|
:data="note"
|
||||||
:title-view="titleView || isFloatingList"
|
:title-view="titleView || isFloatingList"
|
||||||
:currently-open="openNotes.includes(note.id)"
|
:currently-open="openNotes.includes(note.id)"
|
||||||
:key="note.id + note.color + '-' +note.title.length + '-' +note.subtext.length + '-' + note.tag_count + note.updated"
|
:key="note.id + note.color + '-' +note.title.length + '-' +note.subtext.length + '-' + note.tag_count + note.updated + note.archived + note.pinned + note.trashed"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -564,16 +564,20 @@
|
|||||||
// @TODO Don't even trigger this if the note wasn't changed
|
// @TODO Don't even trigger this if the note wasn't changed
|
||||||
updateSingleNote(noteId, focuseAndAnimate = true){
|
updateSingleNote(noteId, focuseAndAnimate = true){
|
||||||
|
|
||||||
|
console.log('updating single note', noteId)
|
||||||
|
|
||||||
noteId = parseInt(noteId)
|
noteId = parseInt(noteId)
|
||||||
|
|
||||||
//Find local note, if it exists; continue
|
//Find local note, if it exists; continue
|
||||||
let note = null
|
let note = null
|
||||||
if(this.$refs['note-'+noteId] && this.$refs['note-'+noteId][0] && this.$refs['note-'+noteId][0].note){
|
if(this.$refs['note-'+noteId]?.[0]?.note){
|
||||||
note = this.$refs['note-'+noteId][0].note
|
note = this.$refs['note-'+noteId][0].note
|
||||||
//Show that note is working on updating
|
//Show that note is working on updating
|
||||||
this.$refs['note-'+noteId][0].showWorking = true
|
this.$refs['note-'+noteId][0].showWorking = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.rebuildNoteCategorise()
|
||||||
|
// return
|
||||||
|
|
||||||
//Lookup one note using passed in ID
|
//Lookup one note using passed in ID
|
||||||
const postData = {
|
const postData = {
|
||||||
|
@ -9,6 +9,7 @@ export default new Vuex.Store({
|
|||||||
username: null,
|
username: null,
|
||||||
nightMode: false,
|
nightMode: false,
|
||||||
isUserOnMobile: false,
|
isUserOnMobile: false,
|
||||||
|
fetchTotalsTimeout: null,
|
||||||
userTotals: null,
|
userTotals: null,
|
||||||
activeSessions: 0,
|
activeSessions: 0,
|
||||||
},
|
},
|
||||||
@ -155,17 +156,20 @@ export default new Vuex.Store({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
fetchAndUpdateUserTotals ({ commit }) {
|
fetchAndUpdateUserTotals ({ commit, state }) {
|
||||||
axios.post('/api/user/totals')
|
clearTimeout(state.fetchTotalsTimeout)
|
||||||
.then( ({data}) => {
|
state.fetchTotalsTimeout = setTimeout(() => {
|
||||||
commit('setUserTotals', data)
|
axios.post('/api/user/totals')
|
||||||
})
|
.then( ({data}) => {
|
||||||
.catch( error => {
|
commit('setUserTotals', data)
|
||||||
if(error.response && error.response.status == 400){
|
})
|
||||||
commit('destroyLoginToken')
|
.catch( error => {
|
||||||
location.reload()
|
if(error.response && error.response.status == 400){
|
||||||
}
|
commit('destroyLoginToken')
|
||||||
})
|
location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
Loading…
Reference in New Issue
Block a user