summaryrefslogtreecommitdiff
path: root/packages/frontend/src/ui/deck/tl-column.vue
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2022-12-27 14:36:33 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2022-12-27 14:36:33 +0900
commit9384f5399da39e53855beb8e7f8ded1aa56bf72e (patch)
treece5959571a981b9c4047da3c7b3fd080aa44222c /packages/frontend/src/ui/deck/tl-column.vue
parentwip: retention for dashboard (diff)
downloadmisskey-9384f5399da39e53855beb8e7f8ded1aa56bf72e.tar.gz
misskey-9384f5399da39e53855beb8e7f8ded1aa56bf72e.tar.bz2
misskey-9384f5399da39e53855beb8e7f8ded1aa56bf72e.zip
rename: client -> frontend
Diffstat (limited to 'packages/frontend/src/ui/deck/tl-column.vue')
-rw-r--r--packages/frontend/src/ui/deck/tl-column.vue119
1 files changed, 119 insertions, 0 deletions
diff --git a/packages/frontend/src/ui/deck/tl-column.vue b/packages/frontend/src/ui/deck/tl-column.vue
new file mode 100644
index 0000000000..49b29145ff
--- /dev/null
+++ b/packages/frontend/src/ui/deck/tl-column.vue
@@ -0,0 +1,119 @@
+<template>
+<XColumn :menu="menu" :column="column" :is-stacked="isStacked" :indicated="indicated" @change-active-state="onChangeActiveState" @parent-focus="$event => emit('parent-focus', $event)">
+ <template #header>
+ <i v-if="column.tl === 'home'" class="ti ti-home"></i>
+ <i v-else-if="column.tl === 'local'" class="ti ti-messages"></i>
+ <i v-else-if="column.tl === 'social'" class="ti ti-share"></i>
+ <i v-else-if="column.tl === 'global'" class="ti ti-world"></i>
+ <span style="margin-left: 8px;">{{ column.name }}</span>
+ </template>
+
+ <div v-if="disabled" class="iwaalbte">
+ <p>
+ <i class="ti ti-minus-circle"></i>
+ {{ $t('disabled-timeline.title') }}
+ </p>
+ <p class="desc">{{ $t('disabled-timeline.description') }}</p>
+ </div>
+ <XTimeline v-else-if="column.tl" ref="timeline" :key="column.tl" :src="column.tl" @after="() => emit('loaded')" @queue="queueUpdated" @note="onNote"/>
+</XColumn>
+</template>
+
+<script lang="ts" setup>
+import { onMounted } from 'vue';
+import XColumn from './column.vue';
+import { removeColumn, updateColumn, Column } from './deck-store';
+import XTimeline from '@/components/MkTimeline.vue';
+import * as os from '@/os';
+import { $i } from '@/account';
+import { instance } from '@/instance';
+import { i18n } from '@/i18n';
+
+const props = defineProps<{
+ column: Column;
+ isStacked: boolean;
+}>();
+
+const emit = defineEmits<{
+ (ev: 'loaded'): void;
+ (ev: 'parent-focus', direction: 'up' | 'down' | 'left' | 'right'): void;
+}>();
+
+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));
+ }
+});
+
+async function setType() {
+ const { canceled, result: src } = await os.select({
+ title: i18n.ts.timeline,
+ items: [{
+ value: 'home' as const, text: i18n.ts._timelines.home,
+ }, {
+ value: 'local' as const, text: i18n.ts._timelines.local,
+ }, {
+ value: 'social' as const, text: i18n.ts._timelines.social,
+ }, {
+ value: 'global' as const, text: i18n.ts._timelines.global,
+ }],
+ });
+ if (canceled) {
+ if (props.column.tl == null) {
+ removeColumn(props.column.id);
+ }
+ return;
+ }
+ updateColumn(props.column.id, {
+ tl: src,
+ });
+}
+
+function queueUpdated(q) {
+ if (columnActive) {
+ indicated = q !== 0;
+ }
+}
+
+function onNote() {
+ if (!columnActive) {
+ indicated = true;
+ }
+}
+
+function onChangeActiveState(state) {
+ columnActive = state;
+
+ if (columnActive) {
+ indicated = false;
+ }
+}
+
+const menu = [{
+ icon: 'ti ti-pencil',
+ text: i18n.ts.timeline,
+ action: setType,
+}];
+</script>
+
+<style lang="scss" scoped>
+.iwaalbte {
+ text-align: center;
+
+ > p {
+ margin: 16px;
+
+ &.desc {
+ font-size: 14px;
+ }
+ }
+}
+</style>