Cleanup mark_read

This commit is contained in:
Peter Stuifzand 2018-08-27 23:19:32 +02:00
parent 57139fd68a
commit 2d1b21b804
2 changed files with 12 additions and 4 deletions

View File

@ -51,6 +51,9 @@
},
prevPage() {
this.$emit('getPage', {uid: this.channel.uid, before: this.timeline.paging.before})
},
markRead(channel, id) {
return this.$store.dispatch('markRead', {channel:channel, entry: id })
}
},
@ -59,12 +62,18 @@
// let bottomOfWindow = document.documentElement.scrollTop + window.innerHeight === document.documentElement.offsetHeight;
let bottomOfWindow = document.documentElement.scrollTop + window.innerHeight === this.$el.offsetHeight + document.documentElement.offsetHeight + 20;
if (bottomOfWindow) {
let count = 0
this.$children.forEach((child) => {
if (child.$props.item && !child.$props.item._is_read) {
child.$props.item._is_read = true
this.$store.dispatch('markRead', child.$props.item.uid)
let item = child.$props.item
this.markRead(this.channel.uid, item._id)
count++
}
})
if (count > 0) {
this.$store.dispatch('fetchChannels')
}
}
this.$children.forEach((child) => {
@ -72,7 +81,8 @@
if (rect.top + rect.height < 100) {
if (child.$props.item && !child.$props.item._is_read) {
child.$props.item._is_read = true
this.$store.dispatch('markRead', {channel:this.channel.uid, entry: child.$props.item._id }).then(() => {
let item = child.$props.item
this.markRead(this.channel.uid, item._id).then(() => {
this.$store.dispatch('fetchChannels')
})
}

View File

@ -83,8 +83,6 @@ export default new Vuex.Store({
commit('newAccessToken', response)
},
markRead(x, {channel, entry}) {
// eslint-disable-next-line
console.log(channel, entry)
let url = 'https://microsub.stuifzandapp.com/microsub?action=timeline&method=mark_read&channel=' + encodeURIComponent(channel) + '&entry=' + encodeURIComponent(entry);
return fetch(url, {
method: 'POST',