@@ -8,12 +8,7 @@
%fa:R comments%%i18n:@empty%
-
-
-
+
@@ -22,7 +17,6 @@ import Vue from 'vue';
import { url } from '../../../config';
const fetchLimit = 10;
-const displayLimit = 30;
export default Vue.extend({
props: {
@@ -37,8 +31,6 @@ export default Vue.extend({
fetching: true,
moreFetching: false,
existMore: false,
- notes: [],
- queue: [],
connection: null,
connectionId: null,
date: null
@@ -67,7 +59,7 @@ export default Vue.extend({
},
canFetchMore(): boolean {
- return !this.moreFetching && !this.fetching && this.notes.length > 0 && this.existMore;
+ return !this.moreFetching && !this.fetching && this.existMore;
}
},
@@ -82,7 +74,6 @@ export default Vue.extend({
}
document.addEventListener('keydown', this.onKeydown);
- window.addEventListener('scroll', this.onScroll);
this.fetch();
},
@@ -96,7 +87,6 @@ export default Vue.extend({
this.stream.dispose(this.connectionId);
document.removeEventListener('keydown', this.onKeydown);
- window.removeEventListener('scroll', this.onScroll);
},
methods: {
@@ -105,7 +95,6 @@ export default Vue.extend({
},
fetch(cb?) {
- this.queue = [];
this.fetching = true;
(this as any).api(this.endpoint, {
@@ -118,7 +107,7 @@ export default Vue.extend({
notes.pop();
this.existMore = true;
}
- this.notes = notes;
+ (this.$refs.timeline as any).init(notes);
this.fetching = false;
this.$emit('loaded');
if (cb) cb();
@@ -132,7 +121,7 @@ export default Vue.extend({
(this as any).api(this.endpoint, {
limit: fetchLimit + 1,
- untilId: this.notes[this.notes.length - 1].id,
+ untilId: (this.$refs.timeline as any).tail().id,
includeMyRenotes: (this as any).os.i.clientSettings.showMyRenotes,
includeRenotedMyNotes: (this as any).os.i.clientSettings.showRenotedMyNotes
}).then(notes => {
@@ -141,33 +130,11 @@ export default Vue.extend({
} else {
this.existMore = false;
}
- this.notes = this.notes.concat(notes);
+ notes.forEach(n => (this.$refs.timeline as any).append(n));
this.moreFetching = false;
});
},
- prependNote(note, silent = false) {
- // サウンドを再生する
- if ((this as any).os.isEnableSounds && !silent) {
- const sound = new Audio(`${url}/assets/post.mp3`);
- sound.volume = localStorage.getItem('soundVolume') ? parseInt(localStorage.getItem('soundVolume'), 10) / 100 : 0.5;
- sound.play();
- }
-
- // Prepent a note
- this.notes.unshift(note);
-
- // オーバーフローしたら古い投稿は捨てる
- if (this.notes.length >= displayLimit) {
- this.notes = this.notes.slice(0, displayLimit);
- }
- },
-
- releaseQueue() {
- this.queue.forEach(n => this.prependNote(n, true));
- this.queue = [];
- },
-
onNote(note) {
//#region 弾く
const isMyNote = note.userId == (this as any).os.i.id;
@@ -186,11 +153,15 @@ export default Vue.extend({
}
//#endregion
- if (this.isScrollTop()) {
- this.prependNote(note);
- } else {
- this.queue.unshift(note);
+ // サウンドを再生する
+ if ((this as any).os.isEnableSounds) {
+ const sound = new Audio(`${url}/assets/post.mp3`);
+ sound.volume = localStorage.getItem('soundVolume') ? parseInt(localStorage.getItem('soundVolume'), 10) / 100 : 0.5;
+ sound.play();
}
+
+ // Prepend a note
+ (this.$refs.timeline as any).prepend(note);
},
onChangeFollowing() {
@@ -206,17 +177,6 @@ export default Vue.extend({
this.fetch();
},
- onScroll() {
- if ((this as any).os.i.clientSettings.fetchOnScroll !== false) {
- const current = window.scrollY + window.innerHeight;
- if (current > document.body.offsetHeight - 8) this.more();
- }
-
- if (this.isScrollTop()) {
- this.releaseQueue();
- }
- },
-
onKeydown(e) {
if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
if (e.which == 84) { // t
@@ -231,7 +191,7 @@ export default Vue.extend({