出し分けのロジックを1箇所に統一

This commit is contained in:
kakkokari-gtyih 2024-05-03 15:00:50 +09:00
parent 4ab74d83f2
commit 527b812cce
2 changed files with 17 additions and 25 deletions

View file

@ -38,6 +38,7 @@
- Enhance: フォローするかどうかの確認ダイアログを出せるように - Enhance: フォローするかどうかの確認ダイアログを出せるように
- Enhance: Playを手動でリロードできるように - Enhance: Playを手動でリロードできるように
- Enhance: 通報のコメント内のリンクをクリックした際、ウィンドウで開くように - Enhance: 通報のコメント内のリンクをクリックした際、ウィンドウで開くように
- Enhance: リモートのノートのリンクをコピーできるように
- Chore: AiScriptを0.18.0にバージョンアップ - Chore: AiScriptを0.18.0にバージョンアップ
- Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 一部のページ内リンクが正しく動作しない問題を修正
- Fix: 周年の実績が閏年を考慮しない問題を修正 - Fix: 周年の実績が閏年を考慮しない問題を修正

View file

@ -227,17 +227,6 @@ export function getNoteMenu(props: {
os.success(); os.success();
} }
async function copyNoteLinkOnRemoteServer(): Promise<void> {
// TODO: 何が違う?
copyToClipboard(appearNote.url ?? appearNote.uri);
return os.success();
}
function copyLink(): void {
copyToClipboard(`${url}/notes/${appearNote.id}`);
os.success();
}
function togglePin(pin: boolean): void { function togglePin(pin: boolean): void {
os.apiWithDialog(pin ? 'i/pin' : 'i/unpin', { os.apiWithDialog(pin ? 'i/pin' : 'i/unpin', {
noteId: appearNote.id, noteId: appearNote.id,
@ -305,7 +294,7 @@ export function getNoteMenu(props: {
text: i18n.ts.unclip, text: i18n.ts.unclip,
danger: true, danger: true,
action: unclip, action: unclip,
}, { type: 'divider' }] : [] }, { type: 'divider' as const }] : []
), { ), {
icon: 'ti ti-info-circle', icon: 'ti ti-info-circle',
text: i18n.ts.details, text: i18n.ts.details,
@ -314,20 +303,22 @@ export function getNoteMenu(props: {
icon: 'ti ti-copy', icon: 'ti ti-copy',
text: i18n.ts.copyContent, text: i18n.ts.copyContent,
action: copyContent, action: copyContent,
}, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink) },
, (appearNote.url || appearNote.uri) ? { getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink),
...((appearNote.url != null || appearNote.uri != null) ? [{
icon: 'ti ti-link',
text: `${i18n.ts.copyLink} (${i18n.ts.remote})`,
action: () => {
copyToClipboard(appearNote.url ?? appearNote.uri);
os.success();
},
}, {
icon: 'ti ti-external-link', icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote, text: i18n.ts.showOnRemote,
action: () => { action: () => {
window.open(appearNote.url ?? appearNote.uri, '_blank', 'noopener'); window.open(appearNote.url ?? appearNote.uri, '_blank', 'noopener');
}, },
} : undefined, }] : []),
// リモートのリンクをコピー
(appearNote.url || appearNote.uri) ? {
icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote,
action: () => copyNoteLinkOnRemoteServer,
} : undefined,
...(isSupportShare() ? [{ ...(isSupportShare() ? [{
icon: 'ti ti-share', icon: 'ti ti-share',
text: i18n.ts.share, text: i18n.ts.share,
@ -338,7 +329,7 @@ export function getNoteMenu(props: {
text: i18n.ts.translate, text: i18n.ts.translate,
action: translate, action: translate,
} : undefined, } : undefined,
{ type: 'divider' }, { type: 'divider' as const },
statePromise.then(state => state.isFavorited ? { statePromise.then(state => state.isFavorited ? {
icon: 'ti ti-star-off', icon: 'ti ti-star-off',
text: i18n.ts.unfavorite, text: i18n.ts.unfavorite,
@ -394,13 +385,13 @@ export function getNoteMenu(props: {
: [] : []
),*/ ),*/
...(appearNote.userId !== $i.id ? [ ...(appearNote.userId !== $i.id ? [
{ type: 'divider' }, { type: 'divider' as const },
appearNote.userId !== $i.id ? getAbuseNoteMenu(appearNote, i18n.ts.reportAbuse) : undefined, appearNote.userId !== $i.id ? getAbuseNoteMenu(appearNote, i18n.ts.reportAbuse) : undefined,
] ]
: [] : []
), ),
...(appearNote.channel && (appearNote.channel.userId === $i.id || $i.isModerator || $i.isAdmin) ? [ ...(appearNote.channel && (appearNote.channel.userId === $i.id || $i.isModerator || $i.isAdmin) ? [
{ type: 'divider' }, { type: 'divider' as const },
{ {
type: 'parent' as const, type: 'parent' as const,
icon: 'ti ti-device-tv', icon: 'ti ti-device-tv',
@ -436,7 +427,7 @@ export function getNoteMenu(props: {
: [] : []
), ),
...(appearNote.userId === $i.id || $i.isModerator || $i.isAdmin ? [ ...(appearNote.userId === $i.id || $i.isModerator || $i.isAdmin ? [
{ type: 'divider' }, { type: 'divider' as const },
appearNote.userId === $i.id ? { appearNote.userId === $i.id ? {
icon: 'ti ti-edit', icon: 'ti ti-edit',
text: i18n.ts.deleteAndEdit, text: i18n.ts.deleteAndEdit,