2020-01-29 19:37:25 +00:00
|
|
|
<template>
|
2020-12-29 02:33:21 +00:00
|
|
|
<div class="cmuxhskf" v-hotkey.global="keymap">
|
2020-12-26 01:47:36 +00:00
|
|
|
<div class="new" v-if="queue > 0" :style="{ width: width + 'px' }"><button class="_buttonPrimary" @click="top()">{{ $ts.newNoteRecived }}</button></div>
|
2020-02-18 19:08:35 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
<div class="_section">
|
2020-12-19 01:55:52 +00:00
|
|
|
<XTutorial v-if="$store.reactiveState.tutorial.value != -1" class="tutorial _content _vMargin"/>
|
|
|
|
<XPostForm v-if="$store.reactiveState.showFixedPostForm.value" class="post-form _panel _content _vMargin" fixed/>
|
2020-12-29 02:33:21 +00:00
|
|
|
<div class="tabs _panel _vMargin">
|
|
|
|
<div class="left">
|
|
|
|
<button class="_button tab" @click="() => { src = 'home'; saveSrc(); }" :class="{ active: src === 'home' }" v-tooltip="$ts._timelines.home"><Fa :icon="faHome"/></button>
|
2020-12-29 07:58:14 +00:00
|
|
|
<button class="_button tab" @click="() => { src = 'local'; saveSrc(); }" :class="{ active: src === 'local' }" v-tooltip="$ts._timelines.local" v-if="isLocalTimelineAvailable"><Fa :icon="faComments"/></button>
|
|
|
|
<button class="_button tab" @click="() => { src = 'social'; saveSrc(); }" :class="{ active: src === 'social' }" v-tooltip="$ts._timelines.social" v-if="isLocalTimelineAvailable"><Fa :icon="faShareAlt"/></button>
|
|
|
|
<button class="_button tab" @click="() => { src = 'global'; saveSrc(); }" :class="{ active: src === 'global' }" v-tooltip="$ts._timelines.global" v-if="isGlobalTimelineAvailable"><Fa :icon="faGlobe"/></button>
|
2020-12-29 08:11:12 +00:00
|
|
|
<span class="divider"></span>
|
|
|
|
<button class="_button tab" @click="() => { src = 'mentions'; saveSrc(); }" :class="{ active: src === 'mentions' }" v-tooltip="$ts.mentions"><Fa :icon="faAt"/><Fa :icon="faCircle" class="i" v-if="$i.hasUnreadMentions"/></button>
|
|
|
|
<button class="_button tab" @click="() => { src = 'directs'; saveSrc(); }" :class="{ active: src === 'directs' }" v-tooltip="$ts.directNotes"><Fa :icon="faEnvelope"/><Fa :icon="faCircle" class="i" v-if="$i.hasUnreadSpecifiedNotes"/></button>
|
2020-12-29 02:33:21 +00:00
|
|
|
</div>
|
|
|
|
<div class="right">
|
|
|
|
<button class="_button tab" @click="chooseChannel" :class="{ active: src === 'channel' }" v-tooltip="$ts.channel"><Fa :icon="faSatelliteDish"/><Fa :icon="faCircle" class="i" v-if="$i.hasUnreadChannel"/></button>
|
|
|
|
<button class="_button tab" @click="chooseAntenna" :class="{ active: src === 'antenna' }" v-tooltip="$ts.antennas"><Fa :icon="faSatellite"/><Fa :icon="faCircle" class="i" v-if="$i.hasUnreadAntenna"/></button>
|
|
|
|
<button class="_button tab" @click="chooseList" :class="{ active: src === 'list' }" v-tooltip="$ts.lists"><Fa :icon="faListUl"/></button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-17 11:12:00 +00:00
|
|
|
<XTimeline ref="tl"
|
|
|
|
class="_content _vMargin"
|
|
|
|
:key="src === 'list' ? `list:${list.id}` : src === 'antenna' ? `antenna:${antenna.id}` : src === 'channel' ? `channel:${channel.id}` : src"
|
|
|
|
:src="src"
|
|
|
|
:list="list ? list.id : null"
|
|
|
|
:antenna="antenna ? antenna.id : null"
|
|
|
|
:channel="channel ? channel.id : null"
|
|
|
|
:sound="true"
|
|
|
|
@before="before()"
|
|
|
|
@after="after()"
|
|
|
|
@queue="queueUpdated"
|
|
|
|
/>
|
|
|
|
</div>
|
2020-01-29 19:37:25 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 11:12:00 +00:00
|
|
|
import { defineComponent, defineAsyncComponent, computed } from 'vue';
|
2020-12-29 02:33:21 +00:00
|
|
|
import { faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faListUl, faSatellite, faSatelliteDish, faCircle, faEllipsisH, faPencilAlt, faAt } from '@fortawesome/free-solid-svg-icons';
|
|
|
|
import { faComments, faEnvelope } from '@fortawesome/free-regular-svg-icons';
|
2020-10-17 11:12:00 +00:00
|
|
|
import Progress from '@/scripts/loading';
|
|
|
|
import XTimeline from '@/components/timeline.vue';
|
|
|
|
import XPostForm from '@/components/post-form.vue';
|
|
|
|
import { scroll } from '@/scripts/scroll';
|
|
|
|
import * as os from '@/os';
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'timeline',
|
2020-01-29 19:37:25 +00:00
|
|
|
|
|
|
|
components: {
|
2020-02-09 12:31:17 +00:00
|
|
|
XTimeline,
|
2020-10-17 11:12:00 +00:00
|
|
|
XTutorial: defineAsyncComponent(() => import('./timeline.tutorial.vue')),
|
2020-02-18 18:11:09 +00:00
|
|
|
XPostForm,
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
src: 'home',
|
|
|
|
list: null,
|
|
|
|
antenna: null,
|
2020-08-18 13:44:21 +00:00
|
|
|
channel: null,
|
2020-01-29 19:37:25 +00:00
|
|
|
menuOpened: false,
|
2020-02-18 19:08:35 +00:00
|
|
|
queue: 0,
|
|
|
|
width: 0,
|
2020-12-29 02:33:21 +00:00
|
|
|
INFO: computed(() => ({
|
|
|
|
title: this.$ts.timeline,
|
|
|
|
icon: this.src === 'local' ? faComments : this.src === 'social' ? faShareAlt : this.src === 'global' ? faGlobe : faHome,
|
|
|
|
action: {
|
|
|
|
icon: faPencilAlt,
|
|
|
|
handler: () => os.post()
|
2020-10-18 07:33:23 +00:00
|
|
|
}
|
2020-12-29 02:33:21 +00:00
|
|
|
})),
|
|
|
|
faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faComments, faListUl, faSatellite, faSatelliteDish, faCircle, faEllipsisH, faAt, faEnvelope,
|
2020-01-29 19:37:25 +00:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
keymap(): any {
|
|
|
|
return {
|
|
|
|
't': this.focus
|
|
|
|
};
|
2020-02-09 12:31:17 +00:00
|
|
|
},
|
2020-02-20 14:02:55 +00:00
|
|
|
|
2020-12-29 07:58:14 +00:00
|
|
|
isLocalTimelineAvailable(): boolean {
|
|
|
|
return !this.$instance.disableLocalTimeline || this.$i.isModerator || this.$i.isAdmin;
|
|
|
|
},
|
|
|
|
|
|
|
|
isGlobalTimelineAvailable(): boolean {
|
|
|
|
return !this.$instance.disableGlobalTimeline || this.$i.isModerator || this.$i.isAdmin;
|
2020-02-20 14:02:55 +00:00
|
|
|
},
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
src() {
|
|
|
|
this.showNav = false;
|
|
|
|
},
|
|
|
|
list(x) {
|
|
|
|
this.showNav = false;
|
|
|
|
if (x != null) this.antenna = null;
|
2020-08-18 13:44:21 +00:00
|
|
|
if (x != null) this.channel = null;
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
antenna(x) {
|
|
|
|
this.showNav = false;
|
2020-08-18 13:44:21 +00:00
|
|
|
if (x != null) this.list = null;
|
|
|
|
if (x != null) this.channel = null;
|
|
|
|
},
|
|
|
|
channel(x) {
|
|
|
|
this.showNav = false;
|
|
|
|
if (x != null) this.antenna = null;
|
2020-01-29 19:37:25 +00:00
|
|
|
if (x != null) this.list = null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-12-19 01:55:52 +00:00
|
|
|
this.src = this.$store.state.tl.src;
|
2020-02-09 22:23:43 +00:00
|
|
|
if (this.src === 'list') {
|
2020-12-19 01:55:52 +00:00
|
|
|
this.list = this.$store.state.tl.arg;
|
2020-02-09 22:23:43 +00:00
|
|
|
} else if (this.src === 'antenna') {
|
2020-12-19 01:55:52 +00:00
|
|
|
this.antenna = this.$store.state.tl.arg;
|
2020-08-18 13:44:21 +00:00
|
|
|
} else if (this.src === 'channel') {
|
2020-12-19 01:55:52 +00:00
|
|
|
this.channel = this.$store.state.tl.arg;
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-19 08:55:55 +00:00
|
|
|
mounted() {
|
2020-02-19 08:59:28 +00:00
|
|
|
this.width = this.$el.offsetWidth;
|
2020-02-19 08:55:55 +00:00
|
|
|
},
|
|
|
|
|
2020-01-29 19:37:25 +00:00
|
|
|
methods: {
|
|
|
|
before() {
|
|
|
|
Progress.start();
|
|
|
|
},
|
|
|
|
|
|
|
|
after() {
|
|
|
|
Progress.done();
|
|
|
|
},
|
|
|
|
|
2020-02-18 19:08:35 +00:00
|
|
|
queueUpdated(q) {
|
2020-02-19 08:55:55 +00:00
|
|
|
if (this.$el.offsetWidth !== 0) this.width = this.$el.offsetWidth;
|
2020-02-18 19:08:35 +00:00
|
|
|
this.queue = q;
|
|
|
|
},
|
|
|
|
|
|
|
|
top() {
|
2020-07-12 07:14:49 +00:00
|
|
|
scroll(this.$el, 0);
|
2020-02-18 19:08:35 +00:00
|
|
|
},
|
|
|
|
|
2020-12-29 02:33:21 +00:00
|
|
|
async chooseList(ev) {
|
|
|
|
const lists = await os.api('users/lists/list');
|
|
|
|
const items = lists.map(list => ({
|
|
|
|
text: list.name,
|
2020-01-29 19:37:25 +00:00
|
|
|
action: () => {
|
2020-12-29 02:33:21 +00:00
|
|
|
this.list = list;
|
|
|
|
this.src = 'list';
|
2020-08-18 13:44:21 +00:00
|
|
|
this.saveSrc();
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}));
|
2020-12-29 02:33:21 +00:00
|
|
|
os.modalMenu(items, ev.currentTarget || ev.target);
|
|
|
|
},
|
|
|
|
|
|
|
|
async chooseAntenna(ev) {
|
|
|
|
const antennas = await os.api('antennas/list');
|
|
|
|
const items = antennas.map(antenna => ({
|
|
|
|
text: antenna.name,
|
|
|
|
indicate: antenna.hasUnreadNote,
|
2020-01-29 19:37:25 +00:00
|
|
|
action: () => {
|
2020-12-29 02:33:21 +00:00
|
|
|
this.antenna = antenna;
|
|
|
|
this.src = 'antenna';
|
2020-08-18 13:44:21 +00:00
|
|
|
this.saveSrc();
|
|
|
|
}
|
|
|
|
}));
|
2020-12-29 02:33:21 +00:00
|
|
|
os.modalMenu(items, ev.currentTarget || ev.target);
|
|
|
|
},
|
|
|
|
|
|
|
|
async chooseChannel(ev) {
|
|
|
|
const channels = await os.api('channels/followed');
|
|
|
|
const items = channels.map(channel => ({
|
2020-08-18 13:44:21 +00:00
|
|
|
text: channel.name,
|
|
|
|
indicate: channel.hasUnreadNote,
|
|
|
|
action: () => {
|
|
|
|
// NOTE: チャンネルタイムラインをこのコンポーネントで表示するようにすると投稿フォームはどうするかなどの問題が生じるのでとりあえずページ遷移で
|
|
|
|
//this.channel = channel;
|
|
|
|
//this.src = 'channel';
|
|
|
|
//this.saveSrc();
|
|
|
|
this.$router.push(`/channels/${channel.id}`);
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}));
|
2020-12-29 02:33:21 +00:00
|
|
|
os.modalMenu(items, ev.currentTarget || ev.target);
|
2020-01-29 19:37:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
saveSrc() {
|
2020-12-19 01:55:52 +00:00
|
|
|
this.$store.set('tl', {
|
2020-01-29 19:37:25 +00:00
|
|
|
src: this.src,
|
2020-08-18 13:44:21 +00:00
|
|
|
arg:
|
|
|
|
this.src === 'list' ? this.list :
|
|
|
|
this.src === 'antenna' ? this.antenna :
|
|
|
|
this.channel
|
2020-01-29 19:37:25 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
(this.$refs.tl as any).focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-02-09 12:31:17 +00:00
|
|
|
<style lang="scss" scoped>
|
2020-12-29 02:33:21 +00:00
|
|
|
.cmuxhskf {
|
2020-02-18 19:08:35 +00:00
|
|
|
> .new {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
display: block;
|
2020-10-17 11:12:00 +00:00
|
|
|
margin: var(--margin) auto 0 auto;
|
2020-02-19 21:08:54 +00:00
|
|
|
padding: 8px 16px;
|
2020-02-18 19:08:35 +00:00
|
|
|
border-radius: 32px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 11:12:00 +00:00
|
|
|
> ._section {
|
2020-12-29 02:33:21 +00:00
|
|
|
> .tabs {
|
|
|
|
display: flex;
|
|
|
|
box-sizing: border-box;
|
|
|
|
padding: 0 8px;
|
|
|
|
max-width: var(--baseContentWidth);
|
|
|
|
margin-left: auto;
|
|
|
|
margin-right: auto;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: auto;
|
|
|
|
|
2020-12-29 13:00:02 +00:00
|
|
|
// 影の都合上
|
|
|
|
position: relative;
|
|
|
|
|
2020-12-29 02:33:21 +00:00
|
|
|
> .right {
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .left, > .right {
|
|
|
|
> .tab {
|
|
|
|
position: relative;
|
|
|
|
height: 50px;
|
|
|
|
padding: 0 12px;
|
2020-01-29 19:37:25 +00:00
|
|
|
|
2020-12-29 02:33:21 +00:00
|
|
|
&:hover {
|
|
|
|
color: var(--fgHighlighted);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
color: var(--fgHighlighted);
|
|
|
|
|
|
|
|
&:after {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
margin: 0 auto;
|
|
|
|
width: calc(100% - 16px);
|
|
|
|
height: 4px;
|
|
|
|
background: var(--accent);
|
|
|
|
border-radius: 8px 8px 0 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
> .i {
|
|
|
|
position: absolute;
|
|
|
|
top: 16px;
|
|
|
|
right: 8px;
|
|
|
|
color: var(--indicator);
|
|
|
|
font-size: 8px;
|
|
|
|
animation: blink 1s infinite;
|
|
|
|
}
|
|
|
|
}
|
2020-12-29 08:11:12 +00:00
|
|
|
|
|
|
|
> .divider {
|
|
|
|
display: inline-block;
|
|
|
|
width: 1px;
|
|
|
|
height: 28px;
|
|
|
|
vertical-align: middle;
|
|
|
|
margin: 0 8px;
|
|
|
|
background: var(--divider);
|
|
|
|
}
|
2020-12-29 02:33:21 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-29 19:37:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|