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
191 changed files with 581 additions and 468 deletions

View File

@@ -49,7 +49,8 @@ import { defineAsyncComponent, ref } from 'vue';
import * as Misskey from 'misskey-js';
import { swInject } from './sw-inject.js';
import XNotification from './notification.vue';
import { popups, pendingApiRequestsCount } from '@/os.js';
import { popups } from '@/os.js';
import { pendingApiRequestsCount } from '@/scripts/misskey-api.js';
import { uploads } from '@/scripts/upload.js';
import * as sound from '@/scripts/sound.js';
import { $i } from '@/account.js';

View File

@@ -34,7 +34,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { ref } from 'vue';
import * as Misskey from 'misskey-js';
import MarqueeText from '@/components/MkMarquee.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useInterval } from '@/scripts/use-interval.js';
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy.js';
@@ -52,7 +52,7 @@ const fetching = ref(true);
const key = ref(0);
const tick = () => {
os.api('federation/instances', {
misskeyApi('federation/instances', {
sort: '+latestRequestReceivedAt',
limit: 30,
}).then(res => {

View File

@@ -34,7 +34,7 @@ SPDX-License-Identifier: AGPL-3.0-only
import { ref, watch } from 'vue';
import * as Misskey from 'misskey-js';
import MarqueeText from '@/components/MkMarquee.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { useInterval } from '@/scripts/use-interval.js';
import { getNoteSummary } from '@/scripts/get-note-summary.js';
import { notePage } from '@/filters/note.js';
@@ -54,7 +54,7 @@ const key = ref(0);
const tick = () => {
if (props.userListId == null) return;
os.api('notes/user-list-timeline', {
misskeyApi('notes/user-list-timeline', {
listId: props.userListId,
}).then(res => {
notes.value = res;

View File

@@ -3,7 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { api, post } from '@/os.js';
import { post } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { $i, login } from '@/account.js';
import { getAccountFromId } from '@/scripts/get-account-from-id.js';
import { mainRouter } from '@/router.js';
@@ -30,10 +31,10 @@ export function swInject() {
// プッシュ通知から来たreply,renoteはtruncateBodyが通されているため、
// 完全なノートを取得しなおす
if (props.reply) {
props.reply = await api('notes/show', { noteId: props.reply.id });
props.reply = await misskeyApi('notes/show', { noteId: props.reply.id });
}
if (props.renote) {
props.renote = await api('notes/show', { noteId: props.renote.id });
props.renote = await misskeyApi('notes/show', { noteId: props.renote.id });
}
return post(props);
}

View File

@@ -19,6 +19,7 @@ import XColumn from './column.vue';
import { updateColumn, Column } from './deck-store.js';
import MkTimeline from '@/components/MkTimeline.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
const props = defineProps<{
@@ -35,7 +36,7 @@ onMounted(() => {
});
async function setAntenna() {
const antennas = await os.api('antennas/list');
const antennas = await misskeyApi('antennas/list');
const { canceled, result: antenna } = await os.select({
title: i18n.ts.selectAntenna,
items: antennas.map(x => ({

View File

@@ -26,6 +26,7 @@ import { updateColumn, Column } from './deck-store.js';
import MkTimeline from '@/components/MkTimeline.vue';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
const props = defineProps<{
@@ -41,7 +42,7 @@ if (props.column.channelId == null) {
}
async function setChannel() {
const channels = await os.api('channels/my-favorites', {
const channels = await misskeyApi('channels/my-favorites', {
limit: 100,
});
const { canceled, result: channel } = await os.select({
@@ -60,7 +61,7 @@ async function setChannel() {
async function post() {
if (!channel.value || channel.value.id !== props.column.channelId) {
channel.value = await os.api('channels/show', {
channel.value = await misskeyApi('channels/show', {
channelId: props.column.channelId,
});
}

View File

@@ -7,7 +7,7 @@ import { throttle } from 'throttle-debounce';
import { markRaw } from 'vue';
import { notificationTypes } from 'misskey-js';
import { Storage } from '@/pizzax.js';
import { api } from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { deepClone } from '@/scripts/clone.js';
type ColumnWidget = {
@@ -70,7 +70,7 @@ export const loadDeck = async () => {
let deck;
try {
deck = await api('i/registry/get', {
deck = await misskeyApi('i/registry/get', {
scope: ['client', 'deck', 'profiles'],
key: deckStore.state.profile,
});
@@ -95,7 +95,7 @@ export const loadDeck = async () => {
// TODO: deckがloadされていない状態でsaveすると意図せず上書きが発生するので対策する
export const saveDeck = throttle(1000, () => {
api('i/registry/set', {
misskeyApi('i/registry/set', {
scope: ['client', 'deck', 'profiles'],
key: deckStore.state.profile,
value: {
@@ -106,13 +106,13 @@ export const saveDeck = throttle(1000, () => {
});
export async function getProfiles(): Promise<string[]> {
return await api('i/registry/keys', {
return await misskeyApi('i/registry/keys', {
scope: ['client', 'deck', 'profiles'],
});
}
export async function deleteProfile(key: string): Promise<void> {
return await api('i/registry/remove', {
return await misskeyApi('i/registry/remove', {
scope: ['client', 'deck', 'profiles'],
key: key,
});

View File

@@ -19,6 +19,7 @@ import XColumn from './column.vue';
import { updateColumn, Column } from './deck-store.js';
import MkTimeline from '@/components/MkTimeline.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
const props = defineProps<{
@@ -40,7 +41,7 @@ watch(withRenotes, v => {
});
async function setList() {
const lists = await os.api('users/lists/list');
const lists = await misskeyApi('users/lists/list');
const { canceled, result: list } = await os.select({
title: i18n.ts.selectList,
items: lists.map(x => ({

View File

@@ -19,6 +19,7 @@ import XColumn from './column.vue';
import { updateColumn, Column } from './deck-store.js';
import MkTimeline from '@/components/MkTimeline.vue';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { i18n } from '@/i18n.js';
const props = defineProps<{
@@ -35,7 +36,7 @@ onMounted(() => {
});
async function setRole() {
const roles = (await os.api('roles/list')).filter(x => x.isExplorable);
const roles = (await misskeyApi('roles/list')).filter(x => x.isExplorable);
const { canceled, result: role } = await os.select({
title: i18n.ts.role,
items: roles.map(x => ({

View File

@@ -74,6 +74,7 @@ import * as Misskey from 'misskey-js';
import XCommon from './_common_/common.vue';
import { instanceName } from '@/config.js';
import * as os from '@/os.js';
import { misskeyApi } from '@/scripts/misskey-api.js';
import { instance } from '@/instance.js';
import XSigninDialog from '@/components/MkSigninDialog.vue';
import XSignupDialog from '@/components/MkSignupDialog.vue';
@@ -121,7 +122,7 @@ const keymap = computed(() => {
const root = computed(() => mainRouter.currentRoute.value.name === 'index');
os.api('meta', { detail: true }).then(res => {
misskeyApi('meta', { detail: true }).then(res => {
meta.value = res;
});