1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 22:38:30 +09:00

Improve usability

This commit is contained in:
syuilo 2018-10-08 15:42:21 +09:00
parent a70ced8e90
commit 1c2dbb914e
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69

View File

@ -48,6 +48,8 @@ export default Vue.extend({
},
mounted() {
window.addEventListener('scroll', this.onScroll, { passive: true });
this.connection = (this as any).os.stream.useSharedConnection('main');
this.connection.on('notification', this.onNotification);
@ -69,6 +71,7 @@ export default Vue.extend({
},
beforeDestroy() {
window.removeEventListener('scroll', this.onScroll);
this.connection.dispose();
},
@ -101,6 +104,18 @@ export default Vue.extend({
});
this.notifications.unshift(notification);
},
onScroll() {
if (this.$store.state.settings.fetchOnScroll !== false) {
// display none
// https://github.com/syuilo/misskey/issues/1569
// http://d.hatena.ne.jp/favril/20091105/1257403319
if (this.$el.offsetHeight == 0) return;
const current = window.scrollY + window.innerHeight;
if (current > document.body.offsetHeight - 8) this.fetchMoreNotifications();
}
}
}
});