1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-12-15 23:28:16 +09:00
This commit is contained in:
syuilo 2018-05-26 23:37:40 +09:00
parent 102aaeb390
commit 100557e975

View File

@ -12,6 +12,7 @@ const fetchLimit = 10;
export default Vue.extend({ export default Vue.extend({
props: ['list'], props: ['list'],
data() { data() {
return { return {
fetching: true, fetching: true,
@ -20,15 +21,25 @@ export default Vue.extend({
connection: null connection: null
}; };
}, },
computed: {
canFetchMore(): boolean {
return !this.moreFetching && !this.fetching && this.existMore;
}
},
watch: { watch: {
$route: 'init' $route: 'init'
}, },
mounted() { mounted() {
this.init(); this.init();
}, },
beforeDestroy() { beforeDestroy() {
this.connection.close(); this.connection.close();
}, },
methods: { methods: {
init() { init() {
if (this.connection) this.connection.close(); if (this.connection) this.connection.close();
@ -39,6 +50,7 @@ export default Vue.extend({
this.fetch(); this.fetch();
}, },
fetch() { fetch() {
this.fetching = true; this.fetching = true;
@ -59,7 +71,10 @@ export default Vue.extend({
}, rej); }, rej);
})); }));
}, },
more() { more() {
if (!this.canFetchMore) return;
this.moreFetching = true; this.moreFetching = true;
(this as any).api('notes/user-list-timeline', { (this as any).api('notes/user-list-timeline', {
@ -78,13 +93,16 @@ export default Vue.extend({
this.moreFetching = false; this.moreFetching = false;
}); });
}, },
onNote(note) { onNote(note) {
// Prepend a note // Prepend a note
(this.$refs.timeline as any).prepend(note); (this.$refs.timeline as any).prepend(note);
}, },
onUserAdded() { onUserAdded() {
this.fetch(); this.fetch();
}, },
onUserRemoved() { onUserRemoved() {
this.fetch(); this.fetch();
} }