mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-23 12:50:39 +01:00
Resolve #2935
This commit is contained in:
parent
b622946844
commit
e8de29ae79
5 changed files with 32 additions and 41 deletions
|
@ -38,7 +38,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import * as config from '../../../config';
|
import * as config from '../../../config';
|
||||||
import getNoteSummary from '../../../../../misc/get-note-summary';
|
|
||||||
|
|
||||||
import XNote from './note.vue';
|
import XNote from './note.vue';
|
||||||
|
|
||||||
|
@ -61,7 +60,6 @@ export default Vue.extend({
|
||||||
requestInitPromise: null as () => Promise<any[]>,
|
requestInitPromise: null as () => Promise<any[]>,
|
||||||
notes: [],
|
notes: [],
|
||||||
queue: [],
|
queue: [],
|
||||||
unreadCount: 0,
|
|
||||||
fetching: true,
|
fetching: true,
|
||||||
moreFetching: false
|
moreFetching: false
|
||||||
};
|
};
|
||||||
|
@ -80,12 +78,10 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
|
|
||||||
window.addEventListener('scroll', this.onScroll, { passive: true });
|
window.addEventListener('scroll', this.onScroll, { passive: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
document.removeEventListener('visibilitychange', this.onVisibilitychange);
|
|
||||||
window.removeEventListener('scroll', this.onScroll);
|
window.removeEventListener('scroll', this.onScroll);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -147,10 +143,9 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
// 投稿が自分のものではないかつ、タブが非表示またはスクロール位置が最上部ではないならタイトルで通知
|
// タブが非表示またはスクロール位置が最上部ではないならタイトルで通知
|
||||||
if ((document.hidden || !this.isScrollTop()) && note.userId !== this.$store.state.i.id) {
|
if (document.hidden || !this.isScrollTop()) {
|
||||||
this.unreadCount++;
|
this.$store.commit('pushBehindNote', note);
|
||||||
document.title = `(${this.unreadCount}) ${getNoteSummary(note)}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isScrollTop()) {
|
if (this.isScrollTop()) {
|
||||||
|
@ -195,21 +190,9 @@ export default Vue.extend({
|
||||||
this.moreFetching = false;
|
this.moreFetching = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
clearNotification() {
|
|
||||||
this.unreadCount = 0;
|
|
||||||
document.title = (this as any).os.instanceName;
|
|
||||||
},
|
|
||||||
|
|
||||||
onVisibilitychange() {
|
|
||||||
if (!document.hidden) {
|
|
||||||
this.clearNotification();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onScroll() {
|
onScroll() {
|
||||||
if (this.isScrollTop()) {
|
if (this.isScrollTop()) {
|
||||||
this.releaseQueue();
|
this.releaseQueue();
|
||||||
this.clearNotification();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.$store.state.settings.fetchOnScroll !== false) {
|
if (this.$store.state.settings.fetchOnScroll !== false) {
|
||||||
|
|
|
@ -154,6 +154,11 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
// タブが非表示またはスクロール位置が最上部ではないならタイトルで通知
|
||||||
|
if (document.hidden || !this.isScrollTop()) {
|
||||||
|
this.$store.commit('pushBehindNote', note);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.isScrollTop()) {
|
if (this.isScrollTop()) {
|
||||||
// Prepend the note
|
// Prepend the note
|
||||||
this.notes.unshift(note);
|
this.notes.unshift(note);
|
||||||
|
|
|
@ -161,6 +161,12 @@ export default (callback: (launch: (router: VueRouter, api?: (os: MiOS) => API)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.addEventListener('visibilitychange', () => {
|
||||||
|
if (!document.hidden) {
|
||||||
|
os.store.commit('clearBehindNotes');
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
Vue.mixin({
|
Vue.mixin({
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -37,7 +37,6 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import getNoteSummary from '../../../../../misc/get-note-summary';
|
|
||||||
|
|
||||||
const displayLimit = 30;
|
const displayLimit = 30;
|
||||||
|
|
||||||
|
@ -54,7 +53,6 @@ export default Vue.extend({
|
||||||
requestInitPromise: null as () => Promise<any[]>,
|
requestInitPromise: null as () => Promise<any[]>,
|
||||||
notes: [],
|
notes: [],
|
||||||
queue: [],
|
queue: [],
|
||||||
unreadCount: 0,
|
|
||||||
fetching: true,
|
fetching: true,
|
||||||
moreFetching: false
|
moreFetching: false
|
||||||
};
|
};
|
||||||
|
@ -83,12 +81,10 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
|
|
||||||
window.addEventListener('scroll', this.onScroll, { passive: true });
|
window.addEventListener('scroll', this.onScroll, { passive: true });
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
document.removeEventListener('visibilitychange', this.onVisibilitychange);
|
|
||||||
window.removeEventListener('scroll', this.onScroll);
|
window.removeEventListener('scroll', this.onScroll);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -146,10 +142,9 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
// 投稿が自分のものではないかつ、タブが非表示またはスクロール位置が最上部ではないならタイトルで通知
|
// タブが非表示またはスクロール位置が最上部ではないならタイトルで通知
|
||||||
if ((document.hidden || !this.isScrollTop()) && note.userId !== this.$store.state.i.id) {
|
if (document.hidden || !this.isScrollTop()) {
|
||||||
this.unreadCount++;
|
this.$store.commit('pushBehindNote', note);
|
||||||
document.title = `(${this.unreadCount}) ${getNoteSummary(note)}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isScrollTop()) {
|
if (this.isScrollTop()) {
|
||||||
|
@ -187,21 +182,9 @@ export default Vue.extend({
|
||||||
this.moreFetching = false;
|
this.moreFetching = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
clearNotification() {
|
|
||||||
this.unreadCount = 0;
|
|
||||||
document.title = (this as any).os.instanceName;
|
|
||||||
},
|
|
||||||
|
|
||||||
onVisibilitychange() {
|
|
||||||
if (!document.hidden) {
|
|
||||||
this.clearNotification();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onScroll() {
|
onScroll() {
|
||||||
if (this.isScrollTop()) {
|
if (this.isScrollTop()) {
|
||||||
this.releaseQueue();
|
this.releaseQueue();
|
||||||
this.clearNotification();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.$store.state.settings.fetchOnScroll !== false) {
|
if (this.$store.state.settings.fetchOnScroll !== false) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import * as nestedProperty from 'nested-property';
|
||||||
import MiOS from './mios';
|
import MiOS from './mios';
|
||||||
import { hostname } from './config';
|
import { hostname } from './config';
|
||||||
import { erase } from '../../prelude/array';
|
import { erase } from '../../prelude/array';
|
||||||
|
import getNoteSummary from '../../misc/get-note-summary';
|
||||||
|
|
||||||
const defaultSettings = {
|
const defaultSettings = {
|
||||||
home: null,
|
home: null,
|
||||||
|
@ -73,7 +74,8 @@ export default (os: MiOS) => new Vuex.Store({
|
||||||
i: null,
|
i: null,
|
||||||
indicate: false,
|
indicate: false,
|
||||||
uiHeaderHeight: 0,
|
uiHeaderHeight: 0,
|
||||||
navHook: null
|
navHook: null,
|
||||||
|
behindNotes: []
|
||||||
},
|
},
|
||||||
|
|
||||||
getters: {
|
getters: {
|
||||||
|
@ -99,6 +101,18 @@ export default (os: MiOS) => new Vuex.Store({
|
||||||
|
|
||||||
navHook(state, callback) {
|
navHook(state, callback) {
|
||||||
state.navHook = callback;
|
state.navHook = callback;
|
||||||
|
},
|
||||||
|
|
||||||
|
pushBehindNote(state, note) {
|
||||||
|
if (note.userId === state.i.id) return;
|
||||||
|
if (state.behindNotes.some(n => n.id === note.id)) return;
|
||||||
|
state.behindNotes.push(note);
|
||||||
|
document.title = `(${state.behindNotes.length}) ${getNoteSummary(note)}`;
|
||||||
|
},
|
||||||
|
|
||||||
|
clearBehindNotes(state) {
|
||||||
|
state.behindNotes = [];
|
||||||
|
document.title = os.instanceName;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue