mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
cleanup
This commit is contained in:
parent
4a3de2ab01
commit
69c7b71237
4 changed files with 9 additions and 14 deletions
|
@ -83,5 +83,6 @@ module.exports = {
|
||||||
HTMLInputElement: false,
|
HTMLInputElement: false,
|
||||||
HTMLDivElement: false,
|
HTMLDivElement: false,
|
||||||
FormData: false,
|
FormData: false,
|
||||||
|
FileReader: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,7 @@ import * as NODE_ACTIONS from '~/redux/node/actions';
|
||||||
import { selectNode } from '~/redux/node/selectors';
|
import { selectNode } from '~/redux/node/selectors';
|
||||||
import { LoaderCircle } from '~/components/input/LoaderCircle';
|
import { LoaderCircle } from '~/components/input/LoaderCircle';
|
||||||
import { Group } from '~/components/containers/Group';
|
import { Group } from '~/components/containers/Group';
|
||||||
import { UPLOAD_SUBJECTS, UPLOAD_TARGETS, UPLOAD_TYPES } from '~/redux/uploads/constants';
|
import { UPLOAD_SUBJECTS, UPLOAD_TARGETS } from '~/redux/uploads/constants';
|
||||||
import uuid from 'uuid4';
|
import uuid from 'uuid4';
|
||||||
import * as UPLOAD_ACTIONS from '~/redux/uploads/actions';
|
import * as UPLOAD_ACTIONS from '~/redux/uploads/actions';
|
||||||
import { selectUploads } from '~/redux/uploads/selectors';
|
import { selectUploads } from '~/redux/uploads/selectors';
|
||||||
|
@ -149,14 +149,7 @@ const CommentFormUnconnected: FC<IProps> = ({
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{comment.files.map(
|
{comment.files.map(file => file.name && <div key={file.id}>{file.name}</div>)}
|
||||||
file =>
|
|
||||||
file.name && (
|
|
||||||
<div key={file.id}>
|
|
||||||
[{file.mime}] {file.name}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</CommentWrapper>
|
</CommentWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,7 +11,6 @@ import {
|
||||||
import { reqWrapper } from '../auth/sagas';
|
import { reqWrapper } from '../auth/sagas';
|
||||||
import { createUploader, uploadGetThumb } from '~/utils/uploader';
|
import { createUploader, uploadGetThumb } from '~/utils/uploader';
|
||||||
import { HTTP_RESPONSES } from '~/utils/api';
|
import { HTTP_RESPONSES } from '~/utils/api';
|
||||||
import { VALIDATORS } from '~/utils/validators';
|
|
||||||
import { IFileWithUUID, IFile, IUploadProgressHandler } from '../types';
|
import { IFileWithUUID, IFile, IUploadProgressHandler } from '../types';
|
||||||
|
|
||||||
function* uploadCall({
|
function* uploadCall({
|
||||||
|
@ -97,13 +96,13 @@ function* uploadFile({ file, temp_id, type, target }: IFileWithUUID) {
|
||||||
// add here CANCEL_UPLOADS worker, that will watch for subject
|
// add here CANCEL_UPLOADS worker, that will watch for subject
|
||||||
// cancel_editing: take(UPLOAD_ACTIONS.CANCEL_EDITING),
|
// cancel_editing: take(UPLOAD_ACTIONS.CANCEL_EDITING),
|
||||||
// save_inventory: take(INVENTORY_ACTIONS.SAVE_INVENTORY),
|
// save_inventory: take(INVENTORY_ACTIONS.SAVE_INVENTORY),
|
||||||
}) as any;
|
});
|
||||||
|
|
||||||
if (cancel || cancel_editing) {
|
if (cancel || cancel_editing) {
|
||||||
return yield put(uploadDropStatus(temp_id));
|
return yield put(uploadDropStatus(temp_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data, error }: { data: IFile & { detail: any }; error: string } = result;
|
const { data, error }: { data: IFile & { detail: string }; error: string } = result;
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return yield put(
|
return yield put(
|
||||||
|
|
|
@ -33,11 +33,13 @@ export function createUploader<T extends {}, R extends {}>(
|
||||||
export const uploadGetThumb = async file => {
|
export const uploadGetThumb = async file => {
|
||||||
if (!file.type || !VALIDATORS.IS_IMAGE_MIME(file.type)) return '';
|
if (!file.type || !VALIDATORS.IS_IMAGE_MIME(file.type)) return '';
|
||||||
|
|
||||||
return await new Promise((resolve, reject) => {
|
const thumb = await new Promise(resolve => {
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onloadend = () => resolve(reader.result || '');
|
reader.onloadend = () => resolve(reader.result || '');
|
||||||
reader.readAsDataURL(file);
|
reader.readAsDataURL(file);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return thumb;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fakeUploader = ({
|
export const fakeUploader = ({
|
||||||
|
@ -49,7 +51,7 @@ export const fakeUploader = ({
|
||||||
onProgress: (current: number, total: number) => void;
|
onProgress: (current: number, total: number) => void;
|
||||||
mustSucceed: boolean;
|
mustSucceed: boolean;
|
||||||
}): Promise<IResultWithStatus<IFile>> => {
|
}): Promise<IResultWithStatus<IFile>> => {
|
||||||
const { url, error } = file;
|
const { error } = file;
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue