mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-06 20:33:33 +01:00
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({
|
||||
timeline: state => state.TimelineSpace.homeTimeline,
|
||||
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 () {
|
||||
@ -39,6 +40,7 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
onScroll (event) {
|
||||
// for 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])
|
||||
.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: '',
|
||||
username: ''
|
||||
},
|
||||
heading: true,
|
||||
homeTimeline: [],
|
||||
unreadHomeTimeline: [],
|
||||
notifications: []
|
||||
},
|
||||
mutations: {
|
||||
updateAccount (state, account) {
|
||||
state.account = account
|
||||
},
|
||||
changeHeading (state, value) {
|
||||
state.heading = value
|
||||
},
|
||||
appendHomeTimeline (state, update) {
|
||||
state.homeTimeline = [update].concat(state.homeTimeline)
|
||||
if (state.heading) {
|
||||
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) {
|
||||
state.notifications = [notification].concat(state.notifications)
|
||||
@ -77,6 +90,7 @@ const TimelineSpace = {
|
||||
},
|
||||
clearTimeline (state) {
|
||||
state.homeTimeline = []
|
||||
state.unreadHomeTimeline = []
|
||||
},
|
||||
clearNotifications (state) {
|
||||
state.notifications = []
|
||||
@ -139,9 +153,13 @@ const TimelineSpace = {
|
||||
})
|
||||
})
|
||||
},
|
||||
startUserStreaming ({ commit }, account) {
|
||||
startUserStreaming ({ state, commit }, account) {
|
||||
ipcRenderer.on('update-start-user-streaming', (event, update) => {
|
||||
commit('appendHomeTimeline', update)
|
||||
// Sometimes archive old statuses
|
||||
if (state.heading) {
|
||||
commit('archiveHomeTimeline')
|
||||
}
|
||||
commit('TimelineSpace/SideMenu/changeUnreadHomeTimeline', true, { root: true })
|
||||
})
|
||||
ipcRenderer.on('notification-start-user-streaming', (event, notification) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user