mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
fixed audio attaches
This commit is contained in:
parent
c9d84a4947
commit
b11593c45e
7 changed files with 68 additions and 69 deletions
|
@ -240,7 +240,8 @@ function* onCancelCommentEdit({ id }: ReturnType<typeof nodeCancelCommentEdit>)
|
|||
}
|
||||
|
||||
function* onUpdateTags({ id, tags }: ReturnType<typeof nodeUpdateTags>) {
|
||||
yield delay(1000);
|
||||
yield delay(100);
|
||||
|
||||
const {
|
||||
data: { node },
|
||||
}: IResultWithStatus<{ node: INode }> = yield call(reqWrapper, updateNodeTags, { id, tags });
|
||||
|
|
|
@ -1,49 +1,37 @@
|
|||
import {
|
||||
takeEvery,
|
||||
all,
|
||||
spawn,
|
||||
call,
|
||||
put,
|
||||
take,
|
||||
fork,
|
||||
race
|
||||
} from "redux-saga/effects";
|
||||
import { postUploadFile } from "./api";
|
||||
import { UPLOAD_ACTIONS, FILE_MIMES } from "~/redux/uploads/constants";
|
||||
import { takeEvery, all, spawn, call, put, take, fork, race } from 'redux-saga/effects';
|
||||
import { postUploadFile } from './api';
|
||||
import { UPLOAD_ACTIONS, FILE_MIMES } from '~/redux/uploads/constants';
|
||||
import {
|
||||
uploadUploadFiles,
|
||||
uploadSetStatus,
|
||||
uploadAddStatus,
|
||||
uploadDropStatus,
|
||||
uploadAddFile
|
||||
} from "./actions";
|
||||
import { reqWrapper } from "../auth/sagas";
|
||||
import { createUploader, uploadGetThumb } from "~/utils/uploader";
|
||||
import { HTTP_RESPONSES } from "~/utils/api";
|
||||
import { IFileWithUUID, IFile, IUploadProgressHandler } from "../types";
|
||||
uploadAddFile,
|
||||
} from './actions';
|
||||
import { reqWrapper } from '../auth/sagas';
|
||||
import { createUploader, uploadGetThumb } from '~/utils/uploader';
|
||||
import { HTTP_RESPONSES } from '~/utils/api';
|
||||
import { IFileWithUUID, IFile, IUploadProgressHandler } from '../types';
|
||||
|
||||
function* uploadCall({
|
||||
file,
|
||||
temp_id,
|
||||
target,
|
||||
type,
|
||||
onProgress
|
||||
onProgress,
|
||||
}: IFileWithUUID & { onProgress: IUploadProgressHandler }) {
|
||||
return yield call(reqWrapper, postUploadFile, {
|
||||
file,
|
||||
temp_id,
|
||||
type,
|
||||
target,
|
||||
onProgress
|
||||
onProgress,
|
||||
});
|
||||
}
|
||||
|
||||
function* onUploadProgress(chan) {
|
||||
while (true) {
|
||||
const {
|
||||
progress,
|
||||
temp_id
|
||||
}: { progress: number; temp_id: string } = yield take(chan);
|
||||
const { progress, temp_id }: { progress: number; temp_id: string } = yield take(chan);
|
||||
|
||||
yield put(uploadSetStatus(temp_id, { progress }));
|
||||
}
|
||||
|
@ -59,10 +47,10 @@ function* uploadCancelWorker(id) {
|
|||
}
|
||||
|
||||
function* uploadWorker({ file, temp_id, target, type }: IFileWithUUID) {
|
||||
const [promise, chan] = createUploader<
|
||||
Partial<IFileWithUUID>,
|
||||
Partial<IFileWithUUID>
|
||||
>(uploadCall, { temp_id, target, type });
|
||||
const [promise, chan] = createUploader<Partial<IFileWithUUID>, Partial<IFileWithUUID>>(
|
||||
uploadCall,
|
||||
{ temp_id, target, type }
|
||||
);
|
||||
|
||||
yield fork(onUploadProgress, chan);
|
||||
|
||||
|
@ -70,23 +58,16 @@ function* uploadWorker({ file, temp_id, target, type }: IFileWithUUID) {
|
|||
temp_id,
|
||||
file,
|
||||
target,
|
||||
type
|
||||
type,
|
||||
});
|
||||
}
|
||||
|
||||
function* uploadFile({
|
||||
file,
|
||||
temp_id,
|
||||
type,
|
||||
target,
|
||||
onSuccess,
|
||||
onFail
|
||||
}: IFileWithUUID) {
|
||||
if (!file.type || !file.type || !FILE_MIMES[type].includes(file.type)) {
|
||||
function* uploadFile({ file, temp_id, type, target, onSuccess, onFail }: IFileWithUUID) {
|
||||
if (!file.type || !FILE_MIMES[type] || !FILE_MIMES[type].includes(file.type)) {
|
||||
return {
|
||||
error: "File_Not_Image",
|
||||
error: 'File_Not_Image',
|
||||
status: HTTP_RESPONSES.BAD_REQUEST,
|
||||
data: {}
|
||||
data: {},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -99,10 +80,9 @@ function* uploadFile({
|
|||
{
|
||||
preview,
|
||||
is_uploading: true,
|
||||
// type: file.type,
|
||||
temp_id,
|
||||
type,
|
||||
name: file.name
|
||||
name: file.name,
|
||||
}
|
||||
)
|
||||
);
|
||||
|
@ -112,13 +92,9 @@ function* uploadFile({
|
|||
file,
|
||||
temp_id,
|
||||
target,
|
||||
type
|
||||
type,
|
||||
}),
|
||||
cancel: call(uploadCancelWorker, temp_id)
|
||||
// subject_cancel: call(uploadSubjectCancelWorker, subject)
|
||||
// add here CANCEL_UPLOADS worker, that will watch for subject
|
||||
// cancel_editing: take(UPLOAD_ACTIONS.CANCEL_EDITING),
|
||||
// save_inventory: take(INVENTORY_ACTIONS.SAVE_INVENTORY),
|
||||
cancel: call(uploadCancelWorker, temp_id),
|
||||
});
|
||||
|
||||
if (cancel || cancel_editing) {
|
||||
|
@ -126,10 +102,7 @@ function* uploadFile({
|
|||
return yield put(uploadDropStatus(temp_id));
|
||||
}
|
||||
|
||||
const {
|
||||
data,
|
||||
error
|
||||
}: { data: IFile & { detail: string }; error: string } = result;
|
||||
const { data, error }: { data: IFile & { detail: string }; error: string } = result;
|
||||
|
||||
if (error) {
|
||||
if (onFail) onFail();
|
||||
|
@ -138,7 +111,7 @@ function* uploadFile({
|
|||
uploadSetStatus(temp_id, {
|
||||
is_uploading: false,
|
||||
error: data.detail || error,
|
||||
type
|
||||
type,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -152,7 +125,7 @@ function* uploadFile({
|
|||
type,
|
||||
thumbnail_url: data.full_path,
|
||||
progress: 1,
|
||||
name: file.name
|
||||
name: file.name,
|
||||
})
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue