refs #197 Archive home timeline and store unread timeline
This commit is contained in:
parent
eccce5592c
commit
af79cf654d
@ -19,7 +19,8 @@ export default {
|
|||||||
...mapState({
|
...mapState({
|
||||||
timeline: state => state.TimelineSpace.homeTimeline,
|
timeline: state => state.TimelineSpace.homeTimeline,
|
||||||
lazyLoading: state => state.TimelineSpace.Contents.Home.lazyLoading,
|
lazyLoading: state => state.TimelineSpace.Contents.Home.lazyLoading,
|
||||||
backgroundColor: state => state.App.theme.background_color
|
backgroundColor: state => state.App.theme.background_color,
|
||||||
|
heading: state => state.TimelineSpace.heading
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
@ -39,6 +40,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onScroll (event) {
|
onScroll (event) {
|
||||||
|
// for lazyLoading
|
||||||
if (((event.target.clientHeight + event.target.scrollTop) >= document.getElementById('home').clientHeight - 10) && !this.lazyloading) {
|
if (((event.target.clientHeight + event.target.scrollTop) >= document.getElementById('home').clientHeight - 10) && !this.lazyloading) {
|
||||||
this.$store.dispatch('TimelineSpace/Contents/Home/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
this.$store.dispatch('TimelineSpace/Contents/Home/lazyFetchTimeline', this.timeline[this.timeline.length - 1])
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@ -48,6 +50,13 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// for unread control
|
||||||
|
if ((event.target.scrollTop > 10) && this.heading) {
|
||||||
|
this.$store.commit('TimelineSpace/changeHeading', false)
|
||||||
|
} else if ((event.target.scrollTop <= 10) && !this.heading) {
|
||||||
|
this.$store.commit('TimelineSpace/changeHeading', true)
|
||||||
|
this.$store.commit('TimelineSpace/mergeHomeTimeline')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,15 +20,28 @@ const TimelineSpace = {
|
|||||||
_id: '',
|
_id: '',
|
||||||
username: ''
|
username: ''
|
||||||
},
|
},
|
||||||
|
heading: true,
|
||||||
homeTimeline: [],
|
homeTimeline: [],
|
||||||
|
unreadHomeTimeline: [],
|
||||||
notifications: []
|
notifications: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
updateAccount (state, account) {
|
updateAccount (state, account) {
|
||||||
state.account = account
|
state.account = account
|
||||||
},
|
},
|
||||||
|
changeHeading (state, value) {
|
||||||
|
state.heading = value
|
||||||
|
},
|
||||||
appendHomeTimeline (state, update) {
|
appendHomeTimeline (state, update) {
|
||||||
|
if (state.heading) {
|
||||||
state.homeTimeline = [update].concat(state.homeTimeline)
|
state.homeTimeline = [update].concat(state.homeTimeline)
|
||||||
|
} else {
|
||||||
|
state.unreadHomeTimeline = [update].concat(state.unreadHomeTimeline)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mergeHomeTimeline (state) {
|
||||||
|
state.homeTimeline = state.unreadHomeTimeline.concat(state.homeTimeline)
|
||||||
|
state.unreadHomeTimeline = []
|
||||||
},
|
},
|
||||||
appendNotifications (state, notification) {
|
appendNotifications (state, notification) {
|
||||||
state.notifications = [notification].concat(state.notifications)
|
state.notifications = [notification].concat(state.notifications)
|
||||||
@ -77,6 +90,7 @@ const TimelineSpace = {
|
|||||||
},
|
},
|
||||||
clearTimeline (state) {
|
clearTimeline (state) {
|
||||||
state.homeTimeline = []
|
state.homeTimeline = []
|
||||||
|
state.unreadHomeTimeline = []
|
||||||
},
|
},
|
||||||
clearNotifications (state) {
|
clearNotifications (state) {
|
||||||
state.notifications = []
|
state.notifications = []
|
||||||
@ -139,9 +153,13 @@ const TimelineSpace = {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
startUserStreaming ({ commit }, account) {
|
startUserStreaming ({ state, commit }, account) {
|
||||||
ipcRenderer.on('update-start-user-streaming', (event, update) => {
|
ipcRenderer.on('update-start-user-streaming', (event, update) => {
|
||||||
commit('appendHomeTimeline', update)
|
commit('appendHomeTimeline', update)
|
||||||
|
// Sometimes archive old statuses
|
||||||
|
if (state.heading) {
|
||||||
|
commit('archiveHomeTimeline')
|
||||||
|
}
|
||||||
commit('TimelineSpace/SideMenu/changeUnreadHomeTimeline', true, { root: true })
|
commit('TimelineSpace/SideMenu/changeUnreadHomeTimeline', true, { root: true })
|
||||||
})
|
})
|
||||||
ipcRenderer.on('notification-start-user-streaming', (event, notification) => {
|
ipcRenderer.on('notification-start-user-streaming', (event, notification) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user