1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-05-01 23:56:41 +07:00

fixed eslint again

This commit is contained in:
muerwre 2019-08-20 10:58:34 +07:00
parent f922536ffa
commit db0a94b581
5 changed files with 42 additions and 27 deletions

View file

@ -8,12 +8,21 @@ import { reqWrapper } from '../auth/sagas';
import { createUploader, uploadGetThumb, fakeUploader } from '~/utils/uploader';
import { HTTP_RESPONSES } from '~/utils/api';
import { VALIDATORS } from '~/utils/validators';
import { UUID, IFileWithUUID, IFile } from '../types';
import { UUID, IFileWithUUID, IFile, IUploadProgressHandler } from '../types';
function* uploadCall({ temp_id, onProgress, file }) {
function* uploadCall({ file, temp_id, target, type, onProgress }: IFileWithUUID & { onProgress: IUploadProgressHandler }) {
// return yield call(reqWrapper, fakeUploader, { file: { url: 'some', error: 'cant do this boss' }, onProgress, mustSucceed: true });
return yield call(reqWrapper, postUploadFile, { file: { url: 'some', error: 'cant do this boss' }, onProgress, mustSucceed: true });
return yield call(
reqWrapper,
postUploadFile,
{
file,
temp_id,
type,
target,
onProgress,
}
);
}
function* onUploadProgress(chan) {
@ -33,13 +42,19 @@ function* uploadCancelWorker(id) {
return true;
}
function* uploadWorker(file: File, temp_id: UUID) {
const [promise, chan] = createUploader<{ temp_id; file }, { temp_id }>(uploadCall, { temp_id });
function* uploadWorker({
file, temp_id, target, type,
}: IFileWithUUID) {
const [promise, chan] = createUploader<Partial<IFileWithUUID>, Partial<IFileWithUUID>>(uploadCall, { temp_id, target, type });
yield fork(onUploadProgress, chan);
return yield call(promise, { temp_id, file });
return yield call(promise, {
temp_id, file, target, type,
});
}
function* uploadFile({ file, temp_id }: IFileWithUUID) {
function* uploadFile({ file, temp_id, type, target }: IFileWithUUID) {
if (!file.type || !VALIDATORS.IS_IMAGE_MIME(file.type)) {
return { error: 'File_Not_Image', status: HTTP_RESPONSES.BAD_REQUEST, data: {} };
}
@ -62,7 +77,7 @@ function* uploadFile({ file, temp_id }: IFileWithUUID) {
const {
result, cancel, cancel_editing, save_inventory,
} = yield race({
result: call(uploadWorker, file, temp_id),
result: call(uploadWorker, { file, temp_id, target, type }),
cancel: call(uploadCancelWorker, temp_id),
// subject_cancel: call(uploadSubjectCancelWorker, subject)
// add here CANCEL_UPLOADS worker, that will watch for subject