Added some realtime events to the app

* When a user gets a new shared message, it will popup instantly
* When a new website is scraped, it will update in real time
* Various other little bug fixes and improvements
* Sharing displays correct notes and handles shared notes correctly
* Tags were not displaying on notes, they do now. They better.
This commit is contained in:
Max G committed 2020-02-14 01:08:46 +00:00
1 parent a51d81b013
commit daa674c54f
14 files changed
+247 -46

No files matched your search

+15 -4
View File
@@ -27,10 +27,17 @@ export default {
},
beforeCreate: function(){
//Puts token into state on page load
let token = localStorage.getItem('loginToken')
let username = localStorage.getItem('username')
// const socket = io({ path:'/socket' });
const socket = this.$io
socket.on('connect', () => {
this.$store.commit('setSocketIoSocket', socket.id)
this.$io.emit('user_connect', token)
})
//Detect if user is on a mobile browser and set a flag in store
@@ -41,16 +48,20 @@ export default {
this.$store.commit('toggleNightMode')
}
//Puts token into state on page load
let token = localStorage.getItem('loginToken')
let username = localStorage.getItem('username')
//Put user data into global store on load
if(token){
this.$store.commit('setLoginToken', {token, username})
}
},
mounted: function(){
//Update totals for entire app on event
this.$io.on('update_counts', () => {
console.log('Got event, update totals')
this.$store.dispatch('fetchAndUpdateUserTotals')
})
},
computed: {
loggedIn () {