wip
This commit is contained in:
parent
bc8a0083e2
commit
6ab0c386cb
6 changed files with 432 additions and 326 deletions
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
<script lang="ts">
|
||||
import Vue from 'vue';
|
||||
import getNoteSummary from '../../../../../renderers/get-note-summary';
|
||||
|
||||
const fetchLimit = 10;
|
||||
|
||||
|
|
@ -33,6 +34,7 @@ export default Vue.extend({
|
|||
existMore: false,
|
||||
connection: null,
|
||||
connectionId: null,
|
||||
unreadCount: 0,
|
||||
date: null
|
||||
};
|
||||
},
|
||||
|
|
@ -74,6 +76,7 @@ export default Vue.extend({
|
|||
}
|
||||
|
||||
document.addEventListener('keydown', this.onKeydown);
|
||||
document.addEventListener('visibilitychange', this.onVisibilitychange, false);
|
||||
|
||||
this.fetch();
|
||||
},
|
||||
|
|
@ -87,10 +90,11 @@ export default Vue.extend({
|
|||
this.stream.dispose(this.connectionId);
|
||||
|
||||
document.removeEventListener('keydown', this.onKeydown);
|
||||
document.removeEventListener('visibilitychange', this.onVisibilitychange);
|
||||
},
|
||||
|
||||
methods: {
|
||||
fetch(cb?) {
|
||||
fetch() {
|
||||
this.fetching = true;
|
||||
|
||||
(this.$refs.timeline as any).init(() => new Promise((res, rej) => {
|
||||
|
|
@ -107,7 +111,6 @@ export default Vue.extend({
|
|||
res(notes);
|
||||
this.fetching = false;
|
||||
this.$emit('loaded');
|
||||
if (cb) cb();
|
||||
}, rej);
|
||||
}));
|
||||
},
|
||||
|
|
@ -134,6 +137,11 @@ export default Vue.extend({
|
|||
},
|
||||
|
||||
onNote(note) {
|
||||
if (document.hidden && note.userId !== (this as any).os.i.id) {
|
||||
this.unreadCount++;
|
||||
document.title = `(${this.unreadCount}) ${getNoteSummary(note)}`;
|
||||
}
|
||||
|
||||
// Prepend a note
|
||||
(this.$refs.timeline as any).prepend(note);
|
||||
},
|
||||
|
|
@ -151,13 +159,20 @@ export default Vue.extend({
|
|||
this.fetch();
|
||||
},
|
||||
|
||||
onVisibilitychange() {
|
||||
if (!document.hidden) {
|
||||
this.unreadCount = 0;
|
||||
document.title = 'Misskey';
|
||||
}
|
||||
},
|
||||
|
||||
onKeydown(e) {
|
||||
if (e.target.tagName != 'INPUT' && e.target.tagName != 'TEXTAREA') {
|
||||
if (e.which == 84) { // t
|
||||
this.focus();
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue