kopia lustrzana https://github.com/nextcloud/social
Make pagination work properly
Signed-off-by: Julius Härtl <jus@bitgrid.net>pull/21/head
rodzic
9187acfc47
commit
a39a360ad9
|
@ -149,7 +149,7 @@ class LocalController extends Controller {
|
|||
// $this->miscService->log('timeline: ' . json_encode($data));
|
||||
|
||||
try {
|
||||
$posts = $this->noteService->getTimeline($since, $limit);
|
||||
$posts = $this->noteService->getTimeline((int)$since, (int)$limit);
|
||||
|
||||
return $this->success($posts);
|
||||
} catch (Exception $e) {
|
||||
|
|
|
@ -231,7 +231,8 @@ class CoreRequestBuilder {
|
|||
$expr = $qb->expr();
|
||||
$dt = new \DateTime();
|
||||
$dt->setTimestamp($since);
|
||||
$qb->andWhere('creation < "2020-10-10 10:00:00"');
|
||||
// TODO: Pagination should use published date, once we can properly query the db for that
|
||||
$qb->andWhere($expr->lt('creation', $qb->createNamedParameter($dt, IQueryBuilder::PARAM_DATE), IQueryBuilder::PARAM_DATE));
|
||||
}
|
||||
$qb->setMaxResults($limit);
|
||||
$qb->orderBy('creation', 'desc');
|
||||
|
|
|
@ -237,7 +237,7 @@ class NoteService implements ICoreService {
|
|||
* @return Note[]
|
||||
*/
|
||||
public function getTimeline($since = 0, $limit = 5): array {
|
||||
$notes = $this->notesRequest->getPublicNotes($since = 0, $limit = 5);
|
||||
$notes = $this->notesRequest->getPublicNotes($since, $limit);
|
||||
$result = [];
|
||||
/** @var Note $note */
|
||||
foreach ($notes as $note) {
|
||||
|
|
|
@ -25,7 +25,7 @@ import axios from 'nextcloud-axios'
|
|||
|
||||
const state = {
|
||||
timeline: [],
|
||||
since: 0,
|
||||
since: new Date(),
|
||||
}
|
||||
const mutations = {
|
||||
addToTimeline(state, data) {
|
||||
|
@ -47,7 +47,8 @@ const actions = {
|
|||
})
|
||||
},
|
||||
fetchTimeline(context, account) {
|
||||
return axios.get(OC.generateUrl('apps/social/api/v1/timeline?since=' + state.since)).then((response) => {
|
||||
const sinceTimestamp = Date.parse(state.since)/1000;
|
||||
return axios.get(OC.generateUrl('apps/social/api/v1/timeline?limit=5&since=' + sinceTimestamp)).then((response) => {
|
||||
context.commit('addToTimeline', response.data.result);
|
||||
return response.data.result;
|
||||
})
|
||||
|
|
|
@ -26,7 +26,10 @@
|
|||
</form>
|
||||
</div>
|
||||
<!--<timeline-entry v-for="entry in timeline" :item="entry" :key="entry.id" /> //-->
|
||||
<div v-for="entry in timeline">{{entry}}</div>
|
||||
<div v-for="entry in timeline">
|
||||
{{entry.content}}
|
||||
<pre style="height: 200px; overflow:scroll;">{{entry}}</pre>
|
||||
</div>
|
||||
<infinite-loading @infinite="infiniteHandler" ref="infiniteLoading">
|
||||
<div slot="spinner"><div class="icon-loading"></div></div>
|
||||
<div slot="no-more"><div class="list-end"></div></div>
|
||||
|
@ -211,22 +214,7 @@ export default {
|
|||
}
|
||||
},
|
||||
beforeMount: function() {
|
||||
/*let example = {
|
||||
message: 'Want to #DropDropbox? #DeleteGoogle? #decentralize? We got you covered, easy as a piece of 🥞\n'
|
||||
+ '\n'
|
||||
+ 'Get started right now: https://nextcloud.com/signup',
|
||||
author: 'Nextcloud 📱☁️💻',
|
||||
authorId: '@nextcloud@mastodon.xyz',
|
||||
authorAvatar: OC.linkTo('social', 'img/nextcloud.png'),
|
||||
timestamp: '1 day ago'
|
||||
}
|
||||
let data = []
|
||||
for (let i = 0; i < 20; i++) {
|
||||
let item = Object.assign({}, example)
|
||||
item.id = i
|
||||
data.push(item)
|
||||
}
|
||||
this.$store.commit('addToTimeline', data)*/
|
||||
|
||||
},
|
||||
methods: {
|
||||
hideInfo() {
|
||||
|
|
Ładowanie…
Reference in New Issue