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