1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-12-15 23:28:26 +09:00
This commit is contained in:
syuilo 2020-02-09 22:00:38 +09:00
parent ac5453232f
commit 7813c8a942
2 changed files with 15 additions and 6 deletions

View File

@ -27,6 +27,7 @@ export default Vue.extend({
data() { data() {
return { return {
connection: null, connection: null,
connection2: null,
pagination: null, pagination: null,
baseQuery: { baseQuery: {
includeMyRenotes: this.$store.state.settings.showMyRenotes, includeMyRenotes: this.$store.state.settings.showMyRenotes,
@ -40,6 +41,7 @@ export default Vue.extend({
created() { created() {
this.$once('hook:beforeDestroy', () => { this.$once('hook:beforeDestroy', () => {
this.connection.dispose(); this.connection.dispose();
if (this.connection2) this.connection2.dispose();
}); });
const prepend = note => { const prepend = note => {
@ -54,6 +56,12 @@ export default Vue.extend({
(this.$refs.tl as any).reload(); (this.$refs.tl as any).reload();
}; };
const onChangeFollowing = () => {
if (!this.$refs.tl.backed) {
this.$refs.tl.reload();
}
};
let endpoint; let endpoint;
if (this.src == 'antenna') { if (this.src == 'antenna') {
@ -67,13 +75,12 @@ export default Vue.extend({
this.connection.on('note', prepend); this.connection.on('note', prepend);
} else if (this.src == 'home') { } else if (this.src == 'home') {
endpoint = 'notes/timeline'; endpoint = 'notes/timeline';
const onChangeFollowing = () => {
this.fetch();
};
this.connection = this.$root.stream.useSharedConnection('homeTimeline'); this.connection = this.$root.stream.useSharedConnection('homeTimeline');
this.connection.on('note', prepend); this.connection.on('note', prepend);
this.connection.on('follow', onChangeFollowing);
this.connection.on('unfollow', onChangeFollowing); this.connection2 = this.$root.stream.useSharedConnection('main');
this.connection2.on('follow', onChangeFollowing);
this.connection2.on('unfollow', onChangeFollowing);
} else if (this.src == 'local') { } else if (this.src == 'local') {
endpoint = 'notes/local-timeline'; endpoint = 'notes/local-timeline';
this.connection = this.$root.stream.useSharedConnection('localTimeline'); this.connection = this.$root.stream.useSharedConnection('localTimeline');

View File

@ -8,7 +8,8 @@ export default (opts) => ({
fetching: true, fetching: true,
moreFetching: false, moreFetching: false,
inited: false, inited: false,
more: false more: false,
backed: false,
}; };
}, },
@ -78,6 +79,7 @@ export default (opts) => ({
async fetchMore() { async fetchMore() {
if (!this.more || this.moreFetching || this.items.length === 0) return; if (!this.more || this.moreFetching || this.items.length === 0) return;
this.moreFetching = true; this.moreFetching = true;
this.backed = true;
let params = typeof this.pagination.params === 'function' ? this.pagination.params(false) : this.pagination.params; let params = typeof this.pagination.params === 'function' ? this.pagination.params(false) : this.pagination.params;
if (params && params.then) params = await params; if (params && params.then) params = await params;
const endpoint = typeof this.pagination.endpoint === 'function' ? this.pagination.endpoint() : this.pagination.endpoint; const endpoint = typeof this.pagination.endpoint === 'function' ? this.pagination.endpoint() : this.pagination.endpoint;