From 3cb0cc798914ff9057f4032a9b79e21402f72ec8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 31 Mar 2023 11:30:27 +0900 Subject: feat: チャンネルをお気に入りに登録できるように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve #10097 --- packages/frontend/src/pages/channel.vue | 26 ++++++++++++++++++++++++++ packages/frontend/src/pages/channels.vue | 25 +++++++++++++++++++------ packages/frontend/src/pages/timeline.vue | 2 +- 3 files changed, 46 insertions(+), 7 deletions(-) (limited to 'packages/frontend/src/pages') diff --git a/packages/frontend/src/pages/channel.vue b/packages/frontend/src/pages/channel.vue index 76f11faab8..0fee2181db 100644 --- a/packages/frontend/src/pages/channel.vue +++ b/packages/frontend/src/pages/channel.vue @@ -16,6 +16,9 @@ + + +
@@ -63,6 +66,7 @@ const props = defineProps<{ let tab = $ref('timeline'); let channel = $ref(null); +let favorited = $ref(false); const featuredPagination = $computed(() => ({ endpoint: 'notes/featured' as const, limit: 10, @@ -76,6 +80,7 @@ watch(() => props.channelId, async () => { channel = await os.api('channels/show', { channelId: props.channelId, }); + favorited = channel.isFavorited; }, { immediate: true }); function edit() { @@ -90,6 +95,27 @@ function openPostForm() { }); } +function favorite() { + os.apiWithDialog('channels/favorite', { + channelId: channel.id, + }).then(() => { + favorited = true; + }); +} + +async function unfavorite() { + const confirm = await os.confirm({ + type: 'warning', + text: i18n.ts.unfavoriteConfirm, + }); + if (confirm.canceled) return; + os.apiWithDialog('channels/unfavorite', { + channelId: channel.id, + }).then(() => { + favorited = false; + }); +} + const headerActions = $computed(() => { if (channel && channel.userId) { const share = { diff --git a/packages/frontend/src/pages/channels.vue b/packages/frontend/src/pages/channels.vue index 3550c7f436..fd1d2d03cf 100644 --- a/packages/frontend/src/pages/channels.vue +++ b/packages/frontend/src/pages/channels.vue @@ -2,17 +2,22 @@ -