X-Git-Url: https://git.r.bdr.sh/rbdr/dasein/blobdiff_plain/a6ccda0fbc4df683f9568d85eb22b21684d2a0bd..HEAD:/app/components/posts.js?ds=sidebyside
diff --git a/app/components/posts.js b/app/components/posts.js
index c41707f..d0e0338 100644
--- a/app/components/posts.js
+++ b/app/components/posts.js
@@ -3,26 +3,21 @@ import Vue from 'vue';
import AuthService from '../services/auth';
import PostFormComponent from './post_form';
+import PostComponent from './post';
import DatetimeFilter from '../filters/datetime';
import UsertimeFilter from '../filters/usertime';
const internals = {};
internals.kPostsRoute = '/api/posts';
+internals.kPollFrequency = 5000;
export default internals.PostsComponent = Vue.component('posts', {
- template: '
' +
+ template: '
' +
'
' +
'
Posts.
' +
'
{{message}}
' +
- '
' +
- '' +
- '{{post.content}}
' +
- '' +
+ '
' +
'
',
data() {
@@ -46,9 +41,12 @@ export default internals.PostsComponent = Vue.component('posts', {
}).then((response) => {
this.posts = response.data;
+ if (!this._isBeingDestroyed) {
+ setTimeout(this.fetchPosts.bind(this), internals.kPollFrequency);
+ }
}).catch((err) => {
- console.err(err.stack);
+ console.error(err.stack);
this.message = 'Error while loading the posts...';
});
},
@@ -61,17 +59,19 @@ export default internals.PostsComponent = Vue.component('posts', {
components: {
postForm: PostFormComponent,
+ post: PostComponent,
datetime: DatetimeFilter,
usertime: UsertimeFilter
},
- mounted: function mounted() {
+ mounted() {
if (!this.authService.authenticated) {
return this.$router.push('/login');
}
- return this.fetchPosts();
+ this.fetchPosts();
+
}
});