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