2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-08-18 15:44:21 +02:00
|
|
|
<template>
|
2022-06-20 10:38:49 +02:00
|
|
|
<MkStickyContainer>
|
2023-02-25 10:26:35 +01:00
|
|
|
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
|
2023-05-19 09:20:53 +02:00
|
|
|
<MkSpacer :contentMax="700" :class="$style.main">
|
2023-03-04 02:50:21 +01:00
|
|
|
<div v-if="channel && tab === 'overview'" class="_gaps">
|
|
|
|
<div class="_panel" :class="$style.bannerContainer">
|
|
|
|
<XChannelFollowButton :channel="channel" :full="true" :class="$style.subscribe"/>
|
2023-05-19 09:20:53 +02:00
|
|
|
<MkButton v-if="favorited" v-tooltip="i18n.ts.unfavorite" asLike class="button" rounded primary :class="$style.favorite" @click="unfavorite()"><i class="ti ti-star"></i></MkButton>
|
|
|
|
<MkButton v-else v-tooltip="i18n.ts.favorite" asLike class="button" rounded :class="$style.favorite" @click="favorite()"><i class="ti ti-star"></i></MkButton>
|
2023-12-22 12:41:42 +01:00
|
|
|
<div :style="{ backgroundImage: channel.bannerUrl ? `url(${channel.bannerUrl})` : undefined }" :class="$style.banner">
|
2023-03-04 02:50:21 +01:00
|
|
|
<div :class="$style.bannerStatus">
|
2022-12-19 11:01:30 +01:00
|
|
|
<div><i class="ti ti-users ti-fw"></i><I18n :src="i18n.ts._channel.usersCount" tag="span" style="margin-left: 4px;"><template #n><b>{{ channel.usersCount }}</b></template></I18n></div>
|
|
|
|
<div><i class="ti ti-pencil ti-fw"></i><I18n :src="i18n.ts._channel.notesCount" tag="span" style="margin-left: 4px;"><template #n><b>{{ channel.notesCount }}</b></template></I18n></div>
|
2022-06-20 10:38:49 +02:00
|
|
|
</div>
|
2023-08-05 06:58:31 +02:00
|
|
|
<div v-if="channel.isSensitive" :class="$style.sensitiveIndicator">{{ i18n.ts.sensitive }}</div>
|
2023-03-04 02:50:21 +01:00
|
|
|
<div :class="$style.bannerFade"></div>
|
2022-06-20 10:38:49 +02:00
|
|
|
</div>
|
2023-03-04 02:50:21 +01:00
|
|
|
<div v-if="channel.description" :class="$style.description">
|
2023-11-04 10:27:22 +01:00
|
|
|
<Mfm :text="channel.description" :isNote="false"/>
|
2021-12-23 08:10:13 +01:00
|
|
|
</div>
|
2020-08-18 15:44:21 +02:00
|
|
|
</div>
|
2023-03-31 04:30:27 +02:00
|
|
|
|
2023-03-31 08:01:56 +02:00
|
|
|
<MkFoldableSection>
|
|
|
|
<template #header><i class="ti ti-pin ti-fw" style="margin-right: 0.5em;"></i>{{ i18n.ts.pinnedNotes }}</template>
|
2023-12-22 12:41:42 +01:00
|
|
|
<div v-if="channel.pinnedNotes && channel.pinnedNotes.length > 0" class="_gaps">
|
2023-03-31 08:01:56 +02:00
|
|
|
<MkNote v-for="note in channel.pinnedNotes" :key="note.id" class="_panel" :note="note"/>
|
|
|
|
</div>
|
|
|
|
</MkFoldableSection>
|
2023-03-04 02:50:21 +01:00
|
|
|
</div>
|
|
|
|
<div v-if="channel && tab === 'timeline'" class="_gaps">
|
2023-05-06 01:15:17 +02:00
|
|
|
<MkInfo v-if="channel.isArchived" warn>{{ i18n.ts.thisChannelArchived }}</MkInfo>
|
|
|
|
|
2023-02-24 02:31:21 +01:00
|
|
|
<!-- スマホ・タブレットの場合、キーボードが表示されると投稿が見づらくなるので、デスクトップ場合のみ自動でフォーカスを当てる -->
|
2023-03-04 02:34:54 +01:00
|
|
|
<MkPostForm v-if="$i && defaultStore.reactiveState.showFixedPostFormInChannel.value" :channel="channel" class="post-form _panel" fixed :autofocus="deviceKind === 'desktop'"/>
|
2020-08-18 15:44:21 +02:00
|
|
|
|
2023-12-22 12:41:42 +01:00
|
|
|
<MkTimeline :key="channelId" src="channel" :channel="channelId" @before="before" @after="after" @note="miLocalStorage.setItemAsJson(`channelLastReadedAt:${channel.id}`, Date.now())"/>
|
2023-02-25 10:26:35 +01:00
|
|
|
</div>
|
|
|
|
<div v-else-if="tab === 'featured'">
|
|
|
|
<MkNotes :pagination="featuredPagination"/>
|
2022-06-20 10:38:49 +02:00
|
|
|
</div>
|
2023-05-05 03:05:33 +02:00
|
|
|
<div v-else-if="tab === 'search'">
|
|
|
|
<div class="_gaps">
|
|
|
|
<div>
|
2023-12-27 23:58:32 +01:00
|
|
|
<MkInput v-model="searchQuery" @enter="search()">
|
2023-05-05 03:05:33 +02:00
|
|
|
<template #prefix><i class="ti ti-search"></i></template>
|
|
|
|
</MkInput>
|
|
|
|
<MkButton primary rounded style="margin-top: 8px;" @click="search()">{{ i18n.ts.search }}</MkButton>
|
|
|
|
</div>
|
2023-05-11 09:29:34 +02:00
|
|
|
<MkNotes v-if="searchPagination" :key="searchKey" :pagination="searchPagination"/>
|
2023-05-05 03:05:33 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-20 10:38:49 +02:00
|
|
|
</MkSpacer>
|
2023-03-04 02:34:54 +01:00
|
|
|
<template #footer>
|
|
|
|
<div :class="$style.footer">
|
2023-05-19 09:20:53 +02:00
|
|
|
<MkSpacer :contentMax="700" :marginMin="16" :marginMax="16">
|
2023-03-04 02:34:54 +01:00
|
|
|
<div class="_buttonsCenter">
|
|
|
|
<MkButton inline rounded primary gradate @click="openPostForm()"><i class="ti ti-pencil"></i> {{ i18n.ts.postToTheChannel }}</MkButton>
|
|
|
|
</div>
|
|
|
|
</MkSpacer>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-06-20 10:38:49 +02:00
|
|
|
</MkStickyContainer>
|
2020-08-18 15:44:21 +02:00
|
|
|
</template>
|
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 06:42:09 +01:00
|
|
|
import { computed, watch, ref } from 'vue';
|
2023-12-22 12:41:42 +01:00
|
|
|
import * as Misskey from 'misskey-js';
|
2023-02-09 02:35:28 +01:00
|
|
|
import MkPostForm from '@/components/MkPostForm.vue';
|
2023-02-22 03:00:34 +01:00
|
|
|
import MkTimeline from '@/components/MkTimeline.vue';
|
2022-08-30 17:24:33 +02:00
|
|
|
import XChannelFollowButton from '@/components/MkChannelFollowButton.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import * as os from '@/os.js';
|
|
|
|
import { useRouter } from '@/router.js';
|
|
|
|
import { $i, iAmModerator } from '@/account.js';
|
|
|
|
import { i18n } from '@/i18n.js';
|
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
|
|
|
import { deviceKind } from '@/scripts/device-kind.js';
|
2023-02-25 10:26:35 +01:00
|
|
|
import MkNotes from '@/components/MkNotes.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { url } from '@/config.js';
|
2023-03-04 02:34:54 +01:00
|
|
|
import MkButton from '@/components/MkButton.vue';
|
2023-05-05 03:05:33 +02:00
|
|
|
import MkInput from '@/components/MkInput.vue';
|
2023-09-19 09:37:43 +02:00
|
|
|
import { defaultStore } from '@/store.js';
|
2023-03-31 08:01:56 +02:00
|
|
|
import MkNote from '@/components/MkNote.vue';
|
2023-05-06 01:15:17 +02:00
|
|
|
import MkInfo from '@/components/MkInfo.vue';
|
2023-03-31 08:01:56 +02:00
|
|
|
import MkFoldableSection from '@/components/MkFoldableSection.vue';
|
2023-11-30 00:15:13 +01:00
|
|
|
import { PageHeaderItem } from '@/types/page-header.js';
|
|
|
|
import { isSupportShare } from '@/scripts/navigator.js';
|
|
|
|
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
|
2023-12-22 12:41:42 +01:00
|
|
|
import { miLocalStorage } from '@/local-storage.js';
|
2020-08-18 15:44:21 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const router = useRouter();
|
2020-08-18 15:44:21 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
const props = defineProps<{
|
|
|
|
channelId: string;
|
|
|
|
}>();
|
2020-08-18 15:44:21 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const tab = ref('overview');
|
2023-12-22 12:41:42 +01:00
|
|
|
const channel = ref<Misskey.entities.Channel | null>(null);
|
2023-12-07 06:42:09 +01:00
|
|
|
const favorited = ref(false);
|
|
|
|
const searchQuery = ref('');
|
|
|
|
const searchPagination = ref();
|
|
|
|
const searchKey = ref('');
|
|
|
|
const featuredPagination = computed(() => ({
|
2023-02-25 10:26:35 +01:00
|
|
|
endpoint: 'notes/featured' as const,
|
2022-06-20 10:38:49 +02:00
|
|
|
limit: 10,
|
2023-02-25 10:26:35 +01:00
|
|
|
params: {
|
2022-06-20 10:38:49 +02:00
|
|
|
channelId: props.channelId,
|
2023-02-25 10:26:35 +01:00
|
|
|
},
|
|
|
|
}));
|
2020-08-18 15:44:21 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
watch(() => props.channelId, async () => {
|
2023-12-07 06:42:09 +01:00
|
|
|
channel.value = await os.api('channels/show', {
|
2022-06-20 10:38:49 +02:00
|
|
|
channelId: props.channelId,
|
|
|
|
});
|
2023-12-22 12:41:42 +01:00
|
|
|
favorited.value = channel.value.isFavorited ?? false;
|
2023-12-07 06:42:09 +01:00
|
|
|
if (favorited.value || channel.value.isFollowing) {
|
|
|
|
tab.value = 'timeline';
|
2023-07-10 06:30:41 +02:00
|
|
|
}
|
2023-12-22 12:41:42 +01:00
|
|
|
|
|
|
|
if ((favorited.value || channel.value.isFollowing) && channel.value.lastNotedAt) {
|
|
|
|
const lastReadedAt: number = miLocalStorage.getItemAsJson(`channelLastReadedAt:${channel.value.id}`) ?? 0;
|
|
|
|
const lastNotedAt = Date.parse(channel.value.lastNotedAt);
|
|
|
|
|
|
|
|
if (lastNotedAt > lastReadedAt) {
|
|
|
|
miLocalStorage.setItemAsJson(`channelLastReadedAt:${channel.value.id}`, lastNotedAt);
|
|
|
|
}
|
|
|
|
}
|
2022-06-20 10:38:49 +02:00
|
|
|
}, { immediate: true });
|
2020-08-18 15:44:21 +02:00
|
|
|
|
2022-06-20 10:38:49 +02:00
|
|
|
function edit() {
|
2023-12-22 12:41:42 +01:00
|
|
|
router.push(`/channels/${channel.value?.id}/edit`);
|
2022-06-20 10:38:49 +02:00
|
|
|
}
|
|
|
|
|
2023-03-04 02:34:54 +01:00
|
|
|
function openPostForm() {
|
|
|
|
os.post({
|
2023-12-07 06:42:09 +01:00
|
|
|
channel: channel.value,
|
2023-03-04 02:34:54 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-03-31 04:30:27 +02:00
|
|
|
function favorite() {
|
2023-12-22 12:41:42 +01:00
|
|
|
if (!channel.value) return;
|
|
|
|
|
2023-03-31 04:30:27 +02:00
|
|
|
os.apiWithDialog('channels/favorite', {
|
2023-12-07 06:42:09 +01:00
|
|
|
channelId: channel.value.id,
|
2023-03-31 04:30:27 +02:00
|
|
|
}).then(() => {
|
2023-12-07 06:42:09 +01:00
|
|
|
favorited.value = true;
|
2023-03-31 04:30:27 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async function unfavorite() {
|
2023-12-22 12:41:42 +01:00
|
|
|
if (!channel.value) return;
|
|
|
|
|
2023-03-31 04:30:27 +02:00
|
|
|
const confirm = await os.confirm({
|
|
|
|
type: 'warning',
|
|
|
|
text: i18n.ts.unfavoriteConfirm,
|
|
|
|
});
|
|
|
|
if (confirm.canceled) return;
|
|
|
|
os.apiWithDialog('channels/unfavorite', {
|
2023-12-07 06:42:09 +01:00
|
|
|
channelId: channel.value.id,
|
2023-03-31 04:30:27 +02:00
|
|
|
}).then(() => {
|
2023-12-07 06:42:09 +01:00
|
|
|
favorited.value = false;
|
2023-03-31 04:30:27 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-05-05 03:05:33 +02:00
|
|
|
async function search() {
|
2023-12-22 12:41:42 +01:00
|
|
|
if (!channel.value) return;
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const query = searchQuery.value.toString().trim();
|
2023-05-05 03:05:33 +02:00
|
|
|
|
|
|
|
if (query == null) return;
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
searchPagination.value = {
|
2023-05-05 03:05:33 +02:00
|
|
|
endpoint: 'notes/search',
|
|
|
|
limit: 10,
|
|
|
|
params: {
|
2023-05-11 09:29:34 +02:00
|
|
|
query: query,
|
2023-12-07 06:42:09 +01:00
|
|
|
channelId: channel.value.id,
|
2023-05-05 03:05:33 +02:00
|
|
|
},
|
|
|
|
};
|
2023-05-11 09:29:34 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
searchKey.value = query;
|
2023-05-05 03:05:33 +02:00
|
|
|
}
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerActions = computed(() => {
|
|
|
|
if (channel.value && channel.value.userId) {
|
2023-11-30 00:15:13 +01:00
|
|
|
const headerItems: PageHeaderItem[] = [];
|
|
|
|
|
|
|
|
headerItems.push({
|
|
|
|
icon: 'ti ti-link',
|
|
|
|
text: i18n.ts.copyUrl,
|
2023-03-08 23:58:53 +01:00
|
|
|
handler: async (): Promise<void> => {
|
2023-12-22 12:41:42 +01:00
|
|
|
if (!channel.value) {
|
|
|
|
console.warn('failed to copy channel URL. channel.value is null.');
|
|
|
|
return;
|
|
|
|
}
|
2023-12-07 06:42:09 +01:00
|
|
|
copyToClipboard(`${url}/channels/${channel.value.id}`);
|
2023-11-30 00:15:13 +01:00
|
|
|
os.success();
|
2023-03-08 23:58:53 +01:00
|
|
|
},
|
2023-11-30 00:15:13 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
if (isSupportShare()) {
|
|
|
|
headerItems.push({
|
|
|
|
icon: 'ti ti-share',
|
|
|
|
text: i18n.ts.share,
|
|
|
|
handler: async (): Promise<void> => {
|
2023-12-22 12:41:42 +01:00
|
|
|
if (!channel.value) {
|
|
|
|
console.warn('failed to share channel. channel.value is null.');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-11-30 00:15:13 +01:00
|
|
|
navigator.share({
|
2023-12-07 06:42:09 +01:00
|
|
|
title: channel.value.name,
|
2023-12-22 12:41:42 +01:00
|
|
|
text: channel.value.description ?? undefined,
|
2023-12-07 06:42:09 +01:00
|
|
|
url: `${url}/channels/${channel.value.id}`,
|
2023-11-30 00:15:13 +01:00
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
if (($i && $i.id === channel.value.userId) || iAmModerator) {
|
2023-11-30 00:15:13 +01:00
|
|
|
headerItems.push({
|
|
|
|
icon: 'ti ti-settings',
|
|
|
|
text: i18n.ts.edit,
|
|
|
|
handler: edit,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return headerItems.length > 0 ? headerItems : null;
|
2023-03-08 23:58:53 +01:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
});
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
const headerTabs = computed(() => [{
|
2023-03-04 02:50:21 +01:00
|
|
|
key: 'overview',
|
|
|
|
title: i18n.ts.overview,
|
|
|
|
icon: 'ti ti-info-circle',
|
|
|
|
}, {
|
2023-02-25 10:26:35 +01:00
|
|
|
key: 'timeline',
|
|
|
|
title: i18n.ts.timeline,
|
|
|
|
icon: 'ti ti-home',
|
|
|
|
}, {
|
|
|
|
key: 'featured',
|
|
|
|
title: i18n.ts.featured,
|
|
|
|
icon: 'ti ti-bolt',
|
2023-05-05 03:05:33 +02:00
|
|
|
}, {
|
|
|
|
key: 'search',
|
|
|
|
title: i18n.ts.search,
|
|
|
|
icon: 'ti ti-search',
|
2023-02-25 10:26:35 +01:00
|
|
|
}]);
|
2022-06-20 10:38:49 +02:00
|
|
|
|
2023-12-07 06:42:09 +01:00
|
|
|
definePageMetadata(computed(() => channel.value ? {
|
|
|
|
title: channel.value.name,
|
2022-12-19 11:01:30 +01:00
|
|
|
icon: 'ti ti-device-tv',
|
2022-06-20 10:38:49 +02:00
|
|
|
} : null));
|
2020-08-18 15:44:21 +02:00
|
|
|
</script>
|
|
|
|
|
2023-03-04 02:34:54 +01:00
|
|
|
<style lang="scss" module>
|
2023-03-04 02:50:21 +01:00
|
|
|
.main {
|
2023-05-08 11:30:40 +02:00
|
|
|
min-height: calc(100cqh - (var(--stickyTop, 0px) + var(--stickyBottom, 0px)));
|
2023-03-04 02:50:21 +01:00
|
|
|
}
|
|
|
|
|
2023-03-04 02:34:54 +01:00
|
|
|
.footer {
|
|
|
|
-webkit-backdrop-filter: var(--blur, blur(15px));
|
|
|
|
backdrop-filter: var(--blur, blur(15px));
|
|
|
|
border-top: solid 0.5px var(--divider);
|
|
|
|
}
|
|
|
|
|
2023-03-04 02:50:21 +01:00
|
|
|
.bannerContainer {
|
2020-10-18 05:16:42 +02:00
|
|
|
position: relative;
|
2023-03-04 02:50:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.subscribe {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
top: 16px;
|
|
|
|
left: 16px;
|
|
|
|
}
|
|
|
|
|
2023-05-16 05:28:59 +02:00
|
|
|
.favorite {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
top: 16px;
|
|
|
|
right: 16px;
|
|
|
|
}
|
|
|
|
|
2023-03-04 02:50:21 +01:00
|
|
|
.banner {
|
|
|
|
position: relative;
|
|
|
|
height: 200px;
|
|
|
|
background-position: center;
|
|
|
|
background-size: cover;
|
|
|
|
}
|
|
|
|
|
|
|
|
.bannerFade {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 0;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
height: 64px;
|
|
|
|
background: linear-gradient(0deg, var(--panel), var(--X15));
|
|
|
|
}
|
|
|
|
|
|
|
|
.bannerStatus {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
bottom: 16px;
|
|
|
|
right: 16px;
|
|
|
|
padding: 8px 12px;
|
|
|
|
font-size: 80%;
|
|
|
|
background: rgba(0, 0, 0, 0.7);
|
|
|
|
border-radius: 6px;
|
|
|
|
color: #fff;
|
|
|
|
}
|
2020-10-18 05:16:42 +02:00
|
|
|
|
2023-03-04 02:50:21 +01:00
|
|
|
.description {
|
|
|
|
padding: 16px;
|
2020-08-18 15:44:21 +02:00
|
|
|
}
|
2023-08-05 06:58:31 +02:00
|
|
|
|
|
|
|
.sensitiveIndicator {
|
|
|
|
position: absolute;
|
|
|
|
z-index: 1;
|
|
|
|
bottom: 16px;
|
|
|
|
left: 16px;
|
|
|
|
background: rgba(0, 0, 0, 0.7);
|
|
|
|
color: var(--warn);
|
|
|
|
border-radius: 6px;
|
|
|
|
font-weight: bold;
|
|
|
|
font-size: 1em;
|
|
|
|
padding: 4px 7px;
|
|
|
|
}
|
2020-08-18 15:44:21 +02:00
|
|
|
</style>
|