From 8e2d47b2e882a9fb10e60c2ea0274a0fa54abb8f Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 20 Sep 2023 16:44:12 +0900 Subject: refactor --- packages/frontend/src/scripts/api.ts | 10 +++++----- packages/frontend/src/scripts/array.ts | 3 ++- packages/frontend/src/scripts/get-note-menu.ts | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'packages/frontend/src/scripts') diff --git a/packages/frontend/src/scripts/api.ts b/packages/frontend/src/scripts/api.ts index d73d60cf26..9259c88013 100644 --- a/packages/frontend/src/scripts/api.ts +++ b/packages/frontend/src/scripts/api.ts @@ -3,21 +3,21 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { Endpoints } from 'misskey-js/built/api.types'; +import * as Misskey from 'misskey-js'; import { ref } from 'vue'; import { apiUrl } from '@/config.js'; import { $i } from '@/account.js'; export const pendingApiRequestsCount = ref(0); // Implements Misskey.api.ApiClient.request -export function api(endpoint: E, data: P = {} as any, token?: string | null | undefined, signal?: AbortSignal): Promise { +export function api(endpoint: E, data: P = {} as any, token?: string | null | undefined, signal?: AbortSignal): Promise { pendingApiRequestsCount.value++; const onFinally = () => { pendingApiRequestsCount.value--; }; - const promise = new Promise((resolve, reject) => { + const promise = new Promise((resolve, reject) => { // Append a credential if ($i) (data as any).i = $i.token; if (token !== undefined) (data as any).i = token; @@ -51,7 +51,7 @@ export function api(en } // Implements Misskey.api.ApiClient.request -export function apiGet (endpoint: E, data: P = {} as any): Promise { +export function apiGet (endpoint: E, data: P = {} as any): Promise { pendingApiRequestsCount.value++; const onFinally = () => { @@ -60,7 +60,7 @@ export function apiGet ((resolve, reject) => { + const promise = new Promise((resolve, reject) => { // Send request window.fetch(`${apiUrl}/${endpoint}?${query}`, { method: 'GET', diff --git a/packages/frontend/src/scripts/array.ts b/packages/frontend/src/scripts/array.ts index d83b001c87..082703a450 100644 --- a/packages/frontend/src/scripts/array.ts +++ b/packages/frontend/src/scripts/array.ts @@ -3,7 +3,8 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { EndoRelation, Predicate } from './relation.js'; +type EndoRelation = (a: T, b: T) => boolean; +type Predicate = (x: T) => boolean; /** * Count the number of elements that satisfy the predicate diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index a0b8683be3..734a632039 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -5,7 +5,7 @@ import { defineAsyncComponent, Ref } from 'vue'; import * as Misskey from 'misskey-js'; -import { claimAchievement } from './achievements'; +import { claimAchievement } from './achievements.js'; import { $i } from '@/account.js'; import { i18n } from '@/i18n.js'; import { instance } from '@/instance.js'; @@ -15,8 +15,8 @@ import { url } from '@/config.js'; import { defaultStore, noteActions } from '@/store.js'; import { miLocalStorage } from '@/local-storage.js'; import { getUserMenu } from '@/scripts/get-user-menu.js'; -import { clipsCache } from '@/cache'; -import { MenuItem } from '@/types/menu'; +import { clipsCache } from '@/cache.js'; +import { MenuItem } from '@/types/menu.js'; export async function getNoteClipMenu(props: { note: Misskey.entities.Note; -- cgit v1.2.3-freya