mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-25 11:45:12 +00:00
refactor
This commit is contained in:
parent
b9c6992aac
commit
8e2d47b2e8
5 changed files with 13 additions and 11 deletions
|
@ -51,7 +51,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<script lang="ts" setup>
|
||||
import { defineAsyncComponent } from 'vue';
|
||||
import { toUnicode } from 'punycode/';
|
||||
import { UserDetailed } from 'misskey-js/built/entities';
|
||||
import * as Misskey from 'misskey-js';
|
||||
import { supported as webAuthnSupported, get as webAuthnRequest, parseRequestOptionsFromJSON } from '@github/webauthn-json/browser-ponyfill';
|
||||
import { showSuspendedDialog } from '@/scripts/show-suspended-dialog.js';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
|
@ -63,7 +63,7 @@ import { login } from '@/account.js';
|
|||
import { i18n } from '@/i18n.js';
|
||||
|
||||
let signing = $ref(false);
|
||||
let user = $ref<UserDetailed | null>(null);
|
||||
let user = $ref<Misskey.entities.UserDetailed | null>(null);
|
||||
let username = $ref('');
|
||||
let password = $ref('');
|
||||
let token = $ref('');
|
||||
|
|
|
@ -286,6 +286,7 @@ const patrons = [
|
|||
'Nick / pprmint.',
|
||||
'kino3277',
|
||||
'美少女JKぐーちゃん',
|
||||
'てば',
|
||||
];
|
||||
|
||||
let thereIsTreasure = $ref($i && !claimedAchievements.includes('foundTreasure'));
|
||||
|
|
|
@ -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<E extends keyof Endpoints, P extends Endpoints[E]['req']>(endpoint: E, data: P = {} as any, token?: string | null | undefined, signal?: AbortSignal): Promise<Endpoints[E]['res']> {
|
||||
export function api<E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(endpoint: E, data: P = {} as any, token?: string | null | undefined, signal?: AbortSignal): Promise<Misskey.Endpoints[E]['res']> {
|
||||
pendingApiRequestsCount.value++;
|
||||
|
||||
const onFinally = () => {
|
||||
pendingApiRequestsCount.value--;
|
||||
};
|
||||
|
||||
const promise = new Promise<Endpoints[E]['res'] | void>((resolve, reject) => {
|
||||
const promise = new Promise<Misskey.Endpoints[E]['res'] | void>((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<E extends keyof Endpoints, P extends Endpoints[E]['req']>(en
|
|||
}
|
||||
|
||||
// Implements Misskey.api.ApiClient.request
|
||||
export function apiGet <E extends keyof Endpoints, P extends Endpoints[E]['req']>(endpoint: E, data: P = {} as any): Promise<Endpoints[E]['res']> {
|
||||
export function apiGet <E extends keyof Misskey.Endpoints, P extends Misskey.Endpoints[E]['req']>(endpoint: E, data: P = {} as any): Promise<Misskey.Endpoints[E]['res']> {
|
||||
pendingApiRequestsCount.value++;
|
||||
|
||||
const onFinally = () => {
|
||||
|
@ -60,7 +60,7 @@ export function apiGet <E extends keyof Endpoints, P extends Endpoints[E]['req']
|
|||
|
||||
const query = new URLSearchParams(data as any);
|
||||
|
||||
const promise = new Promise<Endpoints[E]['res'] | void>((resolve, reject) => {
|
||||
const promise = new Promise<Misskey.Endpoints[E]['res'] | void>((resolve, reject) => {
|
||||
// Send request
|
||||
window.fetch(`${apiUrl}/${endpoint}?${query}`, {
|
||||
method: 'GET',
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { EndoRelation, Predicate } from './relation.js';
|
||||
type EndoRelation<T> = (a: T, b: T) => boolean;
|
||||
type Predicate<T> = (x: T) => boolean;
|
||||
|
||||
/**
|
||||
* Count the number of elements that satisfy the predicate
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue