From d29459fa3781043c4e484c876966dbae5c98a538 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 26 May 2018 23:53:22 +0900 Subject: [PATCH] Fix bug --- .../desktop/views/components/timeline.core.vue | 8 ++++++-- .../views/components/user-list-timeline.vue | 8 ++++++-- .../desktop/views/pages/user/user.timeline.vue | 17 +++++++++++++++-- .../views/components/user-list-timeline.vue | 8 ++++++-- .../mobile/views/components/user-timeline.vue | 9 +++++++-- .../app/mobile/views/pages/home.timeline.vue | 8 ++++++-- 6 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/client/app/desktop/views/components/timeline.core.vue b/src/client/app/desktop/views/components/timeline.core.vue index 254a5b9d6..3c7e87aea 100644 --- a/src/client/app/desktop/views/components/timeline.core.vue +++ b/src/client/app/desktop/views/components/timeline.core.vue @@ -120,12 +120,14 @@ export default Vue.extend({ this.moreFetching = true; - (this as any).api(this.endpoint, { + const promise = (this as any).api(this.endpoint, { limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, includeMyRenotes: (this as any).clientSettings.showMyRenotes, includeRenotedMyNotes: (this as any).clientSettings.showRenotedMyNotes - }).then(notes => { + }); + + promise.then(notes => { if (notes.length == fetchLimit + 1) { notes.pop(); } else { @@ -134,6 +136,8 @@ export default Vue.extend({ notes.forEach(n => (this.$refs.timeline as any).append(n)); this.moreFetching = false; }); + + return promise; }, onNote(note) { diff --git a/src/client/app/desktop/views/components/user-list-timeline.vue b/src/client/app/desktop/views/components/user-list-timeline.vue index 59d6abbbc..4f14da70f 100644 --- a/src/client/app/desktop/views/components/user-list-timeline.vue +++ b/src/client/app/desktop/views/components/user-list-timeline.vue @@ -62,13 +62,15 @@ export default Vue.extend({ more() { this.moreFetching = true; - (this as any).api('notes/user-list-timeline', { + const promise = (this as any).api('notes/user-list-timeline', { listId: this.list.id, limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, includeMyRenotes: (this as any).clientSettings.showMyRenotes, includeRenotedMyNotes: (this as any).clientSettings.showRenotedMyNotes - }).then(notes => { + }); + + promise.then(notes => { if (notes.length == fetchLimit + 1) { notes.pop(); } else { @@ -77,6 +79,8 @@ export default Vue.extend({ notes.forEach(n => (this.$refs.timeline as any).append(n)); this.moreFetching = false; }); + + return promise; }, onNote(note) { // Prepend a note diff --git a/src/client/app/desktop/views/pages/user/user.timeline.vue b/src/client/app/desktop/views/pages/user/user.timeline.vue index 576a28510..812b5b422 100644 --- a/src/client/app/desktop/views/pages/user/user.timeline.vue +++ b/src/client/app/desktop/views/pages/user/user.timeline.vue @@ -21,6 +21,7 @@ const fetchLimit = 10; export default Vue.extend({ props: ['user'], + data() { return { fetching: true, @@ -31,19 +32,23 @@ export default Vue.extend({ date: null }; }, + watch: { mode() { this.fetch(); } }, + mounted() { document.addEventListener('keydown', this.onDocumentKeydown); this.fetch(() => this.$emit('loaded')); }, + beforeDestroy() { document.removeEventListener('keydown', this.onDocumentKeydown); }, + methods: { onDocumentKeydown(e) { if (e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA') { @@ -52,6 +57,7 @@ export default Vue.extend({ } } }, + fetch(cb?) { this.fetching = true; (this.$refs.timeline as any).init(() => new Promise((res, rej) => { @@ -72,15 +78,19 @@ export default Vue.extend({ }, rej); })); }, + more() { this.moreFetching = true; - (this as any).api('users/notes', { + + const promise = (this as any).api('users/notes', { userId: this.user.id, limit: fetchLimit + 1, includeReplies: this.mode == 'with-replies', withMedia: this.mode == 'with-media', untilId: (this.$refs.timeline as any).tail().id - }).then(notes => { + }); + + promise.then(notes => { if (notes.length == fetchLimit + 1) { notes.pop(); } else { @@ -89,7 +99,10 @@ export default Vue.extend({ notes.forEach(n => (this.$refs.timeline as any).append(n)); this.moreFetching = false; }); + + return promise; }, + warp(date) { this.date = date; this.fetch(); 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 c0ba995b6..629151302 100644 --- a/src/client/app/mobile/views/components/user-list-timeline.vue +++ b/src/client/app/mobile/views/components/user-list-timeline.vue @@ -77,13 +77,15 @@ export default Vue.extend({ this.moreFetching = true; - (this as any).api('notes/user-list-timeline', { + const promise = (this as any).api('notes/user-list-timeline', { listId: this.list.id, limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, includeMyRenotes: (this as any).clientSettings.showMyRenotes, includeRenotedMyNotes: (this as any).clientSettings.showRenotedMyNotes - }).then(notes => { + }); + + promise.then(notes => { if (notes.length == fetchLimit + 1) { notes.pop(); } else { @@ -92,6 +94,8 @@ export default Vue.extend({ notes.forEach(n => (this.$refs.timeline as any).append(n)); this.moreFetching = false; }); + + return promise; }, onNote(note) { diff --git a/src/client/app/mobile/views/components/user-timeline.vue b/src/client/app/mobile/views/components/user-timeline.vue index aca6f783b..6be675c0a 100644 --- a/src/client/app/mobile/views/components/user-timeline.vue +++ b/src/client/app/mobile/views/components/user-timeline.vue @@ -59,12 +59,15 @@ export default Vue.extend({ if (!this.canFetchMore) return; this.moreFetching = true; - (this as any).api('users/notes', { + + const promise = (this as any).api('users/notes', { userId: this.user.id, withMedia: this.withMedia, limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id - }).then(notes => { + }); + + promise.then(notes => { if (notes.length == fetchLimit + 1) { notes.pop(); } else { @@ -73,6 +76,8 @@ export default Vue.extend({ notes.forEach(n => (this.$refs.timeline as any).append(n)); this.moreFetching = false; }); + + return promise; } } }); diff --git a/src/client/app/mobile/views/pages/home.timeline.vue b/src/client/app/mobile/views/pages/home.timeline.vue index 4c1c344db..9ebce53de 100644 --- a/src/client/app/mobile/views/pages/home.timeline.vue +++ b/src/client/app/mobile/views/pages/home.timeline.vue @@ -111,12 +111,14 @@ export default Vue.extend({ this.moreFetching = true; - (this as any).api(this.endpoint, { + const promise = (this as any).api(this.endpoint, { limit: fetchLimit + 1, untilId: (this.$refs.timeline as any).tail().id, includeMyRenotes: (this as any).clientSettings.showMyRenotes, includeRenotedMyNotes: (this as any).clientSettings.showRenotedMyNotes - }).then(notes => { + }); + + promise.then(notes => { if (notes.length == fetchLimit + 1) { notes.pop(); } else { @@ -125,6 +127,8 @@ export default Vue.extend({ notes.forEach(n => (this.$refs.timeline as any).append(n)); this.moreFetching = false; }); + + return promise; }, onNote(note) {