From 8db800ed98a4e8d4309e11d2d0910320e24f7d01 Mon Sep 17 00:00:00 2001
From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>
Date: Wed, 17 Jan 2024 15:22:07 +0900
Subject: enhance(frontend): チャンネルノートの場合はその前後を見れるように
 (#13019)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* チャンネルノートの場合はその前後を見れるように

* Update Changelog
---
 packages/frontend/src/pages/note.vue | 58 ++++++++++++++++++++++++++----------
 1 file changed, 43 insertions(+), 15 deletions(-)

(limited to 'packages/frontend/src/pages/note.vue')

diff --git a/packages/frontend/src/pages/note.vue b/packages/frontend/src/pages/note.vue
index 7e353e629c..4c0e9bbb98 100644
--- a/packages/frontend/src/pages/note.vue
+++ b/packages/frontend/src/pages/note.vue
@@ -11,11 +11,14 @@ SPDX-License-Identifier: AGPL-3.0-only
 			<Transition :name="defaultStore.state.animation ? 'fade' : ''" mode="out-in">
 				<div v-if="note">
 					<div v-if="showNext" class="_margin">
-						<MkNotes class="" :pagination="nextPagination" :noGap="true" :disableAutoLoad="true"/>
+						<MkNotes class="" :pagination="showNext === 'channel' ? nextChannelPagination : nextUserPagination" :noGap="true" :disableAutoLoad="true"/>
 					</div>
 
 					<div class="_margin">
-						<MkButton v-if="!showNext" :class="$style.loadNext" @click="showNext = true"><i class="ti ti-chevron-up"></i></MkButton>
+						<div v-if="!showNext" class="_buttons" :class="$style.loadNext">
+							<MkButton v-if="note.channelId" rounded :class="$style.loadButton" @click="showNext = 'channel'"><i class="ti ti-chevron-up"></i> <i class="ti ti-device-tv"></i></MkButton>
+							<MkButton rounded :class="$style.loadButton" @click="showNext = 'user'"><i class="ti ti-chevron-up"></i> <i class="ti ti-user"></i></MkButton>
+						</div>
 						<div class="_margin _gaps_s">
 							<MkRemoteCaution v-if="note.user.host != null" :href="note.url ?? note.uri"/>
 							<MkNoteDetailed :key="note.id" v-model:note="note" :class="$style.note"/>
@@ -28,11 +31,14 @@ SPDX-License-Identifier: AGPL-3.0-only
 								</MkA>
 							</div>
 						</div>
-						<MkButton v-if="!showPrev" :class="$style.loadPrev" @click="showPrev = true"><i class="ti ti-chevron-down"></i></MkButton>
+						<div v-if="!showPrev" class="_buttons" :class="$style.loadPrev">
+							<MkButton v-if="note.channelId" rounded :class="$style.loadButton" @click="showPrev = 'channel'"><i class="ti ti-chevron-down"></i> <i class="ti ti-device-tv"></i></MkButton>
+							<MkButton rounded :class="$style.loadButton" @click="showPrev = 'user'"><i class="ti ti-chevron-down"></i> <i class="ti ti-user"></i></MkButton>
+						</div>
 					</div>
 
 					<div v-if="showPrev" class="_margin">
-						<MkNotes class="" :pagination="prevPagination" :noGap="true"/>
+						<MkNotes class="" :pagination="showPrev === 'channel' ? prevChannelPagination : prevUserPagination" :noGap="true"/>
 					</div>
 				</div>
 				<MkError v-else-if="error" @retry="fetchNote()"/>
@@ -46,6 +52,7 @@ SPDX-License-Identifier: AGPL-3.0-only
 <script lang="ts" setup>
 import { computed, watch, ref } from 'vue';
 import * as Misskey from 'misskey-js';
+import type { Paging } from '@/components/MkPagination.vue';
 import MkNoteDetailed from '@/components/MkNoteDetailed.vue';
 import MkNotes from '@/components/MkNotes.vue';
 import MkRemoteCaution from '@/components/MkRemoteCaution.vue';
@@ -63,27 +70,46 @@ const props = defineProps<{
 
 const note = ref<null | Misskey.entities.Note>();
 const clips = ref<Misskey.entities.Clip[]>();
-const showPrev = ref(false);
-const showNext = ref(false);
+const showPrev = ref<'user' | 'channel' | false>(false);
+const showNext = ref<'user' | 'channel' | false>(false);
 const error = ref();
 
-const prevPagination = {
-	endpoint: 'users/notes' as const,
+const prevUserPagination: Paging = {
+	endpoint: 'users/notes',
 	limit: 10,
 	params: computed(() => note.value ? ({
 		userId: note.value.userId,
 		untilId: note.value.id,
-	}) : null),
+	}) : undefined),
 };
 
-const nextPagination = {
+const nextUserPagination: Paging = {
 	reversed: true,
-	endpoint: 'users/notes' as const,
+	endpoint: 'users/notes',
 	limit: 10,
 	params: computed(() => note.value ? ({
 		userId: note.value.userId,
 		sinceId: note.value.id,
-	}) : null),
+	}) : undefined),
+};
+
+const prevChannelPagination: Paging = {
+	endpoint: 'channels/timeline',
+	limit: 10,
+	params: computed(() => note.value ? ({
+		channelId: note.value.channelId,
+		untilId: note.value.id,
+	}) : undefined),
+};
+
+const nextChannelPagination: Paging = {
+	reversed: true,
+	endpoint: 'channels/timeline',
+	limit: 10,
+	params: computed(() => note.value ? ({
+		channelId: note.value.channelId,
+		sinceId: note.value.id,
+	}) : undefined),
 };
 
 function fetchNote() {
@@ -139,9 +165,7 @@ definePageMetadata(computed(() => note.value ? {
 
 .loadNext,
 .loadPrev {
-	min-width: 0;
-	margin: 0 auto;
-	border-radius: 999px;
+	justify-content: center;
 }
 
 .loadNext {
@@ -152,6 +176,10 @@ definePageMetadata(computed(() => note.value ? {
 	margin-top: var(--margin);
 }
 
+.loadButton {
+	min-width: 0;
+}
+
 .note {
 	border-radius: var(--radius);
 	background: var(--panel);
-- 
cgit v1.2.3-freya

