refactor(client):

This commit is contained in:
syuilo
2021-12-10 01:22:22 +09:00
parent 980a99b6c9
commit 46c0280764
10 changed files with 23 additions and 14 deletions

View File

@ -1,8 +1,9 @@
import * as os from '@/os';
import { i18n } from '@/i18n';
import { defaultStore } from '@/store';
import { DriveFile } from 'misskey-js/built/entities';
export function selectFile(src: any, label: string | null, multiple = false) {
function select(src: any, label: string | null, multiple: boolean): Promise<DriveFile | DriveFile[]> {
return new Promise((res, rej) => {
const chooseFileFromPc = () => {
const input = document.createElement('input');
@ -86,3 +87,11 @@ export function selectFile(src: any, label: string | null, multiple = false) {
}], src);
});
}
export function selectFile(src: any, label: string | null = null): Promise<DriveFile> {
return select(src, label, false) as Promise<DriveFile>;
}
export function selectFiles(src: any, label: string | null = null): Promise<DriveFile[]> {
return select(src, label, true) as Promise<DriveFile[]>;
}