2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2020-02-18 20:08:35 +01:00
|
|
|
<x-notes ref="tl" :pagination="pagination" @before="$emit('before')" @after="e => $emit('after', e)" @queue="$emit('queue', $event)"/>
|
2020-01-29 20:37:25 +01:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import XNotes from './notes.vue';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
components: {
|
|
|
|
XNotes
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
src: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
list: {
|
2020-07-11 03:13:11 +02:00
|
|
|
type: String,
|
2020-01-29 20:37:25 +01:00
|
|
|
required: false
|
|
|
|
},
|
|
|
|
antenna: {
|
2020-07-11 03:13:11 +02:00
|
|
|
type: String,
|
2020-01-29 20:37:25 +01:00
|
|
|
required: false
|
2020-02-19 18:40:53 +01:00
|
|
|
},
|
2020-08-18 15:44:21 +02:00
|
|
|
channel: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
2020-02-19 18:40:53 +01:00
|
|
|
sound: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-08-18 15:44:21 +02:00
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
inChannel: this.src === 'channel'
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
connection: null,
|
2020-02-09 14:00:38 +01:00
|
|
|
connection2: null,
|
2020-01-29 20:37:25 +01:00
|
|
|
pagination: null,
|
|
|
|
baseQuery: {
|
|
|
|
includeMyRenotes: this.$store.state.settings.showMyRenotes,
|
|
|
|
includeRenotedMyNotes: this.$store.state.settings.showRenotedMyNotes,
|
|
|
|
includeLocalRenotes: this.$store.state.settings.showLocalRenotes
|
|
|
|
},
|
|
|
|
query: {},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
this.$once('hook:beforeDestroy', () => {
|
|
|
|
this.connection.dispose();
|
2020-02-09 14:00:38 +01:00
|
|
|
if (this.connection2) this.connection2.dispose();
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
const prepend = note => {
|
2020-07-27 01:46:21 +02:00
|
|
|
(this.$refs.tl as any).prepend(note);
|
2020-02-19 18:40:53 +01:00
|
|
|
|
2020-07-11 03:13:11 +02:00
|
|
|
this.$emit('note');
|
|
|
|
|
2020-02-19 18:40:53 +01:00
|
|
|
if (this.sound) {
|
2020-02-19 22:08:49 +01:00
|
|
|
this.$root.sound(note.userId === this.$store.state.i.id ? 'noteMy' : 'note');
|
2020-02-19 18:40:53 +01:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const onUserAdded = () => {
|
|
|
|
(this.$refs.tl as any).reload();
|
|
|
|
};
|
|
|
|
|
|
|
|
const onUserRemoved = () => {
|
|
|
|
(this.$refs.tl as any).reload();
|
|
|
|
};
|
|
|
|
|
2020-02-09 14:00:38 +01:00
|
|
|
const onChangeFollowing = () => {
|
|
|
|
if (!this.$refs.tl.backed) {
|
|
|
|
this.$refs.tl.reload();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
let endpoint;
|
|
|
|
|
|
|
|
if (this.src == 'antenna') {
|
|
|
|
endpoint = 'antennas/notes';
|
|
|
|
this.query = {
|
2020-07-11 03:13:11 +02:00
|
|
|
antennaId: this.antenna
|
2020-01-29 20:37:25 +01:00
|
|
|
};
|
|
|
|
this.connection = this.$root.stream.connectToChannel('antenna', {
|
2020-07-11 03:13:11 +02:00
|
|
|
antennaId: this.antenna
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
this.connection.on('note', prepend);
|
|
|
|
} else if (this.src == 'home') {
|
|
|
|
endpoint = 'notes/timeline';
|
|
|
|
this.connection = this.$root.stream.useSharedConnection('homeTimeline');
|
|
|
|
this.connection.on('note', prepend);
|
2020-02-09 14:00:38 +01:00
|
|
|
|
|
|
|
this.connection2 = this.$root.stream.useSharedConnection('main');
|
|
|
|
this.connection2.on('follow', onChangeFollowing);
|
|
|
|
this.connection2.on('unfollow', onChangeFollowing);
|
2020-01-29 20:37:25 +01:00
|
|
|
} else if (this.src == 'local') {
|
|
|
|
endpoint = 'notes/local-timeline';
|
|
|
|
this.connection = this.$root.stream.useSharedConnection('localTimeline');
|
|
|
|
this.connection.on('note', prepend);
|
|
|
|
} else if (this.src == 'social') {
|
|
|
|
endpoint = 'notes/hybrid-timeline';
|
|
|
|
this.connection = this.$root.stream.useSharedConnection('hybridTimeline');
|
|
|
|
this.connection.on('note', prepend);
|
|
|
|
} else if (this.src == 'global') {
|
|
|
|
endpoint = 'notes/global-timeline';
|
|
|
|
this.connection = this.$root.stream.useSharedConnection('globalTimeline');
|
|
|
|
this.connection.on('note', prepend);
|
|
|
|
} else if (this.src == 'list') {
|
|
|
|
endpoint = 'notes/user-list-timeline';
|
|
|
|
this.query = {
|
2020-07-11 03:13:11 +02:00
|
|
|
listId: this.list
|
2020-01-29 20:37:25 +01:00
|
|
|
};
|
|
|
|
this.connection = this.$root.stream.connectToChannel('userList', {
|
2020-07-11 03:13:11 +02:00
|
|
|
listId: this.list
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
this.connection.on('note', prepend);
|
|
|
|
this.connection.on('userAdded', onUserAdded);
|
|
|
|
this.connection.on('userRemoved', onUserRemoved);
|
2020-08-18 15:44:21 +02:00
|
|
|
} else if (this.src == 'channel') {
|
|
|
|
endpoint = 'channels/timeline';
|
|
|
|
this.query = {
|
|
|
|
channelId: this.channel
|
|
|
|
};
|
|
|
|
this.connection = this.$root.stream.connectToChannel('channel', {
|
|
|
|
channelId: this.channel
|
|
|
|
});
|
|
|
|
this.connection.on('note', prepend);
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.pagination = {
|
|
|
|
endpoint: endpoint,
|
|
|
|
limit: 10,
|
|
|
|
params: init => ({
|
|
|
|
untilDate: init ? undefined : (this.date ? this.date.getTime() : undefined),
|
|
|
|
...this.baseQuery, ...this.query
|
|
|
|
})
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
focus() {
|
|
|
|
this.$refs.tl.focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|