merge: upstream

This commit is contained in:
Marie 2024-01-09 02:57:57 +01:00
commit 7552cea69a
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
413 changed files with 5517 additions and 2309 deletions

View file

@ -10,6 +10,7 @@ import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
import { instance } from '@/instance.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
import { url } from '@/config.js';
import { defaultStore, noteActions } from '@/store.js';
@ -40,7 +41,7 @@ export async function getNoteClipMenu(props: {
action: () => {
claimAchievement('noteClipped1');
os.promiseDialog(
os.api('clips/add-note', { clipId: clip.id, noteId: appearNote.id }),
misskeyApi('clips/add-note', { clipId: clip.id, noteId: appearNote.id }),
null,
async (err) => {
if (err.id === '734806c4-542c-463a-9311-15c512803965') {
@ -156,7 +157,7 @@ export function getNoteMenu(props: {
}).then(({ canceled }) => {
if (canceled) return;
os.api('notes/delete', {
misskeyApi('notes/delete', {
noteId: appearNote.id,
});
@ -173,7 +174,7 @@ export function getNoteMenu(props: {
}).then(({ canceled }) => {
if (canceled) return;
os.api('notes/delete', {
misskeyApi('notes/delete', {
noteId: appearNote.id,
});
@ -265,7 +266,7 @@ export function getNoteMenu(props: {
async function translate(): Promise<void> {
if (props.translation.value != null) return;
props.translating.value = true;
const res = await os.api('notes/translate', {
const res = await misskeyApi('notes/translate', {
noteId: appearNote.id,
targetLang: miLocalStorage.getItem('lang') ?? navigator.language,
});
@ -275,7 +276,7 @@ export function getNoteMenu(props: {
let menu: MenuItem[];
if ($i) {
const statePromise = os.api('notes/state', {
const statePromise = misskeyApi('notes/state', {
noteId: appearNote.id,
});
@ -355,7 +356,7 @@ export function getNoteMenu(props: {
icon: 'ph-user ph-bold ph-lg',
text: i18n.ts.user,
children: async () => {
const user = appearNote.userId === $i?.id ? $i : await os.api('users/show', { userId: appearNote.userId });
const user = appearNote.userId === $i?.id ? $i : await misskeyApi('users/show', { userId: appearNote.userId });
const { menu, cleanup } = getUserMenu(user);
cleanups.push(cleanup);
return menu;
@ -377,6 +378,42 @@ export function getNoteMenu(props: {
]
: []
),
...(appearNote.channel && (appearNote.channel.userId === $i.id || $i.isModerator || $i.isAdmin) ? [
{ type: 'divider' },
{
type: 'parent' as const,
icon: 'ti ti-device-tv',
text: i18n.ts.channel,
children: async () => {
const channelChildMenu = [] as MenuItem[];
const channel = await misskeyApi('channels/show', { channelId: appearNote.channel!.id });
if (channel.pinnedNoteIds.includes(appearNote.id)) {
channelChildMenu.push({
icon: 'ti ti-pinned-off',
text: i18n.ts.unpin,
action: () => os.apiWithDialog('channels/update', {
channelId: appearNote.channel!.id,
pinnedNoteIds: channel.pinnedNoteIds.filter(id => id !== appearNote.id),
}),
});
} else {
channelChildMenu.push({
icon: 'ti ti-pin',
text: i18n.ts.pin,
action: () => os.apiWithDialog('channels/update', {
channelId: appearNote.channel!.id,
pinnedNoteIds: [...channel.pinnedNoteIds, appearNote.id],
}),
});
}
return channelChildMenu;
},
},
]
: []
),
...(appearNote.userId === $i.id || $i.isModerator || $i.isAdmin ? [
{ type: 'divider' },
appearNote.userId === $i.id ? {
@ -497,7 +534,7 @@ export function getRenoteMenu(props: {
}
if (!props.mock) {
os.api('notes/create', {
misskeyApi('notes/create', {
renoteId: appearNote.id,
channelId: appearNote.channelId,
}).then(() => {
@ -542,7 +579,7 @@ export function getRenoteMenu(props: {
}
if (!props.mock) {
os.api('notes/create', {
misskeyApi('notes/create', {
localOnly,
visibility,
renoteId: appearNote.id,