add warning to showOnRemote

This commit is contained in:
bunnybeam 2025-10-26 00:20:15 +01:00
parent 7715f36a99
commit e5ffb857d8
No known key found for this signature in database
6 changed files with 41 additions and 11 deletions

View file

@ -25,6 +25,7 @@ import { getAppearNote } from '@/utility/get-appear-note.js';
import { genEmbedCode } from '@/utility/get-embed-code.js';
import { prefer } from '@/preferences.js';
import { getPluginHandlers } from '@/plugin.js';
import { showOnRemote } from '@/utility/show-on-remote.js';
export async function getNoteClipMenu(props: {
note: Misskey.entities.Note;
@ -359,7 +360,7 @@ export function getNoteMenu(props: {
icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote,
action: () => {
window.open(appearNote.url ?? appearNote.uri, '_blank', 'noopener');
showOnRemote(appearNote);
},
});
} else {
@ -548,7 +549,7 @@ export function getNoteMenu(props: {
icon: 'ti ti-external-link',
text: i18n.ts.showOnRemote,
action: () => {
window.open(appearNote.url ?? appearNote.uri, '_blank', 'noopener');
showOnRemote(appearNote);
},
});
} else {

View file

@ -20,6 +20,7 @@ import { mainRouter } from '@/router.js';
import { genEmbedCode } from '@/utility/get-embed-code.js';
import { prefer } from '@/preferences.js';
import { getPluginHandlers } from '@/plugin.js';
import { warningExternalWebsite } from '@/utility/warning-external-website.js';
export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router = mainRouter) {
const meId = $i ? $i.id : null;
@ -211,7 +212,7 @@ export function getUserMenu(user: Misskey.entities.UserDetailed, router: Router
text: i18n.ts.showOnRemote,
action: () => {
if (user.url == null) return;
window.open(user.url, '_blank', 'noopener');
warningExternalWebsite(user.url);
},
});
} else {

View file

@ -0,0 +1,23 @@
/*
* SPDX-FileCopyrightText: bunnybeam and other Sharkey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { entities } from 'misskey-js';
import { warningExternalWebsite } from './warning-external-website';
import { useRouter } from '@/router';
import { notePage } from '@/filters/note.js';
const router = useRouter();
/**
* Show a note on the remote instance, if possible. Otherwise, show the local note.
*/
export function showOnRemote(note: entities.Note) {
const remoteUrl = note.url ?? note.uri;
if (remoteUrl) {
warningExternalWebsite(remoteUrl);
} else {
router.push(notePage(note));
}
}