wip
This commit is contained in:
parent
73a83c0064
commit
6c7f24fbb8
|
|
@ -446,14 +446,6 @@ function deleteFolder(folderToDelete: Misskey.entities.DriveFolder) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function upload(file: File, folderToUpload?: Misskey.entities.DriveFolder | null, keepOriginal?: boolean) {
|
|
||||||
uploadFile(file, (folderToUpload && typeof folderToUpload === 'object') ? folderToUpload.id : null, undefined, keepOriginal).then(res => {
|
|
||||||
if (res.folderId === (folder.value?.id ?? null)) {
|
|
||||||
filesPaginator.prepend(res);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function onChooseFile(file: Misskey.entities.DriveFile) {
|
function onChooseFile(file: Misskey.entities.DriveFile) {
|
||||||
const isAlreadySelected = selectedFiles.value.some(f => f.id === file.id);
|
const isAlreadySelected = selectedFiles.value.some(f => f.id === file.id);
|
||||||
|
|
||||||
|
|
@ -649,6 +641,12 @@ function closeTip() {
|
||||||
store.set('readDriveTip', true);
|
store.set('readDriveTip', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useGlobalEvent('driveFileCreated', (file) => {
|
||||||
|
if (file.folderId === (folder.value?.id ?? null)) {
|
||||||
|
filesPaginator.prepend(file);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
useGlobalEvent('driveFilesMoved', (files, to) => {
|
useGlobalEvent('driveFilesMoved', (files, to) => {
|
||||||
for (const f of files) {
|
for (const f of files) {
|
||||||
filesPaginator.removeItem(f.id);
|
filesPaginator.removeItem(f.id);
|
||||||
|
|
|
||||||
|
|
@ -463,14 +463,6 @@ function replaceFile(file: Misskey.entities.DriveFile, newFile: Misskey.entities
|
||||||
files.value[files.value.findIndex(x => x.id === file.id)] = newFile;
|
files.value[files.value.findIndex(x => x.id === file.id)] = newFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
function upload(file: File, name?: string): void {
|
|
||||||
if (props.mock) return;
|
|
||||||
|
|
||||||
uploadFile(file, prefer.s.uploadFolder, name).then(res => {
|
|
||||||
files.value.push(res);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function setVisibility() {
|
function setVisibility() {
|
||||||
if (props.channel) {
|
if (props.channel) {
|
||||||
visibility.value = 'public';
|
visibility.value = 'public';
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ type Events = {
|
||||||
clientNotification: (notification: Misskey.entities.Notification) => void;
|
clientNotification: (notification: Misskey.entities.Notification) => void;
|
||||||
notePosted: (note: Misskey.entities.Note) => void;
|
notePosted: (note: Misskey.entities.Note) => void;
|
||||||
noteDeleted: (noteId: Misskey.entities.Note['id']) => void;
|
noteDeleted: (noteId: Misskey.entities.Note['id']) => void;
|
||||||
|
driveFileCreated: (file: Misskey.entities.DriveFile) => void;
|
||||||
driveFilesMoved: (files: Misskey.entities.DriveFile[], to: Misskey.entities.DriveFolder | null) => void;
|
driveFilesMoved: (files: Misskey.entities.DriveFile[], to: Misskey.entities.DriveFolder | null) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,7 @@ async function onDrop(ev: DragEvent) {
|
||||||
Promise.all(
|
Promise.all(
|
||||||
droppedFiles.map(async (it) => ({
|
droppedFiles.map(async (it) => ({
|
||||||
droppedFile: it,
|
droppedFile: it,
|
||||||
driveFile: await uploadFile(
|
driveFile: await uploadFile( // TODO
|
||||||
it.file,
|
it.file,
|
||||||
selectedFolderId.value,
|
selectedFolderId.value,
|
||||||
it.file.name.replace(/\.[^.]+$/, ''),
|
it.file.name.replace(/\.[^.]+$/, ''),
|
||||||
|
|
|
||||||
|
|
@ -176,12 +176,6 @@ function onChangeFile() {
|
||||||
if (fileEl.value.files[0]) upload(fileEl.value.files[0]);
|
if (fileEl.value.files[0]) upload(fileEl.value.files[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function upload(fileToUpload: File, name?: string) {
|
|
||||||
uploadFile(fileToUpload, prefer.s.uploadFolder, name).then(res => {
|
|
||||||
file.value = res;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function send() {
|
function send() {
|
||||||
if (!canSend.value) return;
|
if (!canSend.value) return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import { $i } from '@/i.js';
|
||||||
import { instance } from '@/instance.js';
|
import { instance } from '@/instance.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
|
import { globalEvents } from '@/events.js';
|
||||||
|
|
||||||
export function uploadFile(file: File | Blob, options: {
|
export function uploadFile(file: File | Blob, options: {
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|
@ -71,6 +72,7 @@ export function uploadFile(file: File | Blob, options: {
|
||||||
}
|
}
|
||||||
|
|
||||||
const driveFile = JSON.parse(ev.target.response);
|
const driveFile = JSON.parse(ev.target.response);
|
||||||
|
globalEvents.emit('driveFileCreated', driveFile);
|
||||||
resolve(driveFile);
|
resolve(driveFile);
|
||||||
}) as (ev: ProgressEvent<EventTarget>) => any;
|
}) as (ev: ProgressEvent<EventTarget>) => any;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue