2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
|
|
|
<div class="mk-home" v-hotkey.global="keymap">
|
2020-12-26 02:47:36 +01:00
|
|
|
<div class="new" v-if="queue > 0" :style="{ width: width + 'px' }"><button class="_buttonPrimary" @click="top()">{{ $ts.newNoteRecived }}</button></div>
|
2020-02-18 20:08:35 +01:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
<div class="_section">
|
2020-12-19 02:55:52 +01: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-10-17 13:12:00 +02: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 20:37:25 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2020-10-17 13:12:00 +02:00
|
|
|
import { defineComponent, defineAsyncComponent, computed } from 'vue';
|
|
|
|
import { faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faListUl, faSatellite, faSatelliteDish, faCircle, faEllipsisH, faPencilAlt } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 20:37:25 +01:00
|
|
|
import { faComments } from '@fortawesome/free-regular-svg-icons';
|
2020-10-17 13:12:00 +02: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 20:37:25 +01:00
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
export default defineComponent({
|
|
|
|
name: 'timeline',
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
components: {
|
2020-02-09 13:31:17 +01:00
|
|
|
XTimeline,
|
2020-10-17 13:12:00 +02:00
|
|
|
XTutorial: defineAsyncComponent(() => import('./timeline.tutorial.vue')),
|
2020-02-18 19:11:09 +01:00
|
|
|
XPostForm,
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
src: 'home',
|
|
|
|
list: null,
|
|
|
|
antenna: null,
|
2020-08-18 15:44:21 +02:00
|
|
|
channel: null,
|
2020-01-29 20:37:25 +01:00
|
|
|
menuOpened: false,
|
2020-02-18 20:08:35 +01:00
|
|
|
queue: 0,
|
|
|
|
width: 0,
|
2020-10-18 09:33:23 +02:00
|
|
|
INFO: computed(() => {
|
2020-11-03 12:36:12 +01:00
|
|
|
const tabs = [{
|
2020-10-17 13:12:00 +02:00
|
|
|
id: 'home',
|
|
|
|
title: null,
|
2020-12-26 02:47:36 +01:00
|
|
|
tooltip: this.$ts._timelines.home,
|
2020-10-17 13:12:00 +02:00
|
|
|
icon: faHome,
|
|
|
|
onClick: () => { this.src = 'home'; this.saveSrc(); },
|
|
|
|
selected: computed(() => this.src === 'home')
|
2020-10-18 09:33:23 +02:00
|
|
|
}];
|
|
|
|
|
2020-12-19 02:55:52 +01:00
|
|
|
if (!this.$instance.disableLocalTimeline || this.$i.isModerator || this.$i.isAdmin) {
|
2020-11-03 12:36:12 +01:00
|
|
|
tabs.push({
|
2020-10-18 09:33:23 +02:00
|
|
|
id: 'local',
|
|
|
|
title: null,
|
2020-12-26 02:47:36 +01:00
|
|
|
tooltip: this.$ts._timelines.local,
|
2020-10-18 09:33:23 +02:00
|
|
|
icon: faComments,
|
|
|
|
onClick: () => { this.src = 'local'; this.saveSrc(); },
|
|
|
|
selected: computed(() => this.src === 'local')
|
|
|
|
});
|
|
|
|
|
2020-11-03 12:36:12 +01:00
|
|
|
tabs.push({
|
2020-10-18 09:33:23 +02:00
|
|
|
id: 'social',
|
|
|
|
title: null,
|
2020-12-26 02:47:36 +01:00
|
|
|
tooltip: this.$ts._timelines.social,
|
2020-10-18 09:33:23 +02:00
|
|
|
icon: faShareAlt,
|
|
|
|
onClick: () => { this.src = 'social'; this.saveSrc(); },
|
|
|
|
selected: computed(() => this.src === 'social')
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-12-19 02:55:52 +01:00
|
|
|
if (!this.$instance.disableGlobalTimeline || this.$i.isModerator || this.$i.isAdmin) {
|
2020-11-03 12:36:12 +01:00
|
|
|
tabs.push({
|
2020-10-18 09:33:23 +02:00
|
|
|
id: 'global',
|
|
|
|
title: null,
|
2020-12-26 02:47:36 +01:00
|
|
|
tooltip: this.$ts._timelines.global,
|
2020-10-18 09:33:23 +02:00
|
|
|
icon: faGlobe,
|
|
|
|
onClick: () => { this.src = 'global'; this.saveSrc(); },
|
|
|
|
selected: computed(() => this.src === 'global')
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-03 12:36:12 +01:00
|
|
|
tabs.push({
|
2020-10-17 13:12:00 +02:00
|
|
|
id: 'other',
|
|
|
|
title: null,
|
|
|
|
icon: faEllipsisH,
|
|
|
|
onClick: this.choose,
|
2020-12-19 02:55:52 +01:00
|
|
|
indicate: computed(() => this.$i.hasUnreadAntenna || this.$i.hasUnreadChannel)
|
2020-10-18 09:33:23 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
2020-11-03 12:36:12 +01:00
|
|
|
tabs,
|
2020-10-18 09:33:23 +02:00
|
|
|
action: {
|
|
|
|
icon: faPencilAlt,
|
|
|
|
handler: () => os.post()
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}),
|
2020-08-18 15:44:21 +02:00
|
|
|
faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faComments, faListUl, faSatellite, faSatelliteDish, faCircle
|
2020-01-29 20:37:25 +01:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
keymap(): any {
|
|
|
|
return {
|
|
|
|
't': this.focus
|
|
|
|
};
|
2020-02-09 13:31:17 +01:00
|
|
|
},
|
2020-02-20 15:02:55 +01:00
|
|
|
|
|
|
|
meta() {
|
2020-12-19 02:55:52 +01:00
|
|
|
return this.$instance;
|
2020-02-20 15:02:55 +01:00
|
|
|
},
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
src() {
|
|
|
|
this.showNav = false;
|
|
|
|
},
|
|
|
|
list(x) {
|
|
|
|
this.showNav = false;
|
|
|
|
if (x != null) this.antenna = null;
|
2020-08-18 15:44:21 +02:00
|
|
|
if (x != null) this.channel = null;
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
antenna(x) {
|
|
|
|
this.showNav = false;
|
2020-08-18 15:44:21 +02: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 20:37:25 +01:00
|
|
|
if (x != null) this.list = null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.src = this.$store.state.tl.src;
|
2020-02-09 23:23:43 +01:00
|
|
|
if (this.src === 'list') {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.list = this.$store.state.tl.arg;
|
2020-02-09 23:23:43 +01:00
|
|
|
} else if (this.src === 'antenna') {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.antenna = this.$store.state.tl.arg;
|
2020-08-18 15:44:21 +02:00
|
|
|
} else if (this.src === 'channel') {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.channel = this.$store.state.tl.arg;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-19 09:55:55 +01:00
|
|
|
mounted() {
|
2020-02-19 09:59:28 +01:00
|
|
|
this.width = this.$el.offsetWidth;
|
2020-02-19 09:55:55 +01:00
|
|
|
},
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
methods: {
|
|
|
|
before() {
|
|
|
|
Progress.start();
|
|
|
|
},
|
|
|
|
|
|
|
|
after() {
|
|
|
|
Progress.done();
|
|
|
|
},
|
|
|
|
|
2020-02-18 20:08:35 +01:00
|
|
|
queueUpdated(q) {
|
2020-02-19 09:55:55 +01:00
|
|
|
if (this.$el.offsetWidth !== 0) this.width = this.$el.offsetWidth;
|
2020-02-18 20:08:35 +01:00
|
|
|
this.queue = q;
|
|
|
|
},
|
|
|
|
|
|
|
|
top() {
|
2020-07-12 09:14:49 +02:00
|
|
|
scroll(this.$el, 0);
|
2020-02-18 20:08:35 +01:00
|
|
|
},
|
|
|
|
|
2020-01-29 20:37:25 +01:00
|
|
|
async choose(ev) {
|
2020-02-20 15:02:55 +01:00
|
|
|
if (this.meta == null) return;
|
2020-08-18 15:44:21 +02:00
|
|
|
const [antennas, lists, channels] = await Promise.all([
|
2020-10-17 13:12:00 +02:00
|
|
|
os.api('antennas/list'),
|
|
|
|
os.api('users/lists/list'),
|
|
|
|
os.api('channels/followed'),
|
2020-01-29 20:37:25 +01:00
|
|
|
]);
|
|
|
|
const antennaItems = antennas.map(antenna => ({
|
|
|
|
text: antenna.name,
|
|
|
|
icon: faSatellite,
|
|
|
|
indicate: antenna.hasUnreadNote,
|
|
|
|
action: () => {
|
|
|
|
this.antenna = antenna;
|
2020-08-18 15:44:21 +02:00
|
|
|
this.src = 'antenna';
|
|
|
|
this.saveSrc();
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}));
|
|
|
|
const listItems = lists.map(list => ({
|
|
|
|
text: list.name,
|
|
|
|
icon: faListUl,
|
|
|
|
action: () => {
|
|
|
|
this.list = list;
|
2020-08-18 15:44:21 +02:00
|
|
|
this.src = 'list';
|
|
|
|
this.saveSrc();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
const channelItems = channels.map(channel => ({
|
|
|
|
text: channel.name,
|
|
|
|
icon: faSatelliteDish,
|
|
|
|
indicate: channel.hasUnreadNote,
|
|
|
|
action: () => {
|
|
|
|
// NOTE: チャンネルタイムラインをこのコンポーネントで表示するようにすると投稿フォームはどうするかなどの問題が生じるのでとりあえずページ遷移で
|
|
|
|
//this.channel = channel;
|
|
|
|
//this.src = 'channel';
|
|
|
|
//this.saveSrc();
|
|
|
|
this.$router.push(`/channels/${channel.id}`);
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
}));
|
2020-10-17 13:12:00 +02:00
|
|
|
os.modalMenu([...antennaItems, listItems.length > 0 ? null : undefined, ...listItems, channelItems.length > 0 ? null : undefined, ...channelItems], ev.currentTarget || ev.target);
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
saveSrc() {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.$store.set('tl', {
|
2020-01-29 20:37:25 +01:00
|
|
|
src: this.src,
|
2020-08-18 15:44:21 +02:00
|
|
|
arg:
|
|
|
|
this.src === 'list' ? this.list :
|
|
|
|
this.src === 'antenna' ? this.antenna :
|
|
|
|
this.channel
|
2020-01-29 20:37:25 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
(this.$refs.tl as any).focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-02-09 13:31:17 +01:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.mk-home {
|
2020-02-18 20:08:35 +01:00
|
|
|
> .new {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
display: block;
|
2020-10-17 13:12:00 +02:00
|
|
|
margin: var(--margin) auto 0 auto;
|
2020-02-19 22:08:54 +01:00
|
|
|
padding: 8px 16px;
|
2020-02-18 20:08:35 +01:00
|
|
|
border-radius: 32px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
> ._section {
|
2020-01-29 20:37:25 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|