2020-01-29 20:37:25 +01:00
|
|
|
<template>
|
2021-11-19 11:36:12 +01:00
|
|
|
<div v-size="{ min: [800] }" v-hotkey.global="keymap" class="cmuxhskf">
|
2021-10-23 21:03:07 +02: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-10-09 05:33:08 +02:00
|
|
|
|
2021-11-19 11:36:12 +01:00
|
|
|
<div v-if="queue > 0" class="new"><button class="_buttonPrimary" @click="top()">{{ $ts.newNoteRecived }}</button></div>
|
2021-10-23 21:03:07 +02:00
|
|
|
<div class="tl _block">
|
2021-11-19 11:36:12 +01:00
|
|
|
<XTimeline ref="tl" :key="src"
|
|
|
|
class="tl"
|
2021-10-23 21:03:07 +02:00
|
|
|
:src="src"
|
|
|
|
:sound="true"
|
|
|
|
@before="before()"
|
|
|
|
@after="after()"
|
|
|
|
@queue="queueUpdated"
|
|
|
|
/>
|
2021-08-21 10:40:15 +02:00
|
|
|
</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';
|
2021-11-11 18:02:25 +01: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';
|
|
|
|
import * as symbols from '@/symbols';
|
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',
|
2020-02-18 20:08:35 +01:00
|
|
|
queue: 0,
|
2021-04-10 05:54:12 +02:00
|
|
|
[symbols.PAGE_INFO]: computed(() => ({
|
2020-12-29 03:33:21 +01:00
|
|
|
title: this.$ts.timeline,
|
2021-04-20 16:22:59 +02: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 15:39:15 +02:00
|
|
|
bg: 'var(--bg)',
|
2021-04-10 06:38:24 +02:00
|
|
|
actions: [{
|
2021-09-18 08:39:01 +02:00
|
|
|
icon: 'fas fa-list-ul',
|
|
|
|
text: this.$ts.lists,
|
|
|
|
handler: this.chooseList
|
|
|
|
}, {
|
|
|
|
icon: 'fas fa-satellite',
|
|
|
|
text: this.$ts.antennas,
|
|
|
|
handler: this.chooseAntenna
|
|
|
|
}, {
|
|
|
|
icon: 'fas fa-satellite-dish',
|
|
|
|
text: this.$ts.channel,
|
|
|
|
handler: this.chooseChannel
|
|
|
|
}, {
|
2021-04-20 16:22:59 +02:00
|
|
|
icon: 'fas fa-calendar-alt',
|
2021-04-10 06:38:24 +02:00
|
|
|
text: this.$ts.jumpToSpecifiedDate,
|
|
|
|
handler: this.timetravel
|
2021-09-17 15:39:15 +02:00
|
|
|
}],
|
|
|
|
tabs: [{
|
|
|
|
active: this.src === 'home',
|
|
|
|
title: this.$ts._timelines.home,
|
|
|
|
icon: 'fas fa-home',
|
|
|
|
iconOnly: true,
|
|
|
|
onClick: () => { this.src = 'home'; this.saveSrc(); },
|
2021-11-30 15:03:03 +01:00
|
|
|
}, ...(this.isLocalTimelineAvailable ? [{
|
2021-09-17 15:39:15 +02:00
|
|
|
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(); },
|
2021-11-30 15:03:03 +01:00
|
|
|
}] : []), ...(this.isGlobalTimelineAvailable ? [{
|
2021-09-17 15:39:15 +02:00
|
|
|
active: this.src === 'global',
|
|
|
|
title: this.$ts._timelines.global,
|
|
|
|
icon: 'fas fa-globe',
|
|
|
|
iconOnly: true,
|
|
|
|
onClick: () => { this.src = 'global'; this.saveSrc(); },
|
2021-11-30 15:03:03 +01:00
|
|
|
}] : [])],
|
2020-12-29 03:33:21 +01:00
|
|
|
})),
|
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
|
|
|
|
2020-12-29 08:58:14 +01: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 15:02:55 +01:00
|
|
|
},
|
2020-01-29 20:37:25 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
src() {
|
|
|
|
this.showNav = false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
created() {
|
2020-12-19 02:55:52 +01:00
|
|
|
this.src = this.$store.state.tl.src;
|
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) {
|
|
|
|
this.queue = q;
|
|
|
|
},
|
|
|
|
|
|
|
|
top() {
|
2021-10-09 05:33:08 +02:00
|
|
|
scroll(this.$el, { top: 0 });
|
2020-02-18 20:08:35 +01:00
|
|
|
},
|
|
|
|
|
2020-12-29 03:33:21 +01:00
|
|
|
async chooseList(ev) {
|
|
|
|
const lists = await os.api('users/lists/list');
|
|
|
|
const items = lists.map(list => ({
|
2021-09-21 14:04:59 +02:00
|
|
|
type: 'link',
|
2020-12-29 03:33:21 +01:00
|
|
|
text: list.name,
|
2021-09-21 14:04:59 +02:00
|
|
|
to: `/timeline/list/${list.id}`
|
2020-01-29 20:37:25 +01:00
|
|
|
}));
|
2021-08-08 05:19:10 +02:00
|
|
|
os.popupMenu(items, ev.currentTarget || ev.target);
|
2020-12-29 03:33:21 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
async chooseAntenna(ev) {
|
|
|
|
const antennas = await os.api('antennas/list');
|
|
|
|
const items = antennas.map(antenna => ({
|
2021-09-21 14:04:59 +02:00
|
|
|
type: 'link',
|
2020-12-29 03:33:21 +01:00
|
|
|
text: antenna.name,
|
|
|
|
indicate: antenna.hasUnreadNote,
|
2021-09-21 14:04:59 +02:00
|
|
|
to: `/timeline/antenna/${antenna.id}`
|
2020-08-18 15:44:21 +02:00
|
|
|
}));
|
2021-08-08 05:19:10 +02:00
|
|
|
os.popupMenu(items, ev.currentTarget || ev.target);
|
2020-12-29 03:33:21 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
async chooseChannel(ev) {
|
|
|
|
const channels = await os.api('channels/followed');
|
|
|
|
const items = channels.map(channel => ({
|
2021-09-21 14:04:59 +02:00
|
|
|
type: 'link',
|
2020-08-18 15:44:21 +02:00
|
|
|
text: channel.name,
|
|
|
|
indicate: channel.hasUnreadNote,
|
2021-09-21 14:04:59 +02:00
|
|
|
to: `/channels/${channel.id}`
|
2020-01-29 20:37:25 +01:00
|
|
|
}));
|
2021-08-08 05:19:10 +02:00
|
|
|
os.popupMenu(items, 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,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2021-04-10 05:40:50 +02:00
|
|
|
async timetravel() {
|
2021-11-18 10:45:58 +01:00
|
|
|
const { canceled, result: date } = await os.inputDate({
|
2021-04-10 05:40:50 +02:00
|
|
|
title: this.$ts.date,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
|
2021-11-18 10:45:58 +01:00
|
|
|
this.$refs.tl.timetravel(date);
|
2021-04-10 05:40:50 +02:00
|
|
|
},
|
|
|
|
|
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>
|
2020-12-29 03:33:21 +01:00
|
|
|
.cmuxhskf {
|
2021-09-17 15:39:15 +02:00
|
|
|
padding: var(--margin);
|
|
|
|
|
2020-02-18 20:08:35 +01:00
|
|
|
> .new {
|
2021-04-15 10:36:09 +02:00
|
|
|
position: sticky;
|
|
|
|
top: calc(var(--stickyTop, 0px) + 16px);
|
2020-02-18 20:08:35 +01:00
|
|
|
z-index: 1000;
|
2021-04-15 10:36:09 +02:00
|
|
|
width: 100%;
|
2020-02-18 20:08:35 +01:00
|
|
|
|
|
|
|
> 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-14 11:51:15 +02:00
|
|
|
> .post-form {
|
|
|
|
border-radius: var(--radius);
|
|
|
|
}
|
|
|
|
|
2021-09-17 15:39:15 +02:00
|
|
|
> .tl {
|
|
|
|
background: var(--bg);
|
|
|
|
border-radius: var(--radius);
|
|
|
|
overflow: clip;
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
2021-08-14 15:35:15 +02:00
|
|
|
|
2021-08-21 10:40:15 +02:00
|
|
|
&.min-width_800px {
|
2021-09-17 15:39:15 +02:00
|
|
|
max-width: 800px;
|
|
|
|
margin: 0 auto;
|
2021-08-14 15:35:15 +02:00
|
|
|
}
|
2020-01-29 20:37:25 +01:00
|
|
|
}
|
|
|
|
</style>
|