2020-01-29 11:37:25 -08:00
|
|
|
<template>
|
|
|
|
<div class="mk-home" v-hotkey.global="keymap">
|
2020-01-31 16:12:04 -08:00
|
|
|
<portal to="header" v-if="showTitle">
|
2020-01-29 11:37:25 -08:00
|
|
|
<button @click="choose" class="_button _kjvfvyph_">
|
2020-08-18 06:44:21 -07:00
|
|
|
<i><fa v-if="$store.state.i.hasUnreadAntenna || $store.state.i.hasUnreadChannel" :icon="faCircle"/></i>
|
2020-01-29 11:37:25 -08:00
|
|
|
<fa v-if="src === 'home'" :icon="faHome"/>
|
|
|
|
<fa v-if="src === 'local'" :icon="faComments"/>
|
|
|
|
<fa v-if="src === 'social'" :icon="faShareAlt"/>
|
|
|
|
<fa v-if="src === 'global'" :icon="faGlobe"/>
|
|
|
|
<fa v-if="src === 'list'" :icon="faListUl"/>
|
|
|
|
<fa v-if="src === 'antenna'" :icon="faSatellite"/>
|
2020-08-18 06:44:21 -07:00
|
|
|
<fa v-if="src === 'channel'" :icon="faSatelliteDish"/>
|
|
|
|
<span style="margin-left: 8px;">{{ src === 'list' ? list.name : src === 'antenna' ? antenna.name : src === 'channel' ? channel.name : $t('_timelines.' + src) }}</span>
|
2020-01-29 11:37:25 -08:00
|
|
|
<fa :icon="menuOpened ? faAngleUp : faAngleDown" style="margin-left: 8px;"/>
|
|
|
|
</button>
|
|
|
|
</portal>
|
2020-02-09 04:31:17 -08:00
|
|
|
|
2020-07-24 09:56:52 -07:00
|
|
|
<div class="new" v-if="queue > 0" :style="{ width: width + 'px' }"><button class="_buttonPrimary" @click="top()">{{ $t('newNoteRecived') }}</button></div>
|
2020-02-18 11:08:35 -08:00
|
|
|
|
2020-02-09 05:25:32 -08:00
|
|
|
<x-tutorial class="tutorial" v-if="$store.state.settings.tutorial != -1"/>
|
2020-02-09 04:31:17 -08:00
|
|
|
|
2020-02-18 10:16:10 -08:00
|
|
|
<x-post-form class="post-form _panel" fixed v-if="$store.state.device.showFixedPostForm"/>
|
2020-08-18 06:44:21 -07:00
|
|
|
<x-timeline ref="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"/>
|
2020-01-29 11:37:25 -08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2020-08-18 06:44:21 -07:00
|
|
|
import { faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faListUl, faSatellite, faSatelliteDish, faCircle } from '@fortawesome/free-solid-svg-icons';
|
2020-01-29 11:37:25 -08:00
|
|
|
import { faComments } from '@fortawesome/free-regular-svg-icons';
|
|
|
|
import Progress from '../scripts/loading';
|
|
|
|
import XTimeline from '../components/timeline.vue';
|
2020-02-18 10:11:09 -08:00
|
|
|
import XPostForm from '../components/post-form.vue';
|
2020-07-12 00:14:49 -07:00
|
|
|
import { scroll } from '../scripts/scroll';
|
2020-01-29 11:37:25 -08:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
metaInfo() {
|
|
|
|
return {
|
|
|
|
title: this.$t('timeline') as string
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
components: {
|
2020-02-09 04:31:17 -08:00
|
|
|
XTimeline,
|
2020-04-22 03:36:28 -07:00
|
|
|
XTutorial: () => import('./index.home.tutorial.vue').then(m => m.default),
|
2020-02-18 10:11:09 -08:00
|
|
|
XPostForm,
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
|
2020-01-31 16:12:04 -08:00
|
|
|
props: {
|
|
|
|
showTitle: {
|
|
|
|
type: Boolean,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
src: 'home',
|
|
|
|
list: null,
|
|
|
|
antenna: null,
|
2020-08-18 06:44:21 -07:00
|
|
|
channel: null,
|
2020-01-29 11:37:25 -08:00
|
|
|
menuOpened: false,
|
2020-02-18 11:08:35 -08:00
|
|
|
queue: 0,
|
|
|
|
width: 0,
|
2020-08-18 06:44:21 -07:00
|
|
|
faAngleDown, faAngleUp, faHome, faShareAlt, faGlobe, faComments, faListUl, faSatellite, faSatelliteDish, faCircle
|
2020-01-29 11:37:25 -08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
keymap(): any {
|
|
|
|
return {
|
|
|
|
't': this.focus
|
|
|
|
};
|
2020-02-09 04:31:17 -08:00
|
|
|
},
|
2020-02-20 06:02:55 -08:00
|
|
|
|
|
|
|
meta() {
|
|
|
|
return this.$store.state.instance.meta;
|
|
|
|
},
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
src() {
|
|
|
|
this.showNav = false;
|
|
|
|
},
|
|
|
|
list(x) {
|
|
|
|
this.showNav = false;
|
|
|
|
if (x != null) this.antenna = null;
|
2020-08-18 06:44:21 -07:00
|
|
|
if (x != null) this.channel = null;
|
2020-01-29 11:37:25 -08:00
|
|
|
},
|
|
|
|
antenna(x) {
|
|
|
|
this.showNav = false;
|
2020-08-18 06:44:21 -07: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 11:37:25 -08:00
|
|
|
if (x != null) this.list = null;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-02-09 14:23:43 -08:00
|
|
|
this.src = this.$store.state.deviceUser.tl.src;
|
|
|
|
if (this.src === 'list') {
|
|
|
|
this.list = this.$store.state.deviceUser.tl.arg;
|
|
|
|
} else if (this.src === 'antenna') {
|
|
|
|
this.antenna = this.$store.state.deviceUser.tl.arg;
|
2020-08-18 06:44:21 -07:00
|
|
|
} else if (this.src === 'channel') {
|
|
|
|
this.channel = this.$store.state.deviceUser.tl.arg;
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-02-19 00:55:55 -08:00
|
|
|
mounted() {
|
2020-02-19 00:59:28 -08:00
|
|
|
this.width = this.$el.offsetWidth;
|
2020-02-19 00:55:55 -08:00
|
|
|
},
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
methods: {
|
|
|
|
before() {
|
|
|
|
Progress.start();
|
|
|
|
},
|
|
|
|
|
|
|
|
after() {
|
|
|
|
Progress.done();
|
|
|
|
},
|
|
|
|
|
2020-02-18 11:08:35 -08:00
|
|
|
queueUpdated(q) {
|
2020-02-19 00:55:55 -08:00
|
|
|
if (this.$el.offsetWidth !== 0) this.width = this.$el.offsetWidth;
|
2020-02-18 11:08:35 -08:00
|
|
|
this.queue = q;
|
|
|
|
},
|
|
|
|
|
|
|
|
top() {
|
2020-07-12 00:14:49 -07:00
|
|
|
scroll(this.$el, 0);
|
2020-02-18 11:08:35 -08:00
|
|
|
},
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
async choose(ev) {
|
2020-02-20 06:02:55 -08:00
|
|
|
if (this.meta == null) return;
|
2020-01-29 11:37:25 -08:00
|
|
|
this.menuOpened = true;
|
2020-08-18 06:44:21 -07:00
|
|
|
const [antennas, lists, channels] = await Promise.all([
|
2020-01-29 11:37:25 -08:00
|
|
|
this.$root.api('antennas/list'),
|
2020-08-18 06:44:21 -07:00
|
|
|
this.$root.api('users/lists/list'),
|
|
|
|
this.$root.api('channels/followed'),
|
2020-01-29 11:37:25 -08:00
|
|
|
]);
|
|
|
|
const antennaItems = antennas.map(antenna => ({
|
|
|
|
text: antenna.name,
|
|
|
|
icon: faSatellite,
|
|
|
|
indicate: antenna.hasUnreadNote,
|
|
|
|
action: () => {
|
|
|
|
this.antenna = antenna;
|
2020-08-18 06:44:21 -07:00
|
|
|
this.src = 'antenna';
|
|
|
|
this.saveSrc();
|
2020-01-29 11:37:25 -08:00
|
|
|
}
|
|
|
|
}));
|
|
|
|
const listItems = lists.map(list => ({
|
|
|
|
text: list.name,
|
|
|
|
icon: faListUl,
|
|
|
|
action: () => {
|
|
|
|
this.list = list;
|
2020-08-18 06:44:21 -07: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 11:37:25 -08:00
|
|
|
}
|
|
|
|
}));
|
|
|
|
this.$root.menu({
|
|
|
|
items: [{
|
|
|
|
text: this.$t('_timelines.home'),
|
|
|
|
icon: faHome,
|
2020-08-18 06:44:21 -07:00
|
|
|
action: () => { this.src = 'home'; this.saveSrc(); }
|
2020-02-20 06:11:09 -08:00
|
|
|
}, this.meta.disableLocalTimeline && !this.$store.state.i.isModerator && !this.$store.state.i.isAdmin ? undefined : {
|
2020-01-29 11:37:25 -08:00
|
|
|
text: this.$t('_timelines.local'),
|
|
|
|
icon: faComments,
|
2020-08-18 06:44:21 -07:00
|
|
|
action: () => { this.src = 'local'; this.saveSrc(); }
|
2020-02-20 06:11:09 -08:00
|
|
|
}, this.meta.disableLocalTimeline && !this.$store.state.i.isModerator && !this.$store.state.i.isAdmin ? undefined : {
|
2020-01-29 11:37:25 -08:00
|
|
|
text: this.$t('_timelines.social'),
|
|
|
|
icon: faShareAlt,
|
2020-08-18 06:44:21 -07:00
|
|
|
action: () => { this.src = 'social'; this.saveSrc(); }
|
2020-02-20 06:11:09 -08:00
|
|
|
}, this.meta.disableGlobalTimeline && !this.$store.state.i.isModerator && !this.$store.state.i.isAdmin ? undefined : {
|
2020-01-29 11:37:25 -08:00
|
|
|
text: this.$t('_timelines.global'),
|
|
|
|
icon: faGlobe,
|
2020-08-18 06:44:21 -07:00
|
|
|
action: () => { this.src = 'global'; this.saveSrc(); }
|
|
|
|
}, antennaItems.length > 0 ? null : undefined, ...antennaItems, listItems.length > 0 ? null : undefined, ...listItems, channelItems.length > 0 ? null : undefined, ...channelItems],
|
2020-01-29 11:37:25 -08:00
|
|
|
fixed: true,
|
|
|
|
noCenter: true,
|
|
|
|
source: ev.currentTarget || ev.target
|
|
|
|
}).then(() => {
|
|
|
|
this.menuOpened = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
saveSrc() {
|
2020-02-09 14:23:43 -08:00
|
|
|
this.$store.commit('deviceUser/setTl', {
|
2020-01-29 11:37:25 -08:00
|
|
|
src: this.src,
|
2020-08-18 06:44:21 -07:00
|
|
|
arg:
|
|
|
|
this.src === 'list' ? this.list :
|
|
|
|
this.src === 'antenna' ? this.antenna :
|
|
|
|
this.channel
|
2020-01-29 11:37:25 -08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
focus() {
|
|
|
|
(this.$refs.tl as any).focus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2020-02-09 04:31:17 -08:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
.mk-home {
|
2020-02-18 11:08:35 -08:00
|
|
|
> .new {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 1000;
|
|
|
|
|
|
|
|
> button {
|
|
|
|
display: block;
|
|
|
|
margin: 0 auto;
|
2020-02-19 13:08:54 -08:00
|
|
|
padding: 8px 16px;
|
2020-02-18 11:08:35 -08:00
|
|
|
border-radius: 32px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-09 05:25:32 -08:00
|
|
|
> .tutorial {
|
2020-02-09 04:31:17 -08:00
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
|
|
|
|
2020-02-18 10:16:10 -08:00
|
|
|
> .post-form {
|
|
|
|
position: relative;
|
|
|
|
margin-bottom: var(--margin);
|
|
|
|
}
|
2020-02-18 10:11:09 -08:00
|
|
|
}
|
|
|
|
|
2020-01-29 11:37:25 -08:00
|
|
|
._kjvfvyph_ {
|
|
|
|
position: relative;
|
|
|
|
height: 100%;
|
|
|
|
padding: 0 16px;
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
|
|
> i {
|
|
|
|
position: absolute;
|
2020-07-12 01:43:35 -07:00
|
|
|
top: initial;
|
2020-01-29 11:37:25 -08:00
|
|
|
right: 8px;
|
2020-02-16 14:14:03 -08:00
|
|
|
color: var(--indicator);
|
2020-01-29 11:37:25 -08:00
|
|
|
font-size: 12px;
|
|
|
|
animation: blink 1s infinite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|