add warning to showOnRemote
This commit is contained in:
parent
7715f36a99
commit
e5ffb857d8
6 changed files with 41 additions and 11 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
23
packages/frontend/src/utility/show-on-remote.ts
Normal file
23
packages/frontend/src/utility/show-on-remote.ts
Normal 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));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue