Improve usability
This commit is contained in:
parent
a70ced8e90
commit
1c2dbb914e
1 changed files with 15 additions and 0 deletions
|
@ -48,6 +48,8 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
|
window.addEventListener('scroll', this.onScroll, { passive: true });
|
||||||
|
|
||||||
this.connection = (this as any).os.stream.useSharedConnection('main');
|
this.connection = (this as any).os.stream.useSharedConnection('main');
|
||||||
|
|
||||||
this.connection.on('notification', this.onNotification);
|
this.connection.on('notification', this.onNotification);
|
||||||
|
@ -69,6 +71,7 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
window.removeEventListener('scroll', this.onScroll);
|
||||||
this.connection.dispose();
|
this.connection.dispose();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -101,6 +104,18 @@ export default Vue.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
this.notifications.unshift(notification);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue