mirror of
https://github.com/misskey-dev/misskey
synced 2024-11-29 23:38:55 +09:00
✌️
This commit is contained in:
parent
98f3dea20d
commit
a0a2cecc73
@ -29,15 +29,16 @@ export default Vue.extend({
|
|||||||
notes: [],
|
notes: [],
|
||||||
connection: null,
|
connection: null,
|
||||||
connectionId: null,
|
connectionId: null,
|
||||||
date: null,
|
date: null
|
||||||
isTop: true
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
alone(): boolean {
|
alone(): boolean {
|
||||||
return (this as any).os.i.followingCount == 0;
|
return (this as any).os.i.followingCount == 0;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.connection = (this as any).os.stream.getConnection();
|
this.connection = (this as any).os.stream.getConnection();
|
||||||
this.connectionId = (this as any).os.stream.use();
|
this.connectionId = (this as any).os.stream.use();
|
||||||
@ -51,6 +52,7 @@ export default Vue.extend({
|
|||||||
|
|
||||||
this.fetch();
|
this.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.connection.off('note', this.onNote);
|
this.connection.off('note', this.onNote);
|
||||||
this.connection.off('follow', this.onChangeFollowing);
|
this.connection.off('follow', this.onChangeFollowing);
|
||||||
@ -60,6 +62,7 @@ export default Vue.extend({
|
|||||||
document.removeEventListener('keydown', this.onKeydown);
|
document.removeEventListener('keydown', this.onKeydown);
|
||||||
window.removeEventListener('scroll', this.onScroll);
|
window.removeEventListener('scroll', this.onScroll);
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
fetch(cb?) {
|
fetch(cb?) {
|
||||||
this.fetching = true;
|
this.fetching = true;
|
||||||
@ -78,6 +81,7 @@ export default Vue.extend({
|
|||||||
if (cb) cb();
|
if (cb) cb();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
more() {
|
more() {
|
||||||
if (this.moreFetching || this.fetching || this.notes.length == 0 || !this.existMore) return;
|
if (this.moreFetching || this.fetching || this.notes.length == 0 || !this.existMore) return;
|
||||||
this.moreFetching = true;
|
this.moreFetching = true;
|
||||||
@ -94,6 +98,7 @@ export default Vue.extend({
|
|||||||
this.moreFetching = false;
|
this.moreFetching = false;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onNote(note) {
|
onNote(note) {
|
||||||
// サウンドを再生する
|
// サウンドを再生する
|
||||||
if ((this as any).os.isEnableSounds) {
|
if ((this as any).os.isEnableSounds) {
|
||||||
@ -102,19 +107,23 @@ export default Vue.extend({
|
|||||||
sound.play();
|
sound.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isTop) this.notes.pop();
|
|
||||||
this.notes.unshift(note);
|
this.notes.unshift(note);
|
||||||
|
|
||||||
|
const isTop = window.scrollY > 8;
|
||||||
|
if (isTop) this.notes.pop();
|
||||||
},
|
},
|
||||||
|
|
||||||
onChangeFollowing() {
|
onChangeFollowing() {
|
||||||
this.fetch();
|
this.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
onScroll() {
|
onScroll() {
|
||||||
if ((this as any).os.i.clientSettings.fetchOnScroll !== false) {
|
if ((this as any).os.i.clientSettings.fetchOnScroll !== false) {
|
||||||
const current = window.scrollY + window.innerHeight;
|
const current = window.scrollY + window.innerHeight;
|
||||||
if (current > document.body.offsetHeight - 8) this.more();
|
if (current > document.body.offsetHeight - 8) this.more();
|
||||||
}
|
}
|
||||||
this.isTop = window.scrollY < 100;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onKeydown(e) {
|
onKeydown(e) {
|
||||||
if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
|
if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
|
||||||
if (e.which == 84) { // t
|
if (e.which == 84) { // t
|
||||||
@ -122,6 +131,7 @@ export default Vue.extend({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
warp(date) {
|
warp(date) {
|
||||||
this.date = date;
|
this.date = date;
|
||||||
this.fetch();
|
this.fetch();
|
||||||
|
@ -37,8 +37,7 @@ export default Vue.extend({
|
|||||||
notes: [],
|
notes: [],
|
||||||
existMore: false,
|
existMore: false,
|
||||||
connection: null,
|
connection: null,
|
||||||
connectionId: null,
|
connectionId: null
|
||||||
isTop: true
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -54,18 +53,13 @@ export default Vue.extend({
|
|||||||
this.connection.on('follow', this.onChangeFollowing);
|
this.connection.on('follow', this.onChangeFollowing);
|
||||||
this.connection.on('unfollow', this.onChangeFollowing);
|
this.connection.on('unfollow', this.onChangeFollowing);
|
||||||
|
|
||||||
window.addEventListener('scroll', this.onScroll);
|
this.fetch();
|
||||||
|
|
||||||
this.fetch();
|
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.connection.off('note', this.onNote);
|
this.connection.off('note', this.onNote);
|
||||||
this.connection.off('follow', this.onChangeFollowing);
|
this.connection.off('follow', this.onChangeFollowing);
|
||||||
this.connection.off('unfollow', this.onChangeFollowing);
|
this.connection.off('unfollow', this.onChangeFollowing);
|
||||||
this.connection.off('unfollow', this.onChangeFollowing);
|
|
||||||
(this as any).os.stream.dispose(this.connectionId);
|
(this as any).os.stream.dispose(this.connectionId);
|
||||||
|
|
||||||
window.removeEventListener('scroll', this.onScroll);
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetch(cb?) {
|
fetch(cb?) {
|
||||||
@ -101,18 +95,13 @@ export default Vue.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onNote(note) {
|
onNote(note) {
|
||||||
this.isTop = window.scrollY < 100;
|
this.notes.unshift(note);
|
||||||
|
|
||||||
|
const isTop = window.scrollY > 8;
|
||||||
|
if (isTop) this.notes.pop();
|
||||||
},
|
},
|
||||||
onChangeFollowing() {
|
onChangeFollowing() {
|
||||||
this.fetch();
|
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 (window.scrollY > 100) this.isTop = false;
|
|
||||||
else this.isTop = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user