diff options
author | Cyrille Bollu <cyrpub@bollu.be> | 2019-09-14 14:23:34 +0200 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2019-09-25 14:07:24 +0200 |
commit | 4fd2473dda4fa00918e05d9cad3df201f30c323c (patch) | |
tree | 27ab0511767eb0bcf765c05cd35c00c28909a5a4 /src/store | |
parent | 3ef67902403e7fe89ca8321a310bf7abd6e4a705 (diff) |
Adapts timeline.js's fetchTimeline for the single-post timeline.
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/timeline.js | 28 |
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 }) }, |