From 9bc5d52e413dcf35e85613e0c5a5b319ba95017a Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 31 Mar 2023 15:01:56 +0900 Subject: feat: チャンネルにノートをピン留めできるように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve #7740 --- packages/frontend/src/components/MkNote.vue | 9 ++- packages/frontend/src/pages/channel-editor.vue | 83 ++++++++++++++++++++++++-- packages/frontend/src/pages/channel.vue | 9 +++ packages/frontend/src/pages/clip.vue | 2 +- packages/frontend/src/scripts/get-note-menu.ts | 12 ++-- 5 files changed, 99 insertions(+), 16 deletions(-) (limited to 'packages/frontend/src') diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 72c6e55df1..eb9793fcc1 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -169,6 +169,7 @@ const props = defineProps<{ }>(); const inChannel = inject('inChannel', null); +const currentClip = inject | null>('currentClip', null); let note = $ref(deepClone(props.note)); @@ -370,8 +371,6 @@ function undoReact(note): void { }); } -const currentClipPage = inject | null>('currentClipPage', null); - function onContextmenu(ev: MouseEvent): void { const isLink = (el: HTMLElement) => { if (el.tagName === 'A') return true; @@ -386,18 +385,18 @@ function onContextmenu(ev: MouseEvent): void { ev.preventDefault(); react(); } else { - os.contextMenu(getNoteMenu({ note: note, translating, translation, menuButton, isDeleted, currentClipPage }), ev).then(focus); + os.contextMenu(getNoteMenu({ note: note, translating, translation, menuButton, isDeleted, currentClip: currentClip?.value }), ev).then(focus); } } function menu(viaKeyboard = false): void { - os.popupMenu(getNoteMenu({ note: note, translating, translation, menuButton, isDeleted, currentClipPage }), menuButton.value, { + os.popupMenu(getNoteMenu({ note: note, translating, translation, menuButton, isDeleted, currentClip: currentClip?.value }), menuButton.value, { viaKeyboard, }).then(focus); } async function clip() { - os.popupMenu(await getNoteClipMenu({ note: note, isDeleted, currentClipPage }), clipButton.value).then(focus); + os.popupMenu(await getNoteClipMenu({ note: note, isDeleted, currentClip: currentClip?.value }), clipButton.value).then(focus); } function showRenoteMenu(viaKeyboard = false): void { diff --git a/packages/frontend/src/pages/channel-editor.vue b/packages/frontend/src/pages/channel-editor.vue index 38c5b1e082..667caab966 100644 --- a/packages/frontend/src/pages/channel-editor.vue +++ b/packages/frontend/src/pages/channel-editor.vue @@ -2,7 +2,7 @@ -
+
@@ -11,13 +11,37 @@ -
@@ -57,6 +64,8 @@ import MkNotes from '@/components/MkNotes.vue'; import { url } from '@/config'; import MkButton from '@/components/MkButton.vue'; import { defaultStore } from '@/store'; +import MkNote from '@/components/MkNote.vue'; +import MkFoldableSection from '@/components/MkFoldableSection.vue'; const router = useRouter(); diff --git a/packages/frontend/src/pages/clip.vue b/packages/frontend/src/pages/clip.vue index 2b64de088a..e3ac3f4c9b 100644 --- a/packages/frontend/src/pages/clip.vue +++ b/packages/frontend/src/pages/clip.vue @@ -57,7 +57,7 @@ watch(() => props.clipId, async () => { immediate: true, }); -provide('currentClipPage', $$(clip)); +provide('currentClip', $$(clip)); function favorite() { os.apiWithDialog('clips/favorite', { diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index 00f2523bf9..d91f0b0eb6 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -15,7 +15,7 @@ import { clipsCache } from '@/cache'; export async function getNoteClipMenu(props: { note: misskey.entities.Note; isDeleted: Ref; - currentClipPage?: Ref; + currentClip?: misskey.entities.Clip; }) { const isRenote = ( props.note.renote != null && @@ -42,7 +42,7 @@ export async function getNoteClipMenu(props: { }); if (!confirm.canceled) { os.apiWithDialog('clips/remove-note', { clipId: clip.id, noteId: appearNote.id }); - if (props.currentClipPage?.value.id === clip.id) props.isDeleted.value = true; + if (props.currentClip?.id === clip.id) props.isDeleted.value = true; } } else { os.alert({ @@ -92,7 +92,7 @@ export function getNoteMenu(props: { translation: Ref; translating: Ref; isDeleted: Ref; - currentClipPage?: Ref; + currentClip?: misskey.entities.Clip; }) { const isRenote = ( props.note.renote != null && @@ -176,7 +176,7 @@ export function getNoteMenu(props: { } async function unclip(): Promise { - os.apiWithDialog('clips/remove-note', { clipId: props.currentClipPage.value.id, noteId: appearNote.id }); + os.apiWithDialog('clips/remove-note', { clipId: props.currentClip.id, noteId: appearNote.id }); props.isDeleted.value = true; } @@ -230,7 +230,7 @@ export function getNoteMenu(props: { menu = [ ...( - props.currentClipPage?.value.userId === $i.id ? [{ + props.currentClip?.userId === $i.id ? [{ icon: 'ti ti-backspace', text: i18n.ts.unclip, danger: true, @@ -294,7 +294,7 @@ export function getNoteMenu(props: { text: i18n.ts.muteThread, action: () => toggleThreadMute(true), }), - appearNote.userId === $i.id ? ($i.pinnedNoteIds || []).includes(appearNote.id) ? { + appearNote.userId === $i.id ? ($i.pinnedNoteIds ?? []).includes(appearNote.id) ? { icon: 'ti ti-pinned-off', text: i18n.ts.unpin, action: () => togglePin(false), -- cgit v1.2.3-freya