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

8
locales/index.d.ts vendored
View file

@ -12525,6 +12525,14 @@ export interface Locale extends ILocale {
* Failed to load note
*/
"cannotLoadNote": string;
/**
* Please click [OK] to unsubscribe from announcement e-mails.
*/
"clickToUnsubscribe": string;
/**
* There was a problem unsubscribing.
*/
"unsubscribeError": string;
"_flash": {
/**
* Flash Content Hidden

View file

@ -79,7 +79,7 @@ Detailed view of a note in the Sharkey style. Used when opening a note onto its
<span v-if="appearNote.updatedAt" ref="menuVersionsButton" style="margin-left: 0.5em;" title="Edited" @mousedown="menuVersions()"><i class="ph-pencil-simple ph-bold ph-lg"></i></span>
<span v-if="appearNote.localOnly" style="margin-left: 0.5em;" :title="i18n.ts._visibility['disableFederation']"><i class="ti ti-rocket-off"></i></span>
</div>
<SkInstanceTicker v-if="showTicker" :host="appearNote.user.host" :instance="appearNote.user.instance"/>
<SkInstanceTicker v-if="showTicker" style="cursor: pointer;" :host="appearNote.user.host" :instance="appearNote.user.instance" @click.stop="showOnRemote(props.note)"/>
</div>
</div>
</header>
@ -290,6 +290,7 @@ import SkNoteTranslation from '@/components/SkNoteTranslation.vue';
import { getSelfNoteIds } from '@/utility/get-self-note-ids.js';
import SkUrlPreviewGroup from '@/components/SkUrlPreviewGroup.vue';
import MkNoteSub from '@/components/MkNoteSub.vue';
import { showOnRemote } from '@/utility/show-on-remote.js';
const props = withDefaults(defineProps<{
note: Misskey.entities.Note;

View file

@ -40,7 +40,7 @@ Header for a note in the Sharkey style, displaying info such as username and cre
<span v-if="note.channel" style="margin-left: 0.5em;" :title="note.channel.name"><i class="ph-television ph-bold ph-lg"></i></span>
</div>
<div :class="$style.info">
<SkInstanceTicker v-if="showTicker" style="cursor: pointer;" :instance="note.user.instance" :host="note.user.host" @click.stop="showOnRemote()"/>
<SkInstanceTicker v-if="showTicker" style="cursor: pointer;" :instance="note.user.instance" :host="note.user.host" @click.stop="showOnRemote(props.note)"/>
</div>
</div>
</header>
@ -56,7 +56,7 @@ Header for a note in the Sharkey style, displaying info such as username and cre
<div v-if="note.user.badgeRoles" :class="$style.badgeRoles">
<img v-for="(role, i) in note.user.badgeRoles" :key="i" v-tooltip="role.name" :class="$style.badgeRole" :src="role.iconUrl ?? ''"/>
</div>
<SkInstanceTicker v-if="showTicker && !isMobile && prefer.s.showTickerOnReplies" style="cursor: pointer; max-height: 5px; top: 3px; position: relative; margin-top: 0 !important;" :instance="note.user.instance" :host="note.user.host" @click.stop="showOnRemote()"/>
<SkInstanceTicker v-if="showTicker && !isMobile && prefer.s.showTickerOnReplies" style="cursor: pointer; max-height: 5px; top: 3px; position: relative; margin-top: 0 !important;" :instance="note.user.instance" :host="note.user.host" @click.stop="showOnRemote(props.note)"/>
<div :class="$style.classicInfo">
<div v-if="mock">
<MkTime :time="note.createdAt" colored/>
@ -89,6 +89,7 @@ import { prefer } from '@/preferences';
import { useRouter } from '@/router';
import { deviceKind } from '@/utility/device-kind';
import SkInstanceTicker from '@/components/SkInstanceTicker.vue';
import { showOnRemote } from '@/utility/show-on-remote.js';
const props = defineProps<{
note: Misskey.entities.Note;
@ -107,11 +108,6 @@ async function menuVersions(): Promise<void> {
popupMenu(menu, menuVersionsButton.value).then(focus).finally(cleanup);
}
function showOnRemote() {
if (props.note.url ?? props.note.uri === undefined) router.push(notePage(props.note));
else window.open(props.note.url ?? props.note.uri);
}
const mock = inject(DI.mock, false);
</script>

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));
}
}