Fix bug
This commit is contained in:
parent
83c819a130
commit
e7d1b6ec00
|
@ -34,7 +34,6 @@ export default Vue.extend({
|
||||||
existMore: false,
|
existMore: false,
|
||||||
connection: null,
|
connection: null,
|
||||||
connectionId: null,
|
connectionId: null,
|
||||||
unreadCount: 0,
|
|
||||||
date: null
|
date: null
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -76,7 +75,6 @@ export default Vue.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener('keydown', this.onKeydown);
|
document.addEventListener('keydown', this.onKeydown);
|
||||||
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
|
|
||||||
|
|
||||||
this.fetch();
|
this.fetch();
|
||||||
},
|
},
|
||||||
|
@ -90,7 +88,6 @@ export default Vue.extend({
|
||||||
this.stream.dispose(this.connectionId);
|
this.stream.dispose(this.connectionId);
|
||||||
|
|
||||||
document.removeEventListener('keydown', this.onKeydown);
|
document.removeEventListener('keydown', this.onKeydown);
|
||||||
document.removeEventListener('visibilitychange', this.onVisibilitychange);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -141,11 +138,6 @@ export default Vue.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
onNote(note) {
|
onNote(note) {
|
||||||
if (document.hidden && note.userId !== (this as any).os.i.id) {
|
|
||||||
this.unreadCount++;
|
|
||||||
document.title = `(${this.unreadCount}) ${getNoteSummary(note)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepend a note
|
// Prepend a note
|
||||||
(this.$refs.timeline as any).prepend(note);
|
(this.$refs.timeline as any).prepend(note);
|
||||||
},
|
},
|
||||||
|
@ -163,13 +155,6 @@ export default Vue.extend({
|
||||||
this.fetch();
|
this.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
onVisibilitychange() {
|
|
||||||
if (!document.hidden) {
|
|
||||||
this.unreadCount = 0;
|
|
||||||
document.title = 'Misskey';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import Progress from '../../../common/scripts/loading';
|
import Progress from '../../../common/scripts/loading';
|
||||||
import getNoteSummary from '../../../../../renderers/get-note-summary';
|
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
|
@ -16,46 +15,14 @@ export default Vue.extend({
|
||||||
default: 'timeline'
|
default: 'timeline'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
connection: null,
|
|
||||||
connectionId: null,
|
|
||||||
unreadCount: 0
|
|
||||||
};
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
document.title = 'Misskey';
|
document.title = 'Misskey';
|
||||||
|
|
||||||
this.connection = (this as any).os.stream.getConnection();
|
|
||||||
this.connectionId = (this as any).os.stream.use();
|
|
||||||
|
|
||||||
this.connection.on('note', this.onStreamNote);
|
|
||||||
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
|
|
||||||
|
|
||||||
Progress.start();
|
Progress.start();
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
|
||||||
this.connection.off('note', this.onStreamNote);
|
|
||||||
(this as any).os.stream.dispose(this.connectionId);
|
|
||||||
document.removeEventListener('visibilitychange', this.onVisibilitychange);
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
loaded() {
|
loaded() {
|
||||||
Progress.done();
|
Progress.done();
|
||||||
},
|
|
||||||
|
|
||||||
onStreamNote(note) {
|
|
||||||
if (document.hidden && note.userId != (this as any).os.i.id) {
|
|
||||||
this.unreadCount++;
|
|
||||||
document.title = `(${this.unreadCount}) ${getNoteSummary(note)}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onVisibilitychange() {
|
|
||||||
if (!document.hidden) {
|
|
||||||
this.unreadCount = 0;
|
|
||||||
document.title = 'Misskey';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue