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

This commit is contained in:
kakkokari-gtyih 2024-05-03 15:00:50 +09:00 committed by Sayamame-beans
parent d6a867a7fd
commit 03e21d61b9
2 changed files with 14 additions and 21 deletions

View file

@ -4,6 +4,7 @@
- -
### Client ### Client
- Enhance: リモートのノートのリンクをコピーできるように
- Fix: 画面サイズが変わった際にナビゲーションバーが自動で折りたたまれない問題を修正 - Fix: 画面サイズが変わった際にナビゲーションバーが自動で折りたたまれない問題を修正
- Fix: サーバー情報メニューに区切り線が不足していたのを修正 - Fix: サーバー情報メニューに区切り線が不足していたのを修正

View file

@ -237,17 +237,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,
@ -313,7 +302,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 });
} }
menuItems.push({ menuItems.push({
@ -327,16 +316,19 @@ export function getNoteMenu(props: {
}, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink)); }, getCopyNoteLinkMenu(appearNote, i18n.ts.copyLink));
if (appearNote.url || appearNote.uri) { if (appearNote.url || appearNote.uri) {
menuItems.push({ menuItems.push({ // リモートのリンクをコピー
icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote,
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');
}, },
}, { // リモートのリンクをコピー
icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote,
action: () => copyNoteLinkOnRemoteServer,
}); });
} else { } else {
menuItems.push(getNoteEmbedCodeMenu(appearNote, i18n.ts.genEmbedCode)); menuItems.push(getNoteEmbedCodeMenu(appearNote, i18n.ts.genEmbedCode));
@ -358,7 +350,7 @@ export function getNoteMenu(props: {
}); });
} }
menuItems.push({ type: 'divider' }); menuItems.push({ type: 'divider' as const });
menuItems.push(statePromise.then(state => state.isFavorited ? { menuItems.push(statePromise.then(state => state.isFavorited ? {
icon: 'ti ti-star-off', icon: 'ti ti-star-off',
@ -416,12 +408,12 @@ export function getNoteMenu(props: {
}); });
if (appearNote.userId !== $i.id) { if (appearNote.userId !== $i.id) {
menuItems.push({ type: 'divider' }); menuItems.push({ type: 'divider' as const });
menuItems.push(getAbuseNoteMenu(appearNote, i18n.ts.reportAbuse)); menuItems.push(getAbuseNoteMenu(appearNote, i18n.ts.reportAbuse));
} }
if (appearNote.channel && (appearNote.channel.userId === $i.id || $i.isModerator || $i.isAdmin)) { if (appearNote.channel && (appearNote.channel.userId === $i.id || $i.isModerator || $i.isAdmin)) {
menuItems.push({ type: 'divider' }); menuItems.push({ type: 'divider' as const });
menuItems.push({ menuItems.push({
type: 'parent', type: 'parent',
icon: 'ti ti-device-tv', icon: 'ti ti-device-tv',
@ -456,7 +448,7 @@ export function getNoteMenu(props: {
} }
if (appearNote.userId === $i.id || $i.isModerator || $i.isAdmin) { if (appearNote.userId === $i.id || $i.isModerator || $i.isAdmin) {
menuItems.push({ type: 'divider' }); menuItems.push({ type: 'divider' as const });
if (appearNote.userId === $i.id) { if (appearNote.userId === $i.id) {
menuItems.push({ menuItems.push({
icon: 'ti ti-edit', icon: 'ti ti-edit',