2023-07-27 05:31:52 +00:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2023-02-09 01:35:28 +00:00
|
|
|
<template>
|
2023-11-10 08:49:09 +00:00
|
|
|
<XColumn :menu="menu" :column="column" :isStacked="isStacked" :refresher="() => timeline.reloadTimeline()">
|
2023-02-09 01:35:28 +00:00
|
|
|
<template #header>
|
2023-09-30 19:53:52 +00:00
|
|
|
<i class="ph-television ph-bold ph-lg"></i><span style="margin-left: 8px;">{{ column.name }}</span>
|
2023-02-09 01:35:28 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-if="column.channelId">
|
|
|
|
<div style="padding: 8px; text-align: center;">
|
2023-09-30 19:53:52 +00:00
|
|
|
<MkButton primary gradate rounded inline @click="post"><i class="ph-pencil ph-bold ph-lg"></i></MkButton>
|
2023-02-09 01:35:28 +00:00
|
|
|
</div>
|
2023-05-29 08:24:46 +00:00
|
|
|
<MkTimeline ref="timeline" src="channel" :channel="column.channelId"/>
|
2023-02-09 01:35:28 +00:00
|
|
|
</template>
|
|
|
|
</XColumn>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2023-09-04 04:33:38 +00:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-02-09 01:35:28 +00:00
|
|
|
import XColumn from './column.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import { updateColumn, Column } from './deck-store.js';
|
2023-02-22 02:00:34 +00:00
|
|
|
import MkTimeline from '@/components/MkTimeline.vue';
|
2023-02-09 01:35:28 +00:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-09-19 07:37:43 +00:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
2023-02-09 01:35:28 +00:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
column: Column;
|
|
|
|
isStacked: boolean;
|
|
|
|
}>();
|
|
|
|
|
2023-02-22 02:00:34 +00:00
|
|
|
let timeline = $shallowRef<InstanceType<typeof MkTimeline>>();
|
2023-09-04 04:33:38 +00:00
|
|
|
let channel = $shallowRef<Misskey.entities.Channel>();
|
2023-02-09 01:35:28 +00:00
|
|
|
|
|
|
|
if (props.column.channelId == null) {
|
|
|
|
setChannel();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function setChannel() {
|
2023-04-18 04:29:45 +00:00
|
|
|
const channels = await os.api('channels/my-favorites', {
|
2023-02-17 05:59:11 +00:00
|
|
|
limit: 100,
|
|
|
|
});
|
2023-02-09 01:35:28 +00:00
|
|
|
const { canceled, result: channel } = await os.select({
|
|
|
|
title: i18n.ts.selectChannel,
|
|
|
|
items: channels.map(x => ({
|
|
|
|
value: x, text: x.name,
|
|
|
|
})),
|
|
|
|
default: props.column.channelId,
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
updateColumn(props.column.id, {
|
|
|
|
channelId: channel.id,
|
|
|
|
name: channel.name,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-04-05 05:30:03 +00:00
|
|
|
async function post() {
|
|
|
|
if (!channel || channel.id !== props.column.channelId) {
|
|
|
|
channel = await os.api('channels/show', {
|
|
|
|
channelId: props.column.channelId,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-02-09 01:35:28 +00:00
|
|
|
os.post({
|
2023-04-05 05:30:03 +00:00
|
|
|
channel,
|
2023-02-09 01:35:28 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const menu = [{
|
2023-09-30 19:53:52 +00:00
|
|
|
icon: 'ph-pencil ph-bold ph-lg',
|
2023-02-09 01:35:28 +00:00
|
|
|
text: i18n.ts.selectChannel,
|
|
|
|
action: setChannel,
|
|
|
|
}];
|
|
|
|
</script>
|