2020-07-10 20:13:11 -05:00
|
|
|
<template>
|
2022-07-16 15:33:21 -05:00
|
|
|
<XColumn :menu="menu" :column="column" :is-stacked="isStacked" :indicated="indicated" @change-active-state="onChangeActiveState" @parent-focus="$event => emit('parent-focus', $event)">
|
2020-07-10 20:13:11 -05:00
|
|
|
<template #header>
|
2021-04-20 09:22:59 -05:00
|
|
|
<i v-if="column.tl === 'home'" class="fas fa-home"></i>
|
|
|
|
<i v-else-if="column.tl === 'local'" class="fas fa-comments"></i>
|
|
|
|
<i v-else-if="column.tl === 'social'" class="fas fa-share-alt"></i>
|
|
|
|
<i v-else-if="column.tl === 'global'" class="fas fa-globe"></i>
|
2020-07-10 20:13:11 -05:00
|
|
|
<span style="margin-left: 8px;">{{ column.name }}</span>
|
|
|
|
</template>
|
|
|
|
|
2021-11-19 04:36:12 -06:00
|
|
|
<div v-if="disabled" class="iwaalbte">
|
2020-07-10 20:13:11 -05:00
|
|
|
<p>
|
2021-04-20 09:22:59 -05:00
|
|
|
<i class="fas fa-minus-circle"></i>
|
2020-07-10 20:13:11 -05:00
|
|
|
{{ $t('disabled-timeline.title') }}
|
|
|
|
</p>
|
|
|
|
<p class="desc">{{ $t('disabled-timeline.description') }}</p>
|
|
|
|
</div>
|
2022-03-20 13:11:14 -05:00
|
|
|
<XTimeline v-else-if="column.tl" ref="timeline" :key="column.tl" :src="column.tl" @after="() => emit('loaded')" @queue="queueUpdated" @note="onNote"/>
|
2020-10-17 06:12:00 -05:00
|
|
|
</XColumn>
|
2020-07-10 20:13:11 -05:00
|
|
|
</template>
|
|
|
|
|
2022-03-20 13:11:14 -05:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { onMounted } from 'vue';
|
2020-07-10 20:13:11 -05:00
|
|
|
import XColumn from './column.vue';
|
2022-07-16 15:33:21 -05:00
|
|
|
import { removeColumn, updateColumn, Column } from './deck-store';
|
2022-08-30 10:24:33 -05:00
|
|
|
import XTimeline from '@/components/MkTimeline.vue';
|
2021-11-11 11:02:25 -06:00
|
|
|
import * as os from '@/os';
|
2022-03-20 13:11:14 -05:00
|
|
|
import { $i } from '@/account';
|
|
|
|
import { instance } from '@/instance';
|
|
|
|
import { i18n } from '@/i18n';
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
column: Column;
|
|
|
|
isStacked: boolean;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2022-05-19 03:35:43 -05:00
|
|
|
(ev: 'loaded'): void;
|
|
|
|
(ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void;
|
2022-03-20 13:11:14 -05:00
|
|
|
}>();
|
|
|
|
|
|
|
|
let disabled = $ref(false);
|
|
|
|
let indicated = $ref(false);
|
|
|
|
let columnActive = $ref(true);
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
if (props.column.tl == null) {
|
|
|
|
setType();
|
|
|
|
} else if ($i) {
|
|
|
|
disabled = !$i.isModerator && !$i.isAdmin && (
|
|
|
|
instance.disableLocalTimeline && ['local', 'social'].includes(props.column.tl) ||
|
|
|
|
instance.disableGlobalTimeline && ['global'].includes(props.column.tl));
|
|
|
|
}
|
|
|
|
});
|
2020-07-10 20:13:11 -05:00
|
|
|
|
2022-03-20 13:11:14 -05:00
|
|
|
async function setType() {
|
|
|
|
const { canceled, result: src } = await os.select({
|
|
|
|
title: i18n.ts.timeline,
|
|
|
|
items: [{
|
2022-07-16 15:33:21 -05:00
|
|
|
value: 'home' as const, text: i18n.ts._timelines.home,
|
2022-03-20 13:11:14 -05:00
|
|
|
}, {
|
2022-07-16 15:33:21 -05:00
|
|
|
value: 'local' as const, text: i18n.ts._timelines.local,
|
2022-03-20 13:11:14 -05:00
|
|
|
}, {
|
2022-07-16 15:33:21 -05:00
|
|
|
value: 'social' as const, text: i18n.ts._timelines.social,
|
2022-03-20 13:11:14 -05:00
|
|
|
}, {
|
2022-07-16 15:33:21 -05:00
|
|
|
value: 'global' as const, text: i18n.ts._timelines.global,
|
2022-03-20 13:11:14 -05:00
|
|
|
}],
|
|
|
|
});
|
|
|
|
if (canceled) {
|
|
|
|
if (props.column.tl == null) {
|
|
|
|
removeColumn(props.column.id);
|
2020-07-10 20:13:11 -05:00
|
|
|
}
|
2022-03-20 13:11:14 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
updateColumn(props.column.id, {
|
2022-07-16 15:33:21 -05:00
|
|
|
tl: src,
|
2022-03-20 13:11:14 -05:00
|
|
|
});
|
|
|
|
}
|
2020-07-10 20:13:11 -05:00
|
|
|
|
2022-03-20 13:11:14 -05:00
|
|
|
function queueUpdated(q) {
|
|
|
|
if (columnActive) {
|
|
|
|
indicated = q !== 0;
|
|
|
|
}
|
|
|
|
}
|
2020-07-10 20:13:11 -05:00
|
|
|
|
2022-03-20 13:11:14 -05:00
|
|
|
function onNote() {
|
|
|
|
if (!columnActive) {
|
|
|
|
indicated = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onChangeActiveState(state) {
|
|
|
|
columnActive = state;
|
|
|
|
|
|
|
|
if (columnActive) {
|
|
|
|
indicated = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-16 15:33:21 -05:00
|
|
|
const menu = [{
|
|
|
|
icon: 'fas fa-pencil-alt',
|
|
|
|
text: i18n.ts.timeline,
|
|
|
|
action: setType,
|
|
|
|
}];
|
2020-07-10 20:13:11 -05:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.iwaalbte {
|
|
|
|
text-align: center;
|
|
|
|
|
|
|
|
> p {
|
|
|
|
margin: 16px;
|
|
|
|
|
|
|
|
&.desc {
|
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|