2021-02-14 22:26:07 +09:00
|
|
|
<template>
|
2021-02-20 22:28:53 +09:00
|
|
|
<div class="dbiokgaf info" v-if="date">
|
|
|
|
<MkInfo>{{ $ts.showingPastTimeline }} <button class="_textButton clear" @click="timetravel()">{{ $ts.clear }}</button></MkInfo>
|
|
|
|
</div>
|
2021-02-20 20:20:05 +09:00
|
|
|
<div class="dbiokgaf top" v-if="['home', 'local', 'social', 'global'].includes(src)">
|
|
|
|
<XPostForm/>
|
|
|
|
</div>
|
|
|
|
<div class="dbiokgaf tl" ref="body">
|
2021-02-16 18:21:44 +09:00
|
|
|
<div class="new" v-if="queue > 0" :style="{ width: width + 'px', [pagination.reversed ? 'bottom' : 'top']: pagination.reversed ? bottom + 'px' : top + 'px' }"><button class="_buttonPrimary" @click="goTop()">{{ $ts.newNoteRecived }}</button></div>
|
|
|
|
<XNotes class="tl" ref="tl" :pagination="pagination" @queue="queueUpdated" v-follow="pagination.reversed"/>
|
|
|
|
</div>
|
2021-02-20 20:20:05 +09:00
|
|
|
<div class="dbiokgaf bottom" v-if="src === 'channel'">
|
|
|
|
<div class="typers" v-if="typers.length > 0">
|
|
|
|
<I18n :src="$ts.typingUsers" text-tag="span" class="users">
|
|
|
|
<template #users>
|
|
|
|
<b v-for="user in typers" :key="user.id" class="user">{{ user.username }}</b>
|
|
|
|
</template>
|
|
|
|
</I18n>
|
|
|
|
<MkEllipsis/>
|
|
|
|
</div>
|
|
|
|
<XPostForm :channel="channel"/>
|
|
|
|
</div>
|
2021-02-14 22:26:07 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineComponent } from 'vue';
|
|
|
|
import XNotes from './notes.vue';
|
2021-03-23 17:30:14 +09:00
|
|
|
import * as os from '@client/os';
|
|
|
|
import * as sound from '@client/scripts/sound';
|
|
|
|
import { scrollToBottom, getScrollPosition, getScrollContainer } from '@client/scripts/scroll';
|
|
|
|
import follow from '@client/directives/follow-append';
|
2021-02-20 20:20:05 +09:00
|
|
|
import XPostForm from './post-form.vue';
|
2021-03-23 17:30:14 +09:00
|
|
|
import MkInfo from '@client/components/ui/info.vue';
|
2021-02-14 22:26:07 +09:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2021-02-20 20:20:05 +09:00
|
|
|
XNotes,
|
|
|
|
XPostForm,
|
2021-02-20 22:28:53 +09:00
|
|
|
MkInfo,
|
2021-02-14 22:26:07 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
directives: {
|
|
|
|
follow
|
|
|
|
},
|
|
|
|
|
|
|
|
provide() {
|
|
|
|
return {
|
|
|
|
inChannel: this.src === 'channel'
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
src: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
antenna: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
channel: {
|
|
|
|
type: String,
|
|
|
|
required: false
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
emits: ['note', 'queue', 'before', 'after'],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
connection: null,
|
|
|
|
connection2: null,
|
|
|
|
pagination: null,
|
|
|
|
baseQuery: {
|
|
|
|
includeMyRenotes: this.$store.state.showMyRenotes,
|
|
|
|
includeRenotedMyNotes: this.$store.state.showRenotedMyNotes,
|
|
|
|
includeLocalRenotes: this.$store.state.showLocalRenotes
|
|
|
|
},
|
|
|
|
query: {},
|
2021-02-16 18:21:44 +09:00
|
|
|
queue: 0,
|
|
|
|
width: 0,
|
|
|
|
top: 0,
|
|
|
|
bottom: 0,
|
2021-02-20 20:20:05 +09:00
|
|
|
typers: [],
|
2021-02-20 22:28:53 +09:00
|
|
|
date: null
|
2021-02-14 22:26:07 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
|
|
|
const prepend = note => {
|
|
|
|
(this.$refs.tl as any).prepend(note);
|
|
|
|
|
|
|
|
this.$emit('note');
|
|
|
|
|
2021-02-20 21:06:26 +09:00
|
|
|
sound.play(note.userId === this.$i.id ? 'noteMy' : 'note');
|
2021-02-14 22:26:07 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
const onUserAdded = () => {
|
|
|
|
(this.$refs.tl as any).reload();
|
|
|
|
};
|
|
|
|
|
|
|
|
const onUserRemoved = () => {
|
|
|
|
(this.$refs.tl as any).reload();
|
|
|
|
};
|
|
|
|
|
|
|
|
const onChangeFollowing = () => {
|
|
|
|
if (!this.$refs.tl.backed) {
|
|
|
|
this.$refs.tl.reload();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
let endpoint;
|
|
|
|
let reversed = false;
|
|
|
|
|
|
|
|
if (this.src == 'antenna') {
|
|
|
|
endpoint = 'antennas/notes';
|
|
|
|
this.query = {
|
|
|
|
antennaId: this.antenna
|
|
|
|
};
|
2021-05-27 17:15:08 +09:00
|
|
|
this.connection = os.stream.useChannel('antenna', {
|
2021-02-14 22:26:07 +09:00
|
|
|
antennaId: this.antenna
|
|
|
|
});
|
|
|
|
this.connection.on('note', prepend);
|
|
|
|
} else if (this.src == 'home') {
|
|
|
|
endpoint = 'notes/timeline';
|
2021-05-27 17:15:08 +09:00
|
|
|
this.connection = os.stream.useChannel('homeTimeline');
|
2021-02-14 22:26:07 +09:00
|
|
|
this.connection.on('note', prepend);
|
|
|
|
|
2021-05-27 17:15:08 +09:00
|
|
|
this.connection2 = os.stream.useChannel('main');
|
2021-02-14 22:26:07 +09:00
|
|
|
this.connection2.on('follow', onChangeFollowing);
|
|
|
|
this.connection2.on('unfollow', onChangeFollowing);
|
|
|
|
} else if (this.src == 'local') {
|
|
|
|
endpoint = 'notes/local-timeline';
|
2021-05-27 17:15:08 +09:00
|
|
|
this.connection = os.stream.useChannel('localTimeline');
|
2021-02-14 22:26:07 +09:00
|
|
|
this.connection.on('note', prepend);
|
|
|
|
} else if (this.src == 'social') {
|
|
|
|
endpoint = 'notes/hybrid-timeline';
|
2021-05-27 17:15:08 +09:00
|
|
|
this.connection = os.stream.useChannel('hybridTimeline');
|
2021-02-14 22:26:07 +09:00
|
|
|
this.connection.on('note', prepend);
|
|
|
|
} else if (this.src == 'global') {
|
|
|
|
endpoint = 'notes/global-timeline';
|
2021-05-27 17:15:08 +09:00
|
|
|
this.connection = os.stream.useChannel('globalTimeline');
|
2021-02-14 22:26:07 +09:00
|
|
|
this.connection.on('note', prepend);
|
|
|
|
} else if (this.src == 'mentions') {
|
|
|
|
endpoint = 'notes/mentions';
|
2021-05-27 17:15:08 +09:00
|
|
|
this.connection = os.stream.useChannel('main');
|
2021-02-14 22:26:07 +09: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-05-27 17:15:08 +09:00
|
|
|
this.connection = os.stream.useChannel('main');
|
2021-02-14 22:26:07 +09:00
|
|
|
this.connection.on('mention', onNote);
|
|
|
|
} else if (this.src == 'list') {
|
|
|
|
endpoint = 'notes/user-list-timeline';
|
|
|
|
this.query = {
|
|
|
|
listId: this.list
|
|
|
|
};
|
2021-05-27 17:15:08 +09:00
|
|
|
this.connection = os.stream.useChannel('userList', {
|
2021-02-14 22:26:07 +09:00
|
|
|
listId: this.list
|
|
|
|
});
|
|
|
|
this.connection.on('note', prepend);
|
|
|
|
this.connection.on('userAdded', onUserAdded);
|
|
|
|
this.connection.on('userRemoved', onUserRemoved);
|
|
|
|
} else if (this.src == 'channel') {
|
|
|
|
endpoint = 'channels/timeline';
|
|
|
|
reversed = true;
|
|
|
|
this.query = {
|
|
|
|
channelId: this.channel
|
|
|
|
};
|
2021-05-27 17:15:08 +09:00
|
|
|
this.connection = os.stream.useChannel('channel', {
|
2021-02-14 22:26:07 +09:00
|
|
|
channelId: this.channel
|
|
|
|
});
|
|
|
|
this.connection.on('note', prepend);
|
2021-02-20 20:20:05 +09:00
|
|
|
this.connection.on('typers', typers => {
|
|
|
|
this.typers = this.$i ? typers.filter(u => u.id !== this.$i.id) : typers;
|
|
|
|
});
|
2021-02-14 22:26:07 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
this.pagination = {
|
|
|
|
endpoint: endpoint,
|
|
|
|
reversed,
|
|
|
|
limit: 10,
|
|
|
|
params: init => ({
|
2021-02-20 22:28:53 +09:00
|
|
|
untilDate: this.date?.getTime(),
|
2021-02-14 22:26:07 +09:00
|
|
|
...this.baseQuery, ...this.query
|
|
|
|
})
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
beforeUnmount() {
|
|
|
|
this.connection.dispose();
|
|
|
|
if (this.connection2) this.connection2.dispose();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
focus() {
|
2021-02-20 20:20:05 +09:00
|
|
|
this.$refs.body.focus();
|
2021-02-14 22:26:07 +09:00
|
|
|
},
|
2021-02-16 18:21:44 +09:00
|
|
|
|
|
|
|
goTop() {
|
2021-02-20 20:20:05 +09:00
|
|
|
const container = getScrollContainer(this.$refs.body);
|
2021-02-16 18:21:44 +09:00
|
|
|
container.scrollTop = 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
queueUpdated(q) {
|
2021-02-20 20:20:05 +09:00
|
|
|
if (this.$refs.body.offsetWidth !== 0) {
|
|
|
|
const rect = this.$refs.body.getBoundingClientRect();
|
|
|
|
this.width = this.$refs.body.offsetWidth;
|
2021-02-20 21:02:59 +09:00
|
|
|
this.top = rect.top;
|
2021-02-20 20:20:05 +09:00
|
|
|
this.bottom = this.$refs.body.offsetHeight;
|
2021-02-16 18:21:44 +09:00
|
|
|
}
|
|
|
|
this.queue = q;
|
|
|
|
},
|
2021-02-20 22:28:53 +09:00
|
|
|
|
|
|
|
timetravel(date?: Date) {
|
|
|
|
this.date = date;
|
|
|
|
this.$refs.tl.reload();
|
|
|
|
}
|
2021-02-14 22:26:07 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2021-02-15 17:17:19 +09:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-02-20 22:28:53 +09:00
|
|
|
.dbiokgaf.info{
|
|
|
|
padding: 16px 16px 0 16px;
|
|
|
|
}
|
|
|
|
|
2021-02-20 20:20:05 +09:00
|
|
|
.dbiokgaf.top {
|
|
|
|
padding: 16px 16px 0 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.dbiokgaf.bottom {
|
|
|
|
padding: 0 16px 16px 16px;
|
|
|
|
position: relative;
|
2021-02-16 13:13:42 +09:00
|
|
|
|
2021-02-20 20:20:05 +09:00
|
|
|
> .typers {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 100%;
|
|
|
|
padding: 0 8px 0 8px;
|
|
|
|
font-size: 0.9em;
|
|
|
|
background: var(--panel);
|
|
|
|
border-radius: 0 8px 0 0;
|
|
|
|
color: var(--fgTransparentWeak);
|
|
|
|
|
|
|
|
> .users {
|
|
|
|
> .user + .user:before {
|
|
|
|
content: ", ";
|
|
|
|
font-weight: normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .user:last-of-type:after {
|
|
|
|
content: " ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.dbiokgaf.tl {
|
2021-02-20 21:02:59 +09:00
|
|
|
position: relative;
|
2021-02-20 20:20:05 +09:00
|
|
|
padding: 16px 0;
|
|
|
|
flex: 1;
|
|
|
|
min-width: 0;
|
|
|
|
overflow: auto;
|
2021-02-16 18:21:44 +09:00
|
|
|
|
|
|
|
> .new {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
display: block;
|
|
|
|
margin: 16px auto;
|
|
|
|
padding: 8px 16px;
|
|
|
|
border-radius: 32px;
|
|
|
|
}
|
|
|
|
}
|
2021-02-15 17:17:19 +09:00
|
|
|
}
|
|
|
|
</style>
|