-
+
+ No more posts to load
+ No posts found
+
@@ -241,7 +240,6 @@
},
updated() {
- this.scroll();
},
methods: {
@@ -279,6 +277,32 @@
});
},
+ infiniteTimeline($state) {
+ let homeTimeline = '/api/v1/timelines/home';
+ let localTimeline = '/api/v1/timelines/public';
+ let apiUrl = this.scope == '/' ? homeTimeline : localTimeline;
+ axios.get(apiUrl, {
+ params: {
+ page: this.page,
+ },
+ }).then(res => {
+ if (res.data.length) {
+ $('.timeline .loader').addClass('d-none');
+ let data = res.data;
+ this.feed.push(...data);
+ let ids = data.map(status => status.id);
+ this.min_id = Math.min(...ids);
+ if(this.page == 1) {
+ this.max_id = Math.max(...ids);
+ }
+ this.page += 1;
+ $state.loaded();
+ } else {
+ $state.complete();
+ }
+ });
+ },
+
fetchNotifications() {
axios.get('/api/v1/notifications')
.then(res => {
@@ -288,16 +312,6 @@
});
},
- scroll() {
- window.onscroll = () => {
- let bottomOfWindow = document.documentElement.scrollTop + window.innerHeight == document.documentElement.offsetHeight;
-
- if (bottomOfWindow) {
- this.fetchTimelineApi();
- }
- };
- },
-
reportUrl(status) {
let type = status.in_reply_to ? 'comment' : 'post';
let id = status.id;