summaryrefslogtreecommitdiffstats
path: root/src/store
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2018-11-22 15:42:10 +0100
committerJulius Härtl <jus@bitgrid.net>2018-11-22 16:14:36 +0100
commit9375d246b9b72942b22ae89fc0f09234e6a1e287 (patch)
treecae348c2871096bf7181581af5eb6d99237ef223 /src/store
parentf3a36449e086c662c3c84169172e63d1fbb20ac7 (diff)
Load different timeline streams
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'src/store')
-rw-r--r--src/store/timeline.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/store/timeline.js b/src/store/timeline.js
index b06dad71..e872f475 100644
--- a/src/store/timeline.js
+++ b/src/store/timeline.js
@@ -25,18 +25,25 @@ import Vue from 'vue'
const state = {
timeline: {},
- since: new Date()
+ since: Math.floor(Date.now() / 1000) + 1,
+ type: 'home'
}
const mutations = {
addToTimeline(state, data) {
for (let item in data) {
- state.since = data[item].published
+ state.since = data[item].publishedTime
Vue.set(state.timeline, data[item].id, data[item])
}
},
addPost(state, data) {
// FIXME: push data we receive to the timeline array
// state.timeline.push(data)
+ },
+ resetTimeline(state) {
+ state.timeline = {}
+ },
+ setTimelineType(state, type) {
+ state.type = type
}
}
const getters = {
@@ -47,6 +54,10 @@ const getters = {
}
}
const actions = {
+ changeTimelineType(context, type) {
+ context.commit('resetTimeline')
+ context.commit('setTimelineType', type)
+ },
post(context, post) {
return axios.post(OC.generateUrl('apps/social/api/v1/post'), { data: post }).then((response) => {
context.commit('addPost', { data: response.data })
@@ -60,9 +71,9 @@ const actions = {
},
fetchTimeline(context, { account, sinceTimestamp }) {
if (typeof sinceTimestamp === 'undefined') {
- sinceTimestamp = Date.parse(state.since) / 1000
+ sinceTimestamp = state.since - 1
}
- return axios.get(OC.generateUrl('apps/social/api/v1/stream/timeline?limit=5&since=' + sinceTimestamp)).then((response) => {
+ return axios.get(OC.generateUrl(`apps/social/api/v1/stream/${state.type}?limit=5&since=` + sinceTimestamp)).then((response) => {
if (response.status === -1) {
throw response.message
}