diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2024-08-17 11:28:22 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-17 11:28:22 +0900 |
| commit | 059eb6d379cc84ee48c76bcea88dd90423f4f929 (patch) | |
| tree | 484f0274242d7013e6feaa6e5860f11e3d00ede6 /packages/frontend/src/scripts | |
| parent | New Crowdin updates (#14393) (diff) | |
| download | sharkey-059eb6d379cc84ee48c76bcea88dd90423f4f929.tar.gz sharkey-059eb6d379cc84ee48c76bcea88dd90423f4f929.tar.bz2 sharkey-059eb6d379cc84ee48c76bcea88dd90423f4f929.zip | |
fix(frontend): リノートの判定が甘いのを修正 (#14396)
* fix(frontend): リノートの判定が甘いのを修正
* fix
* Update Changelog
* fix
* use type assertion
* fix + add comments
* lint
* misskey-jsに移動
* PureRenote -> Renote
* isRenote -> isPureRenote
Diffstat (limited to 'packages/frontend/src/scripts')
| -rw-r--r-- | packages/frontend/src/scripts/get-appear-note.ts | 10 | ||||
| -rw-r--r-- | packages/frontend/src/scripts/get-note-menu.ts | 33 |
2 files changed, 17 insertions, 26 deletions
diff --git a/packages/frontend/src/scripts/get-appear-note.ts b/packages/frontend/src/scripts/get-appear-note.ts new file mode 100644 index 0000000000..40ce80eac9 --- /dev/null +++ b/packages/frontend/src/scripts/get-appear-note.ts @@ -0,0 +1,10 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import * as Misskey from 'misskey-js'; + +export function getAppearNote(note: Misskey.entities.Note) { + return Misskey.note.isPureRenote(note) ? note.renote : note; +} diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index ebb96d1746..2563b0baf3 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -20,6 +20,7 @@ import { clipsCache, favoritedChannelsCache } from '@/cache.js'; import { MenuItem } from '@/types/menu.js'; import MkRippleEffect from '@/components/MkRippleEffect.vue'; import { isSupportShare } from '@/scripts/navigator.js'; +import { getAppearNote } from '@/scripts/get-appear-note.js'; export async function getNoteClipMenu(props: { note: Misskey.entities.Note; @@ -34,14 +35,7 @@ export async function getNoteClipMenu(props: { } } - const isRenote = ( - props.note.renote != null && - props.note.text == null && - props.note.fileIds.length === 0 && - props.note.poll == null - ); - - const appearNote = isRenote ? props.note.renote as Misskey.entities.Note : props.note; + const appearNote = getAppearNote(props.note); const clips = await clipsCache.fetch(); const menu: MenuItem[] = [...clips.map(clip => ({ @@ -164,14 +158,7 @@ export function getNoteMenu(props: { isDeleted: Ref<boolean>; currentClip?: Misskey.entities.Clip; }) { - const isRenote = ( - props.note.renote != null && - props.note.text == null && - props.note.fileIds.length === 0 && - props.note.poll == null - ); - - const appearNote = isRenote ? props.note.renote as Misskey.entities.Note : props.note; + const appearNote = getAppearNote(props.note); const cleanups = [] as (() => void)[]; @@ -248,6 +235,7 @@ export function getNoteMenu(props: { } async function unclip(): Promise<void> { + if (!props.currentClip) return; os.apiWithDialog('clips/remove-note', { clipId: props.currentClip.id, noteId: appearNote.id }); props.isDeleted.value = true; } @@ -267,8 +255,8 @@ export function getNoteMenu(props: { function share(): void { navigator.share({ - title: i18n.tsx.noteOf({ user: appearNote.user.name }), - text: appearNote.text, + title: i18n.tsx.noteOf({ user: appearNote.user.name ?? appearNote.user.username }), + text: appearNote.text ?? '', url: `${url}/notes/${appearNote.id}`, }); } @@ -509,14 +497,7 @@ export function getRenoteMenu(props: { renoteButton: ShallowRef<HTMLElement | undefined>; mock?: boolean; }) { - const isRenote = ( - props.note.renote != null && - props.note.text == null && - props.note.fileIds.length === 0 && - props.note.poll == null - ); - - const appearNote = isRenote ? props.note.renote as Misskey.entities.Note : props.note; + const appearNote = getAppearNote(props.note); const channelRenoteItems: MenuItem[] = []; const normalRenoteItems: MenuItem[] = []; |