2020-01-29 13:37:25 -06:00
|
|
|
<template>
|
2021-08-21 03:40:15 -05:00
|
|
|
<div class="cmuxhskf" v-hotkey.global="keymap" v-size="{ min: [800] }">
|
2021-09-17 08:39:15 -05:00
|
|
|
<XTutorial v-if="$store.reactiveState.tutorial.value != -1" class="tutorial _block"/>
|
|
|
|
<XPostForm v-if="$store.reactiveState.showFixedPostForm.value" class="post-form _block" fixed/>
|
|
|
|
|
2021-04-24 08:52:07 -05:00
|
|
|
<div class="new" v-if="queue > 0"><button class="_buttonPrimary" @click="top()">{{ $ts.newNoteRecived }}</button></div>
|
2021-09-17 08:39:15 -05:00
|
|
|
<div class="tl _block">
|
2021-08-21 03:40:15 -05:00
|
|
|
<XTimeline ref="tl" class="tl"
|
|
|
|
: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 13:37:25 -06:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 06:12:00 -05:00
|
|
|
import { defineComponent, defineAsyncComponent, computed } from 'vue';
|
2021-03-23 03:30:14 -05:00
|
|
|
import Progress from '@client/scripts/loading';
|
|
|
|
import XTimeline from '@client/components/timeline.vue';
|
|
|
|
import XPostForm from '@client/components/post-form.vue';
|
|
|
|
import { scroll } from '@client/scripts/scroll';
|
|
|
|
import * as os from '@client/os';
|
2021-04-09 22:54:12 -05:00
|
|
|
import * as symbols from '@client/symbols';
|
2020-01-29 13:37:25 -06:00
|
|
|
|
2020-10-17 06:12:00 -05:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'timeline',
|
2020-01-29 13:37:25 -06:00
|
|
|
|
|
|
|
components: {
|
2020-02-09 06:31:17 -06:00
|
|
|
XTimeline,
|
2020-10-17 06:12:00 -05:00
|
|
|
XTutorial: defineAsyncComponent(() => import('./timeline.tutorial.vue')),
|
2020-02-18 12:11:09 -06:00
|
|
|
XPostForm,
|
2020-01-29 13:37:25 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
src: 'home',
|
|
|
|
list: null,
|
|
|
|
antenna: null,
|
2020-08-18 08:44:21 -05:00
|
|
|
channel: null,
|
2020-01-29 13:37:25 -06:00
|
|
|
menuOpened: false,
|
2020-02-18 13:08:35 -06:00
|
|
|
queue: 0,
|
2021-04-09 22:54:12 -05:00
|
|
|
[symbols.PAGE_INFO]: computed(() => ({
|
2020-12-28 20:33:21 -06:00
|
|
|
title: this.$ts.timeline,
|
2021-04-20 09:22:59 -05:00
|
|
|
icon: this.src === 'local' ? 'fas fa-comments' : this.src === 'social' ? 'fas fa-share-alt' : this.src === 'global' ? 'fas fa-globe' : 'fas fa-home',
|
2021-09-17 08:39:15 -05:00
|
|
|
bg: 'var(--bg)',
|
2021-04-09 23:38:24 -05:00
|
|
|
actions: [{
|
2021-04-20 09:22:59 -05:00
|
|
|
icon: 'fas fa-calendar-alt',
|
2021-04-09 23:38:24 -05:00
|
|
|
text: this.$ts.jumpToSpecifiedDate,
|
|
|
|
handler: this.timetravel
|
2021-09-17 08:39:15 -05:00
|
|
|
}],
|
|
|
|
tabs: [{
|
|
|
|
active: this.src === 'home',
|
|
|
|
title: this.$ts._timelines.home,
|
|
|
|
icon: 'fas fa-home',
|
|
|
|
iconOnly: true,
|
|
|
|
onClick: () => { this.src = 'home'; this.saveSrc(); },
|
|
|
|
}, {
|
|
|
|
active: this.src === 'local',
|
|
|
|
title: this.$ts._timelines.local,
|
|
|
|
icon: 'fas fa-comments',
|
|
|
|
iconOnly: true,
|
|
|
|
onClick: () => { this.src = 'local'; this.saveSrc(); },
|
|
|
|
}, {
|
|
|
|
active: this.src === 'social',
|
|
|
|
title: this.$ts._timelines.social,
|
|
|
|
icon: 'fas fa-share-alt',
|
|
|
|
iconOnly: true,
|
|
|
|
onClick: () => { this.src = 'social'; this.saveSrc(); },
|
|
|
|
}, {
|
|
|
|
active: this.src === 'global',
|
|
|
|
title: this.$ts._timelines.global,
|
|
|
|
icon: 'fas fa-globe',
|
|
|
|
iconOnly: true,
|
|
|
|
onClick: () => { this.src = 'global'; this.saveSrc(); },
|
2021-04-09 23:38:24 -05:00
|
|
|
}]
|
2020-12-28 20:33:21 -06:00
|
|
|
})),
|
2020-01-29 13:37:25 -06:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
keymap(): any {
|
|
|
|
return {
|
|
|
|
't': this.focus
|
|
|
|
};
|
2020-02-09 06:31:17 -06:00
|
|
|
},
|
2020-02-20 08:02:55 -06:00
|
|
|
|
2020-12-29 01:58:14 -06: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 08:02:55 -06:00
|
|
|
},
|
2020-01-29 13:37:25 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
src() {
|
|
|
|
this.showNav = false;
|
|
|
|
},
|
|
|
|
list(x) {
|
|
|
|
this.showNav = false;
|
|
|
|
if (x != null) this.antenna = null;
|
2020-08-18 08:44:21 -05:00
|
|
|
if (x != null) this.channel = null;
|
2020-01-29 13:37:25 -06:00
|
|
|
},
|
|
|
|
antenna(x) {
|
|
|
|
this.showNav = false;
|
2020-08-18 08:44:21 -05: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 13:37:25 -06:00
|
|
|
if (x != null) this.list = null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-12-18 19:55:52 -06:00
|
|
|
this.src = this.$store.state.tl.src;
|
2020-02-09 16:23:43 -06:00
|
|
|
if (this.src === 'list') {
|
2020-12-18 19:55:52 -06:00
|
|
|
this.list = this.$store.state.tl.arg;
|
2020-02-09 16:23:43 -06:00
|
|
|
} else if (this.src === 'antenna') {
|
2020-12-18 19:55:52 -06:00
|
|
|
this.antenna = this.$store.state.tl.arg;
|
2020-08-18 08:44:21 -05:00
|
|
|
} else if (this.src === 'channel') {
|
2020-12-18 19:55:52 -06:00
|
|
|
this.channel = this.$store.state.tl.arg;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
before() {
|
|
|
|
Progress.start();
|
|
|
|
},
|
|
|
|
|
|
|
|
after() {
|
|
|
|
Progress.done();
|
|
|
|
},
|
|
|
|
|
2020-02-18 13:08:35 -06:00
|
|
|
queueUpdated(q) {
|
|
|
|
this.queue = q;
|
|
|
|
},
|
|
|
|
|
|
|
|
top() {
|
2020-07-12 02:14:49 -05:00
|
|
|
scroll(this.$el, 0);
|
2020-02-18 13:08:35 -06:00
|
|
|
},
|
|
|
|
|
2020-12-28 20:33:21 -06:00
|
|
|
async chooseList(ev) {
|
|
|
|
const lists = await os.api('users/lists/list');
|
|
|
|
const items = lists.map(list => ({
|
|
|
|
text: list.name,
|
2020-01-29 13:37:25 -06:00
|
|
|
action: () => {
|
2020-12-28 20:33:21 -06:00
|
|
|
this.list = list;
|
|
|
|
this.src = 'list';
|
2020-08-18 08:44:21 -05:00
|
|
|
this.saveSrc();
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
}));
|
2021-08-07 22:19:10 -05:00
|
|
|
os.popupMenu(items, ev.currentTarget || ev.target);
|
2020-12-28 20:33:21 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
async chooseAntenna(ev) {
|
|
|
|
const antennas = await os.api('antennas/list');
|
|
|
|
const items = antennas.map(antenna => ({
|
|
|
|
text: antenna.name,
|
|
|
|
indicate: antenna.hasUnreadNote,
|
2020-01-29 13:37:25 -06:00
|
|
|
action: () => {
|
2020-12-28 20:33:21 -06:00
|
|
|
this.antenna = antenna;
|
|
|
|
this.src = 'antenna';
|
2020-08-18 08:44:21 -05:00
|
|
|
this.saveSrc();
|
|
|
|
}
|
|
|
|
}));
|
2021-08-07 22:19:10 -05:00
|
|
|
os.popupMenu(items, ev.currentTarget || ev.target);
|
2020-12-28 20:33:21 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
async chooseChannel(ev) {
|
|
|
|
const channels = await os.api('channels/followed');
|
|
|
|
const items = channels.map(channel => ({
|
2020-08-18 08:44:21 -05: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 13:37:25 -06:00
|
|
|
}
|
|
|
|
}));
|
2021-08-07 22:19:10 -05:00
|
|
|
os.popupMenu(items, ev.currentTarget || ev.target);
|
2020-01-29 13:37:25 -06:00
|
|
|
},
|
|
|
|
|
|
|
|
saveSrc() {
|
2020-12-18 19:55:52 -06:00
|
|
|
this.$store.set('tl', {
|
2020-01-29 13:37:25 -06:00
|
|
|
src: this.src,
|
2020-08-18 08:44:21 -05:00
|
|
|
arg:
|
|
|
|
this.src === 'list' ? this.list :
|
|
|
|
this.src === 'antenna' ? this.antenna :
|
|
|
|
this.channel
|
2020-01-29 13:37:25 -06:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-04-09 22:40:50 -05:00
|
|
|
async timetravel() {
|
|
|
|
const { canceled, result: date } = await os.dialog({
|
|
|
|
title: this.$ts.date,
|
|
|
|
input: {
|
|
|
|
type: 'date'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
this.$refs.tl.timetravel(new Date(date));
|
|
|
|
},
|
|
|
|
|
2020-01-29 13:37:25 -06:00
|
|
|
focus() {
|
|
|
|
(this.$refs.tl as any).focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-02-09 06:31:17 -06:00
|
|
|
<style lang="scss" scoped>
|
2020-12-28 20:33:21 -06:00
|
|
|
.cmuxhskf {
|
2021-09-17 08:39:15 -05:00
|
|
|
padding: var(--margin);
|
|
|
|
|
2020-02-18 13:08:35 -06:00
|
|
|
> .new {
|
2021-04-15 03:36:09 -05:00
|
|
|
position: sticky;
|
|
|
|
top: calc(var(--stickyTop, 0px) + 16px);
|
2020-02-18 13:08:35 -06:00
|
|
|
z-index: 1000;
|
2021-04-15 03:36:09 -05:00
|
|
|
width: 100%;
|
2020-02-18 13:08:35 -06:00
|
|
|
|
|
|
|
> button {
|
|
|
|
display: block;
|
2020-10-17 06:12:00 -05:00
|
|
|
margin: var(--margin) auto 0 auto;
|
2020-02-19 15:08:54 -06:00
|
|
|
padding: 8px 16px;
|
2020-02-18 13:08:35 -06:00
|
|
|
border-radius: 32px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-17 08:39:15 -05:00
|
|
|
> .tl {
|
|
|
|
background: var(--bg);
|
|
|
|
border-radius: var(--radius);
|
|
|
|
overflow: clip;
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
2021-08-14 08:35:15 -05:00
|
|
|
|
2021-08-21 03:40:15 -05:00
|
|
|
&.min-width_800px {
|
2021-09-17 08:39:15 -05:00
|
|
|
max-width: 800px;
|
|
|
|
margin: 0 auto;
|
2021-08-14 08:35:15 -05:00
|
|
|
}
|
2020-01-29 13:37:25 -06:00
|
|
|
}
|
|
|
|
</style>
|