This commit is contained in:
syuilo
2018-04-26 14:38:37 +09:00
parent 6ab0c386cb
commit 03d09e9d24
13 changed files with 233 additions and 47 deletions

View File

@ -31,6 +31,7 @@
<script lang="ts">
import Vue from 'vue';
import { url } from '../../../config';
import getNoteSummary from '../../../../../renderers/get-note-summary';
import XNote from './notes.note.vue';
@ -53,6 +54,7 @@ export default Vue.extend({
requestInitPromise: null as () => Promise<any[]>,
notes: [],
queue: [],
unreadCount: 0,
fetching: true,
moreFetching: false
};
@ -71,10 +73,12 @@ export default Vue.extend({
},
mounted() {
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
window.addEventListener('scroll', this.onScroll);
},
beforeDestroy() {
document.removeEventListener('visibilitychange', this.onVisibilitychange);
window.removeEventListener('scroll', this.onScroll);
},
@ -130,6 +134,12 @@ export default Vue.extend({
}
//#endregion
// 投稿が自分のものではないかつ、タブが非表示またはスクロール位置が最上部ではないならタイトルで通知
if ((document.hidden || !this.isScrollTop()) && note.userId !== (this as any).os.i.id) {
this.unreadCount++;
document.title = `(${this.unreadCount}) ${getNoteSummary(note)}`;
}
if (this.isScrollTop()) {
// Prepend the note
this.notes.unshift(note);
@ -172,9 +182,21 @@ export default Vue.extend({
this.moreFetching = false;
},
clearNotification() {
this.unreadCount = 0;
document.title = 'Misskey';
},
onVisibilitychange() {
if (!document.hidden) {
this.clearNotification();
}
},
onScroll() {
if (this.isScrollTop()) {
this.releaseQueue();
this.clearNotification();
}
if ((this as any).os.i.clientSettings.fetchOnScroll !== false) {