refactor(frontend): os.tsに引き込んだscripts/api.tsの再exportをやめる (#12694)

* refactor(frontend): os.tsに引き込んだscripts/api.tsの再exportをやめる

* fix

* fix

* renate to "misskeyApi"

* rename file
This commit is contained in:
おさむのひと 2024-01-04 18:32:46 +09:00 committed by GitHub
parent ea41cc6ec0
commit fa9c4a19b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
191 changed files with 581 additions and 468 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') {
@ -145,7 +146,7 @@ export function getNoteMenu(props: {
}).then(({ canceled }) => {
if (canceled) return;
os.api('notes/delete', {
misskeyApi('notes/delete', {
noteId: appearNote.id,
});
@ -162,7 +163,7 @@ export function getNoteMenu(props: {
}).then(({ canceled }) => {
if (canceled) return;
os.api('notes/delete', {
misskeyApi('notes/delete', {
noteId: appearNote.id,
});
@ -243,7 +244,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,
});
@ -253,7 +254,7 @@ export function getNoteMenu(props: {
let menu: MenuItem[];
if ($i) {
const statePromise = os.api('notes/state', {
const statePromise = misskeyApi('notes/state', {
noteId: appearNote.id,
});
@ -330,7 +331,7 @@ export function getNoteMenu(props: {
icon: 'ti ti-user',
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;
@ -361,7 +362,7 @@ export function getNoteMenu(props: {
children: async () => {
const channelChildMenu = [] as MenuItem[];
const channel = await os.api('channels/show', { channelId: appearNote.channel!.id });
const channel = await misskeyApi('channels/show', { channelId: appearNote.channel!.id });
if (channel.pinnedNoteIds.includes(appearNote.id)) {
channelChildMenu.push({
@ -425,7 +426,7 @@ export function getNoteMenu(props: {
}
if (noteActions.length > 0) {
menu = menu.concat([{ type: "divider" }, ...noteActions.map(action => ({
menu = menu.concat([{ type: 'divider' }, ...noteActions.map(action => ({
icon: 'ti ti-plug',
text: action.title,
action: () => {
@ -435,7 +436,7 @@ export function getNoteMenu(props: {
}
if (defaultStore.state.devMode) {
menu = menu.concat([{ type: "divider" }, {
menu = menu.concat([{ type: 'divider' }, {
icon: 'ti ti-id',
text: i18n.ts.copyNoteId,
action: () => {
@ -499,7 +500,7 @@ export function getRenoteMenu(props: {
}
if (!props.mock) {
os.api('notes/create', {
misskeyApi('notes/create', {
renoteId: appearNote.id,
channelId: appearNote.channelId,
}).then(() => {
@ -544,7 +545,7 @@ export function getRenoteMenu(props: {
}
if (!props.mock) {
os.api('notes/create', {
misskeyApi('notes/create', {
localOnly,
visibility,
renoteId: appearNote.id,