Call fetchChannels after marking items as read

This commit is contained in:
Peter Stuifzand 2019-08-12 19:35:56 +02:00
parent 63fc43fb27
commit f51f643bfa
2 changed files with 10 additions and 3 deletions

View File

@ -58,6 +58,8 @@
return this.$store.dispatch('markRead', {channel: channel, entry: item._id})
.then(() => {
item._is_read = true
}).then(() => {
this.$store.dispatch('fetchChannels')
})
},
handleScroll() {

View File

@ -175,15 +175,20 @@ export default new Vuex.Store({
},
bottomReached() {
let count = 0
this.state.timeline.items.forEach((item) => {
let uids = []
let items = this.state.timeline.items
uids = _.map(_.filter(items, item => !item._is_read), item => item._id)
items.forEach((item) => {
if (item && !item._is_read) {
item._is_read = true
this.dispatch('markRead', {channel: this.state.channel.uid, entry: item._id})
count++;
}
})
if (count > 0) {
this.dispatch('fetchChannels')
this.dispatch('markRead', {channel: this.state.channel.uid, 'entry[]': uids})
.then(() => {
this.dispatch('fetchChannels')
})
}
},
startEventListening({commit}, url) {