refs #6 Get recent home timeline when timelie space is created
This commit is contained in:
parent
9b0728b724
commit
e1ede624f9
|
@ -16,6 +16,7 @@ export default {
|
||||||
created () {
|
created () {
|
||||||
this.$store.dispatch('TimelineSpace/fetchAccount', this.$route.params.id)
|
this.$store.dispatch('TimelineSpace/fetchAccount', this.$route.params.id)
|
||||||
.then((account) => {
|
.then((account) => {
|
||||||
|
this.$store.dispatch('TimelineSpace/fetchHomeTimeline', account)
|
||||||
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
|
this.$store.dispatch('TimelineSpace/startUserStreaming', account)
|
||||||
this.$store.dispatch('TimelineSpace/username', account)
|
this.$store.dispatch('TimelineSpace/username', account)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="home">
|
<div id="home">
|
||||||
<div class="home-timeline" v-for="(message, index) in timeline" v-bind:key="index">
|
<div class="home-timeline" v-for="message in timeline" v-bind:key="message.id">
|
||||||
<toot :message="message"></toot>
|
<toot :message="message"></toot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -17,9 +17,6 @@ export default {
|
||||||
...mapState({
|
...mapState({
|
||||||
timeline: state => state.TimelineSpace.homeTimeline
|
timeline: state => state.TimelineSpace.homeTimeline
|
||||||
})
|
})
|
||||||
},
|
|
||||||
created () {
|
|
||||||
// TODO: Get recent timeline and concat timeline before stream
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -24,10 +24,13 @@ const TimelineSpace = {
|
||||||
state.username = username
|
state.username = username
|
||||||
},
|
},
|
||||||
appendHomeTimeline (state, update) {
|
appendHomeTimeline (state, update) {
|
||||||
state.homeTimeline = state.homeTimeline.concat([update])
|
state.homeTimeline = [update].concat(state.homeTimeline)
|
||||||
},
|
},
|
||||||
appendNotification (state, notification) {
|
appendNotification (state, notification) {
|
||||||
state.notification = state.notification.concat([notification])
|
state.notification = [notification].concat(state.notification)
|
||||||
|
},
|
||||||
|
insertHomeTimeline (state, messages) {
|
||||||
|
state.homeTimeline = state.homeTimeline.concat(messages)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -75,6 +78,24 @@ const TimelineSpace = {
|
||||||
},
|
},
|
||||||
stopUserStreaming ({ commit }) {
|
stopUserStreaming ({ commit }) {
|
||||||
ipcRenderer.send('stop-user-streaming')
|
ipcRenderer.send('stop-user-streaming')
|
||||||
|
},
|
||||||
|
fetchHomeTimeline ({ commit }, account) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const client = new Mastodon(
|
||||||
|
{
|
||||||
|
access_token: account.accessToken,
|
||||||
|
api_url: account.baseURL + '/api/v1'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
client.get('/timelines/home', { limit: 40 })
|
||||||
|
.then((res) => {
|
||||||
|
commit('insertHomeTimeline', res.data)
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue