summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCyrille Bollu <cyrpub@bollu.be>2019-09-14 14:23:34 +0200
committerMaxence Lange <maxence@artificial-owl.com>2019-09-25 14:07:24 +0200
commit4fd2473dda4fa00918e05d9cad3df201f30c323c (patch)
tree27ab0511767eb0bcf765c05cd35c00c28909a5a4 /src
parent3ef67902403e7fe89ca8321a310bf7abd6e4a705 (diff)
Adapts timeline.js's fetchTimeline for the single-post timeline.
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
Diffstat (limited to 'src')
-rw-r--r--src/store/timeline.js28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/store/timeline.js b/src/store/timeline.js
index f4419736..8af00435 100644
--- a/src/store/timeline.js
+++ b/src/store/timeline.js
@@ -181,24 +181,46 @@ const actions = {
return this.dispatch('fetchTimeline', { sinceTimestamp: Math.floor(Date.now() / 1000) + 1 })
},
fetchTimeline(context, { sinceTimestamp }) {
+
if (typeof sinceTimestamp === 'undefined') {
sinceTimestamp = state.since - 1
}
+
let url
if (state.type === 'account') {
url = OC.generateUrl(`apps/social/api/v1/account/${state.account}/stream?limit=25&since=` + sinceTimestamp)
} else if (state.type === 'tags') {
url = OC.generateUrl(`apps/social/api/v1/stream/tag/${state.params.tag}?limit=25&since=` + sinceTimestamp)
- } else if (state.type === 'post') {
- url = OC.generateUrl(`apps/social/local/v1/post/replies?id=${state.params.id}&limit=5&since=0`)
+ } else if (state.type === 'single-post') {
+ url = OC.generateUrl(`apps/social/@{state.params.account}/${state.params.id}`)
} else {
url = OC.generateUrl(`apps/social/api/v1/stream/${state.type}?limit=25&since=` + sinceTimestamp)
}
+
+ // Get the data
return axios.get(url).then((response) => {
+
if (response.status === -1) {
throw response.message
}
- context.commit('addToTimeline', response.data.result)
+
+ let result = []
+
+ // Also load replies when displaying a single post timeline
+ if (state.type === 'single-post') {
+ result.push(response.data)
+// axios.get(OC.generateUrl(``)).then((response) => {
+// if (response.status !== -1) {
+// result.concat(response.data.result)
+// }
+// }
+ } else {
+ result = response.data.result
+ }
+
+ // Add results to timeline
+ context.commit('addToTimeline', result)
+
return response.data
})
},