@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="mk-timeline">
|
||||
<mk-friends-maker v-if="alone"/>
|
||||
<mk-posts :posts="posts">
|
||||
<mk-notes :notes="notes">
|
||||
<div class="init" v-if="fetching">
|
||||
%fa:spinner .pulse%%i18n:common.loading%
|
||||
</div>
|
||||
<div class="empty" v-if="!fetching && posts.length == 0">
|
||||
<div class="empty" v-if="!fetching && notes.length == 0">
|
||||
%fa:R comments%
|
||||
%i18n:mobile.tags.mk-home-timeline.empty-timeline%
|
||||
</div>
|
||||
@@ -13,7 +13,7 @@
|
||||
<span v-if="!moreFetching">%i18n:mobile.tags.mk-timeline.load-more%</span>
|
||||
<span v-if="moreFetching">%i18n:common.loading%<mk-ellipsis/></span>
|
||||
</button>
|
||||
</mk-posts>
|
||||
</mk-notes>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -33,7 +33,7 @@ export default Vue.extend({
|
||||
return {
|
||||
fetching: true,
|
||||
moreFetching: false,
|
||||
posts: [],
|
||||
notes: [],
|
||||
existMore: false,
|
||||
connection: null,
|
||||
connectionId: null
|
||||
@@ -48,14 +48,14 @@ export default Vue.extend({
|
||||
this.connection = (this as any).os.stream.getConnection();
|
||||
this.connectionId = (this as any).os.stream.use();
|
||||
|
||||
this.connection.on('post', this.onPost);
|
||||
this.connection.on('note', this.onNote);
|
||||
this.connection.on('follow', this.onChangeFollowing);
|
||||
this.connection.on('unfollow', this.onChangeFollowing);
|
||||
|
||||
this.fetch();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.connection.off('post', this.onPost);
|
||||
this.connection.off('note', this.onNote);
|
||||
this.connection.off('follow', this.onChangeFollowing);
|
||||
this.connection.off('unfollow', this.onChangeFollowing);
|
||||
(this as any).os.stream.dispose(this.connectionId);
|
||||
@@ -63,15 +63,15 @@ export default Vue.extend({
|
||||
methods: {
|
||||
fetch(cb?) {
|
||||
this.fetching = true;
|
||||
(this as any).api('posts/timeline', {
|
||||
(this as any).api('notes/timeline', {
|
||||
limit: limit + 1,
|
||||
untilDate: this.date ? (this.date as any).getTime() : undefined
|
||||
}).then(posts => {
|
||||
if (posts.length == limit + 1) {
|
||||
posts.pop();
|
||||
}).then(notes => {
|
||||
if (notes.length == limit + 1) {
|
||||
notes.pop();
|
||||
this.existMore = true;
|
||||
}
|
||||
this.posts = posts;
|
||||
this.notes = notes;
|
||||
this.fetching = false;
|
||||
this.$emit('loaded');
|
||||
if (cb) cb();
|
||||
@@ -79,22 +79,22 @@ export default Vue.extend({
|
||||
},
|
||||
more() {
|
||||
this.moreFetching = true;
|
||||
(this as any).api('posts/timeline', {
|
||||
(this as any).api('notes/timeline', {
|
||||
limit: limit + 1,
|
||||
untilId: this.posts[this.posts.length - 1].id
|
||||
}).then(posts => {
|
||||
if (posts.length == limit + 1) {
|
||||
posts.pop();
|
||||
untilId: this.notes[this.notes.length - 1].id
|
||||
}).then(notes => {
|
||||
if (notes.length == limit + 1) {
|
||||
notes.pop();
|
||||
this.existMore = true;
|
||||
} else {
|
||||
this.existMore = false;
|
||||
}
|
||||
this.posts = this.posts.concat(posts);
|
||||
this.notes = this.notes.concat(notes);
|
||||
this.moreFetching = false;
|
||||
});
|
||||
},
|
||||
onPost(post) {
|
||||
this.posts.unshift(post);
|
||||
onNote(note) {
|
||||
this.notes.unshift(note);
|
||||
},
|
||||
onChangeFollowing() {
|
||||
this.fetch();
|
||||
|
||||
Reference in New Issue
Block a user