2023-09-02 01:27:33 +02:00
|
|
|
import type { Ref } from "vue";
|
2023-10-31 12:19:05 +01:00
|
|
|
import { defineAsyncComponent } from "vue";
|
2024-02-12 16:40:46 +01:00
|
|
|
import type { entities } from "firefish-js";
|
2024-03-16 16:49:12 +01:00
|
|
|
import { isModerator, isSignedIn, me } from "@/me";
|
2023-01-13 05:40:33 +01:00
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
import { instance } from "@/instance";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import copyToClipboard from "@/scripts/copy-to-clipboard";
|
|
|
|
import { url } from "@/config";
|
|
|
|
import { noteActions } from "@/store";
|
|
|
|
import { shareAvailable } from "@/scripts/share-available";
|
2023-06-13 01:44:30 +02:00
|
|
|
import { getUserMenu } from "@/scripts/get-user-menu";
|
2023-10-17 03:57:20 +02:00
|
|
|
import icon from "@/scripts/icon";
|
2024-03-26 09:59:42 +01:00
|
|
|
import { useRouter } from "@/router";
|
|
|
|
import { notePage } from "@/filters/note";
|
|
|
|
|
|
|
|
const router = useRouter();
|
2022-01-14 02:25:51 +01:00
|
|
|
|
|
|
|
export function getNoteMenu(props: {
|
2024-02-12 16:40:46 +01:00
|
|
|
note: entities.Note;
|
2023-05-07 12:48:55 +02:00
|
|
|
menuButton: Ref<HTMLElement | undefined>;
|
2022-01-14 02:25:51 +01:00
|
|
|
translation: Ref<any>;
|
|
|
|
translating: Ref<boolean>;
|
2022-06-18 11:27:09 +02:00
|
|
|
isDeleted: Ref<boolean>;
|
2024-02-12 16:40:46 +01:00
|
|
|
currentClipPage?: Ref<entities.Clip>;
|
2022-01-14 02:25:51 +01:00
|
|
|
}) {
|
2023-01-13 05:40:33 +01:00
|
|
|
const isRenote =
|
2022-01-14 02:25:51 +01:00
|
|
|
props.note.renote != null &&
|
|
|
|
props.note.text == null &&
|
|
|
|
props.note.fileIds.length === 0 &&
|
2023-01-13 05:40:33 +01:00
|
|
|
props.note.poll == null;
|
2022-01-14 02:25:51 +01:00
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
const appearNote = isRenote
|
2024-02-12 16:40:46 +01:00
|
|
|
? (props.note.renote as entities.Note)
|
2023-01-13 05:40:33 +01:00
|
|
|
: props.note;
|
2022-01-14 02:25:51 +01:00
|
|
|
|
|
|
|
function del(): void {
|
|
|
|
os.confirm({
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "warning",
|
2022-01-28 03:39:49 +01:00
|
|
|
text: i18n.ts.noteDeleteConfirm,
|
2022-01-14 02:25:51 +01:00
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
os.api("notes/delete", {
|
2022-06-30 03:53:40 +02:00
|
|
|
noteId: appearNote.id,
|
2022-01-14 02:25:51 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function delEdit(): void {
|
|
|
|
os.confirm({
|
2023-01-13 05:40:33 +01:00
|
|
|
type: "warning",
|
2022-01-28 03:39:49 +01:00
|
|
|
text: i18n.ts.deleteAndEditConfirm,
|
2022-01-14 02:25:51 +01:00
|
|
|
}).then(({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
os.api("notes/delete", {
|
2022-06-30 03:53:40 +02:00
|
|
|
noteId: appearNote.id,
|
2022-01-14 02:25:51 +01:00
|
|
|
});
|
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
os.post({
|
|
|
|
initialNote: appearNote,
|
|
|
|
renote: appearNote.renote,
|
|
|
|
reply: appearNote.reply,
|
|
|
|
channel: appearNote.channel,
|
|
|
|
});
|
2022-01-14 02:25:51 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-05-07 12:48:55 +02:00
|
|
|
function edit(): void {
|
2023-05-07 14:07:40 +02:00
|
|
|
os.post({
|
|
|
|
initialNote: appearNote,
|
|
|
|
renote: appearNote.renote,
|
|
|
|
reply: appearNote.reply,
|
|
|
|
channel: appearNote.channel,
|
|
|
|
editId: appearNote.id,
|
2023-05-07 12:48:55 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-03-26 09:59:42 +01:00
|
|
|
function showEditHistory(): void {
|
|
|
|
router.push(notePage(appearNote, { historyPage: true }));
|
|
|
|
}
|
|
|
|
|
2024-02-21 00:42:12 +01:00
|
|
|
function makePrivate(): void {
|
|
|
|
os.confirm({
|
|
|
|
type: "warning",
|
|
|
|
text: i18n.ts.makePrivateConfirm,
|
|
|
|
}).then(async ({ canceled }) => {
|
|
|
|
if (canceled) return;
|
|
|
|
|
|
|
|
await os.api("notes/make-private", {
|
|
|
|
noteId: appearNote.id,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-14 02:25:51 +01:00
|
|
|
function toggleFavorite(favorite: boolean): void {
|
2023-01-13 05:40:33 +01:00
|
|
|
os.apiWithDialog(
|
|
|
|
favorite ? "notes/favorites/create" : "notes/favorites/delete",
|
|
|
|
{
|
|
|
|
noteId: appearNote.id,
|
|
|
|
},
|
|
|
|
);
|
2022-01-14 02:25:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleWatch(watch: boolean): void {
|
2023-01-13 05:40:33 +01:00
|
|
|
os.apiWithDialog(
|
|
|
|
watch ? "notes/watching/create" : "notes/watching/delete",
|
|
|
|
{
|
|
|
|
noteId: appearNote.id,
|
|
|
|
},
|
|
|
|
);
|
2022-01-14 02:25:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function toggleThreadMute(mute: boolean): void {
|
2023-01-13 05:40:33 +01:00
|
|
|
os.apiWithDialog(
|
|
|
|
mute ? "notes/thread-muting/create" : "notes/thread-muting/delete",
|
|
|
|
{
|
|
|
|
noteId: appearNote.id,
|
|
|
|
},
|
|
|
|
);
|
2022-01-14 02:25:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function copyContent(): void {
|
|
|
|
copyToClipboard(appearNote.text);
|
|
|
|
os.success();
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyLink(): void {
|
|
|
|
copyToClipboard(`${url}/notes/${appearNote.id}`);
|
|
|
|
os.success();
|
|
|
|
}
|
|
|
|
|
2023-06-19 22:50:51 +02:00
|
|
|
function copyOriginal(): void {
|
|
|
|
copyToClipboard(appearNote.url ?? appearNote.uri);
|
|
|
|
os.success();
|
|
|
|
}
|
|
|
|
|
2022-01-14 02:25:51 +01:00
|
|
|
function togglePin(pin: boolean): void {
|
2023-01-13 05:40:33 +01:00
|
|
|
os.apiWithDialog(
|
|
|
|
pin ? "i/pin" : "i/unpin",
|
|
|
|
{
|
|
|
|
noteId: appearNote.id,
|
|
|
|
},
|
|
|
|
undefined,
|
2023-04-30 18:29:50 +02:00
|
|
|
).catch((res) => {
|
|
|
|
if (res.id === "72dab508-c64d-498f-8740-a8eec1ba385a") {
|
|
|
|
os.alert({
|
|
|
|
type: "error",
|
|
|
|
text: i18n.ts.pinLimitExceeded,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2022-01-14 02:25:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
async function clip(): Promise<void> {
|
2023-01-13 05:40:33 +01:00
|
|
|
const clips = await os.api("clips/list");
|
|
|
|
os.popupMenu(
|
|
|
|
[
|
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-plus")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.createNew,
|
|
|
|
action: async () => {
|
|
|
|
const { canceled, result } = await os.form(i18n.ts.createNewClip, {
|
|
|
|
name: {
|
|
|
|
type: "string",
|
|
|
|
label: i18n.ts.name,
|
|
|
|
},
|
|
|
|
description: {
|
|
|
|
type: "string",
|
|
|
|
required: false,
|
|
|
|
multiline: true,
|
|
|
|
label: i18n.ts.description,
|
|
|
|
},
|
|
|
|
isPublic: {
|
|
|
|
type: "boolean",
|
|
|
|
label: i18n.ts.public,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (canceled) return;
|
2022-01-14 02:25:51 +01:00
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
const clip = await os.apiWithDialog("clips/create", result);
|
2022-01-14 02:25:51 +01:00
|
|
|
|
2023-01-13 05:40:33 +01:00
|
|
|
os.apiWithDialog("clips/add-note", {
|
|
|
|
clipId: clip.id,
|
|
|
|
noteId: appearNote.id,
|
|
|
|
});
|
2022-06-30 03:53:40 +02:00
|
|
|
},
|
2023-01-13 05:40:33 +01:00
|
|
|
},
|
|
|
|
null,
|
|
|
|
...clips.map((clip) => ({
|
|
|
|
text: clip.name,
|
|
|
|
action: () => {
|
|
|
|
os.promiseDialog(
|
|
|
|
os.api("clips/add-note", {
|
|
|
|
clipId: clip.id,
|
|
|
|
noteId: appearNote.id,
|
|
|
|
}),
|
|
|
|
null,
|
|
|
|
async (err) => {
|
|
|
|
if (err.id === "734806c4-542c-463a-9311-15c512803965") {
|
|
|
|
const confirm = await os.confirm({
|
|
|
|
type: "warning",
|
|
|
|
text: i18n.t("confirmToUnclipAlreadyClippedNote", {
|
|
|
|
name: clip.name,
|
|
|
|
}),
|
|
|
|
});
|
|
|
|
if (!confirm.canceled) {
|
|
|
|
os.apiWithDialog("clips/remove-note", {
|
|
|
|
clipId: clip.id,
|
|
|
|
noteId: appearNote.id,
|
|
|
|
});
|
|
|
|
if (props.currentClipPage?.value.id === clip.id)
|
|
|
|
props.isDeleted.value = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
os.alert({
|
|
|
|
type: "error",
|
|
|
|
text: err.message + "\n" + err.id,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
})),
|
|
|
|
],
|
|
|
|
props.menuButton.value,
|
|
|
|
{},
|
|
|
|
).then(focus);
|
2022-01-14 02:25:51 +01:00
|
|
|
}
|
|
|
|
|
2022-06-18 11:27:09 +02:00
|
|
|
async function unclip(): Promise<void> {
|
2023-01-13 05:40:33 +01:00
|
|
|
os.apiWithDialog("clips/remove-note", {
|
|
|
|
clipId: props.currentClipPage.value.id,
|
|
|
|
noteId: appearNote.id,
|
|
|
|
});
|
2022-06-18 11:27:09 +02:00
|
|
|
props.isDeleted.value = true;
|
|
|
|
}
|
|
|
|
|
2024-01-11 02:21:21 +01:00
|
|
|
// async function promote(): Promise<void> {
|
|
|
|
// const { canceled, result: days } = await os.inputNumber({
|
|
|
|
// title: i18n.ts.numberOfDays,
|
|
|
|
// });
|
2022-01-14 02:25:51 +01:00
|
|
|
|
2024-01-11 02:21:21 +01:00
|
|
|
// if (canceled) return;
|
2022-01-14 02:25:51 +01:00
|
|
|
|
2024-01-11 02:21:21 +01:00
|
|
|
// os.apiWithDialog("admin/promo/create", {
|
|
|
|
// noteId: appearNote.id,
|
|
|
|
// expiresAt: Date.now() + 86400000 * days,
|
|
|
|
// });
|
|
|
|
// }
|
2022-01-14 02:25:51 +01:00
|
|
|
|
|
|
|
function share(): void {
|
|
|
|
navigator.share({
|
2023-01-13 05:40:33 +01:00
|
|
|
title: i18n.t("noteOf", { user: appearNote.user.name }),
|
2022-01-14 02:25:51 +01:00
|
|
|
text: appearNote.text,
|
|
|
|
url: `${url}/notes/${appearNote.id}`,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2023-09-03 22:50:15 +02:00
|
|
|
async function translate_(noteId: number, targetLang: string) {
|
|
|
|
return await os.api("notes/translate", {
|
2023-09-17 23:59:09 +02:00
|
|
|
noteId,
|
|
|
|
targetLang,
|
2023-09-03 22:50:15 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-01-14 02:25:51 +01:00
|
|
|
async function translate(): Promise<void> {
|
2023-09-03 22:50:15 +02:00
|
|
|
const translateLang = localStorage.getItem("translateLang");
|
|
|
|
const lang = localStorage.getItem("lang");
|
|
|
|
|
2022-01-14 02:25:51 +01:00
|
|
|
if (props.translation.value != null) return;
|
|
|
|
props.translating.value = true;
|
2023-09-03 22:50:15 +02:00
|
|
|
props.translation.value = await translate_(
|
|
|
|
appearNote.id,
|
|
|
|
translateLang || lang || navigator.language,
|
|
|
|
);
|
|
|
|
|
|
|
|
// use UI language as the second translation target
|
|
|
|
if (
|
|
|
|
translateLang != null &&
|
|
|
|
lang != null &&
|
|
|
|
translateLang !== lang &&
|
|
|
|
(!props.translation.value ||
|
|
|
|
props.translation.value.sourceLang.toLowerCase() ===
|
|
|
|
translateLang.slice(0, 2))
|
|
|
|
)
|
|
|
|
props.translation.value = await translate_(appearNote.id, lang);
|
2022-01-14 02:25:51 +01:00
|
|
|
props.translating.value = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
let menu;
|
2024-01-11 02:21:21 +01:00
|
|
|
if (isSignedIn) {
|
2023-01-13 05:40:33 +01:00
|
|
|
const statePromise = os.api("notes/state", {
|
2022-06-30 03:53:40 +02:00
|
|
|
noteId: appearNote.id,
|
2022-01-14 02:25:51 +01:00
|
|
|
});
|
|
|
|
|
2024-03-26 09:59:42 +01:00
|
|
|
const isEdited = !!appearNote.updatedAt;
|
|
|
|
|
2024-03-07 03:06:45 +01:00
|
|
|
const isAppearAuthor = appearNote.userId === me.id;
|
2023-05-07 12:48:55 +02:00
|
|
|
|
2022-06-18 11:27:09 +02:00
|
|
|
menu = [
|
2024-03-07 03:06:45 +01:00
|
|
|
...(props.currentClipPage?.value.userId === me.id
|
2023-01-13 05:40:33 +01:00
|
|
|
? [
|
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-minus-circle")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.unclip,
|
|
|
|
danger: true,
|
|
|
|
action: unclip,
|
|
|
|
},
|
|
|
|
null,
|
2024-03-28 06:25:33 +01:00
|
|
|
]
|
2023-01-13 05:40:33 +01:00
|
|
|
: []),
|
|
|
|
statePromise.then((state) =>
|
|
|
|
state?.isFavorited
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-bookmark-simple")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.unfavorite,
|
|
|
|
action: () => toggleFavorite(false),
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-01-13 05:40:33 +01:00
|
|
|
: {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-bookmark-simple")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.favorite,
|
|
|
|
action: () => toggleFavorite(true),
|
2024-03-28 06:25:33 +01:00
|
|
|
},
|
2023-01-13 05:40:33 +01:00
|
|
|
),
|
2022-06-30 03:53:40 +02:00
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-paperclip")}`,
|
2022-06-30 03:53:40 +02:00
|
|
|
text: i18n.ts.clip,
|
|
|
|
action: () => clip(),
|
|
|
|
},
|
2023-05-07 12:48:55 +02:00
|
|
|
!isAppearAuthor
|
2023-01-13 05:40:33 +01:00
|
|
|
? statePromise.then((state) =>
|
|
|
|
state.isWatching
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-eye-slash")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.unwatch,
|
|
|
|
action: () => toggleWatch(false),
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-01-13 05:40:33 +01:00
|
|
|
: {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-eye")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.watch,
|
|
|
|
action: () => toggleWatch(true),
|
2024-03-28 06:25:33 +01:00
|
|
|
},
|
|
|
|
)
|
2023-01-13 05:40:33 +01:00
|
|
|
: undefined,
|
|
|
|
statePromise.then((state) =>
|
|
|
|
state.isMutedThread
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-speaker-x")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.unmuteThread,
|
|
|
|
action: () => toggleThreadMute(false),
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-01-13 05:40:33 +01:00
|
|
|
: {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-speaker-x")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.muteThread,
|
|
|
|
action: () => toggleThreadMute(true),
|
2024-03-28 06:25:33 +01:00
|
|
|
},
|
2023-01-13 05:40:33 +01:00
|
|
|
),
|
2023-05-07 12:48:55 +02:00
|
|
|
isAppearAuthor
|
2024-03-07 03:06:45 +01:00
|
|
|
? (me.pinnedNoteIds || []).includes(appearNote.id)
|
2023-01-13 05:40:33 +01:00
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-push-pin")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.unpin,
|
|
|
|
action: () => togglePin(false),
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-01-13 05:40:33 +01:00
|
|
|
: {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-push-pin")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.pin,
|
|
|
|
action: () => togglePin(true),
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-01-13 05:40:33 +01:00
|
|
|
: undefined,
|
2024-03-26 09:59:42 +01:00
|
|
|
isEdited
|
|
|
|
? {
|
|
|
|
icon: `${icon('ph-clock-countdown')}`,
|
|
|
|
text: i18n.ts.noteEditHistory,
|
|
|
|
action: () => showEditHistory(),
|
|
|
|
}
|
|
|
|
: undefined,
|
2023-06-23 02:25:50 +02:00
|
|
|
instance.translatorAvailable
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-translate")}`,
|
2023-06-23 02:25:50 +02:00
|
|
|
text: i18n.ts.translate,
|
|
|
|
action: translate,
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-23 02:25:50 +02:00
|
|
|
: undefined,
|
2023-06-19 22:50:51 +02:00
|
|
|
appearNote.url || appearNote.uri
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-arrow-square-out")}`,
|
2023-06-19 22:50:51 +02:00
|
|
|
text: i18n.ts.showOnRemote,
|
|
|
|
action: () => {
|
|
|
|
window.open(appearNote.url || appearNote.uri, "_blank");
|
|
|
|
},
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-19 22:50:51 +02:00
|
|
|
: undefined,
|
|
|
|
{
|
|
|
|
type: "parent",
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-share-network")}`,
|
2023-06-19 22:50:51 +02:00
|
|
|
text: i18n.ts.share,
|
|
|
|
children: [
|
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-clipboard-text")}`,
|
2023-06-19 22:50:51 +02:00
|
|
|
text: i18n.ts.copyContent,
|
|
|
|
action: copyContent,
|
|
|
|
},
|
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-link-simple")}`,
|
2023-06-19 22:50:51 +02:00
|
|
|
text: i18n.ts.copyLink,
|
|
|
|
action: copyLink,
|
|
|
|
},
|
2023-06-24 06:22:44 +02:00
|
|
|
appearNote.url || appearNote.uri
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-link-simple")}`,
|
2023-07-26 03:29:24 +02:00
|
|
|
text: `${i18n.ts.copyLink} (${i18n.ts.origin})`,
|
2023-06-24 06:22:44 +02:00
|
|
|
action: copyOriginal,
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-24 06:22:44 +02:00
|
|
|
: undefined,
|
2023-06-19 22:50:51 +02:00
|
|
|
shareAvailable()
|
2023-06-24 06:22:44 +02:00
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-share-network")}`,
|
2023-06-24 06:22:44 +02:00
|
|
|
text: i18n.ts.share,
|
|
|
|
action: share,
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-24 06:22:44 +02:00
|
|
|
: undefined,
|
|
|
|
],
|
2023-06-19 22:50:51 +02:00
|
|
|
},
|
2022-06-30 03:53:40 +02:00
|
|
|
/*
|
2024-01-11 02:21:21 +01:00
|
|
|
...(isModerator ? [
|
2022-01-14 02:25:51 +01:00
|
|
|
null,
|
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon('ph-megaphone-simple')}`,
|
2022-01-28 03:39:49 +01:00
|
|
|
text: i18n.ts.promote,
|
2022-01-14 02:25:51 +01:00
|
|
|
action: promote
|
|
|
|
}]
|
|
|
|
: []
|
2023-09-02 01:27:33 +02:00
|
|
|
), */
|
2023-06-08 12:02:50 +02:00
|
|
|
null,
|
|
|
|
!isAppearAuthor
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-warning-circle")}`,
|
2023-06-08 12:02:50 +02:00
|
|
|
text: i18n.ts.reportAbuse,
|
|
|
|
action: () => {
|
|
|
|
const u =
|
|
|
|
appearNote.url ||
|
|
|
|
appearNote.uri ||
|
|
|
|
`${url}/notes/${appearNote.id}`;
|
|
|
|
os.popup(
|
|
|
|
defineAsyncComponent(
|
|
|
|
() => import("@/components/MkAbuseReportWindow.vue"),
|
|
|
|
),
|
|
|
|
{
|
|
|
|
user: appearNote.user,
|
|
|
|
initialComment: `Note: ${u}\n-----\n`,
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
"closed",
|
|
|
|
);
|
2023-01-13 05:40:33 +01:00
|
|
|
},
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-08 12:02:50 +02:00
|
|
|
: undefined,
|
2023-07-02 05:00:51 +02:00
|
|
|
isAppearAuthor
|
2023-05-07 12:48:55 +02:00
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-pencil-line")}`,
|
2024-03-06 04:51:30 +01:00
|
|
|
text: i18n.ts.toEdit,
|
2023-06-08 19:47:21 +02:00
|
|
|
accent: true,
|
2023-06-08 12:02:50 +02:00
|
|
|
action: edit,
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-05-07 12:48:55 +02:00
|
|
|
: undefined,
|
2024-02-21 00:42:12 +01:00
|
|
|
isAppearAuthor &&
|
|
|
|
!(
|
|
|
|
appearNote.visibility === "specified" &&
|
|
|
|
appearNote.visibleUserIds.length === 0
|
|
|
|
)
|
|
|
|
? {
|
|
|
|
icon: `${icon("ph-eye-slash")}`,
|
|
|
|
text: i18n.ts.makePrivate,
|
|
|
|
danger: true,
|
|
|
|
action: makePrivate,
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2024-02-21 00:42:12 +01:00
|
|
|
: undefined,
|
2023-05-07 12:48:55 +02:00
|
|
|
isAppearAuthor
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-eraser")}`,
|
2023-05-07 12:48:55 +02:00
|
|
|
text: i18n.ts.deleteAndEdit,
|
2023-07-26 03:56:55 +02:00
|
|
|
danger: true,
|
2023-05-07 12:48:55 +02:00
|
|
|
action: delEdit,
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-05-07 12:48:55 +02:00
|
|
|
: undefined,
|
2023-06-08 12:02:50 +02:00
|
|
|
isAppearAuthor || isModerator
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-trash")}`,
|
2023-06-08 12:02:50 +02:00
|
|
|
text: i18n.ts.delete,
|
|
|
|
danger: true,
|
|
|
|
action: del,
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-08 12:02:50 +02:00
|
|
|
: undefined,
|
2023-06-13 01:44:30 +02:00
|
|
|
!isAppearAuthor ? null : undefined,
|
|
|
|
!isAppearAuthor
|
|
|
|
? {
|
2023-06-24 06:22:44 +02:00
|
|
|
type: "parent",
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-user")}`,
|
2023-06-24 06:22:44 +02:00
|
|
|
text: i18n.ts.user,
|
|
|
|
children: getUserMenu(appearNote.user),
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-24 06:22:44 +02:00
|
|
|
: undefined,
|
2023-01-13 05:40:33 +01:00
|
|
|
].filter((x) => x !== undefined);
|
2022-01-14 02:25:51 +01:00
|
|
|
} else {
|
2023-01-13 05:40:33 +01:00
|
|
|
menu = [
|
2023-06-19 22:50:51 +02:00
|
|
|
appearNote.url || appearNote.uri
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-arrow-square-out")}`,
|
2023-06-19 22:50:51 +02:00
|
|
|
text: i18n.ts.showOnRemote,
|
|
|
|
action: () => {
|
|
|
|
window.open(appearNote.url || appearNote.uri, "_blank");
|
|
|
|
},
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-19 22:50:51 +02:00
|
|
|
: undefined,
|
2023-01-13 05:40:33 +01:00
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-clipboard-text")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.copyContent,
|
|
|
|
action: copyContent,
|
2022-06-30 03:53:40 +02:00
|
|
|
},
|
2023-01-13 05:40:33 +01:00
|
|
|
{
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-link-simple")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: i18n.ts.copyLink,
|
|
|
|
action: copyLink,
|
|
|
|
},
|
2023-06-24 06:22:44 +02:00
|
|
|
appearNote.url || appearNote.uri
|
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-link-simple")}`,
|
2023-07-26 03:29:24 +02:00
|
|
|
text: `${i18n.ts.copyLink} (${i18n.ts.origin})`,
|
2023-06-24 06:22:44 +02:00
|
|
|
action: copyOriginal,
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-24 06:22:44 +02:00
|
|
|
: undefined,
|
2023-06-19 22:50:51 +02:00
|
|
|
shareAvailable()
|
2023-06-24 06:22:44 +02:00
|
|
|
? {
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-share-network")}`,
|
2023-06-24 06:22:44 +02:00
|
|
|
text: i18n.ts.share,
|
|
|
|
action: share,
|
2024-03-28 06:25:33 +01:00
|
|
|
}
|
2023-06-24 06:22:44 +02:00
|
|
|
: undefined,
|
2023-01-13 05:40:33 +01:00
|
|
|
].filter((x) => x !== undefined);
|
2022-01-14 02:25:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (noteActions.length > 0) {
|
2023-01-13 05:40:33 +01:00
|
|
|
menu = menu.concat([
|
|
|
|
null,
|
|
|
|
...noteActions.map((action) => ({
|
2023-10-17 03:57:20 +02:00
|
|
|
icon: `${icon("ph-plug")}`,
|
2023-01-13 05:40:33 +01:00
|
|
|
text: action.title,
|
|
|
|
action: () => {
|
|
|
|
action.handler(appearNote);
|
|
|
|
},
|
|
|
|
})),
|
|
|
|
]);
|
2022-01-14 02:25:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|