From 100557e975a0aab19d0fa42e552ac5bf7882a65f Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 26 May 2018 23:37:40 +0900 Subject: [PATCH] Fix bug --- .../views/components/user-list-timeline.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/client/app/mobile/views/components/user-list-timeline.vue b/src/client/app/mobile/views/components/user-list-timeline.vue index 59d6abbbc..c0ba995b6 100644 --- a/src/client/app/mobile/views/components/user-list-timeline.vue +++ b/src/client/app/mobile/views/components/user-list-timeline.vue @@ -12,6 +12,7 @@ const fetchLimit = 10; export default Vue.extend({ props: ['list'], + data() { return { fetching: true, @@ -20,15 +21,25 @@ export default Vue.extend({ connection: null }; }, + + computed: { + canFetchMore(): boolean { + return !this.moreFetching && !this.fetching && this.existMore; + } + }, + watch: { $route: 'init' }, + mounted() { this.init(); }, + beforeDestroy() { this.connection.close(); }, + methods: { init() { if (this.connection) this.connection.close(); @@ -39,6 +50,7 @@ export default Vue.extend({ this.fetch(); }, + fetch() { this.fetching = true; @@ -59,7 +71,10 @@ export default Vue.extend({ }, rej); })); }, + more() { + if (!this.canFetchMore) return; + this.moreFetching = true; (this as any).api('notes/user-list-timeline', { @@ -78,13 +93,16 @@ export default Vue.extend({ this.moreFetching = false; }); }, + onNote(note) { // Prepend a note (this.$refs.timeline as any).prepend(note); }, + onUserAdded() { this.fetch(); }, + onUserRemoved() { this.fetch(); }