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

fixed prettier, eslint?

This commit is contained in:
muerwre 2019-08-07 15:48:17 +07:00
parent 3eafd990cb
commit 3413b22ac2
6 changed files with 70 additions and 20 deletions
src
redux/uploads
utils

View file

@ -11,7 +11,7 @@ function* uploadCall({ temp_id, onProgress, file }) {
return yield call(reqWrapper, fakeUploader, { file: { url: 'some', error: 'cant do this boss' }, onProgress, mustSucceed: true });
}
function* onUploadProgress(chan) {
function* onUploadProgress(chan) {
while (true) {
const { progress, temp_id }: { progress: number; temp_id: string } = yield take(chan);

View file

@ -10,10 +10,7 @@ export const IMAGE_MIME_TYPES = ['image/jpeg', 'image/png', 'image/gif', 'image/
export function createUploader<T extends {}, R extends {}>(
callback: (args: any) => any,
payload: R
): [
(args: T) => (args: T & { onProgress: (current: number, total: number) => void }) => any,
EventChannel<any>
] {
): [(args: T) => (args: T & { onProgress: (current: number, total: number) => void }) => any, EventChannel<any>] {
let emit;
const chan = eventChannel(emitter => {
@ -22,9 +19,7 @@ export function createUploader<T extends {}, R extends {}>(
});
const onProgress = (current: number, total: number): void => {
emit(
current >= total ? END : { ...payload, progress: parseFloat((current / total).toFixed(1)) }
);
emit(current >= total ? END : { ...payload, progress: parseFloat((current / total).toFixed(1)) });
};
const wrappedCallback = args => callback({ ...args, onProgress });
@ -45,11 +40,11 @@ export const uploadGetThumb = async file => {
export const fakeUploader = ({
file,
onProgress,
mustSucceed,
mustSucceed
}: {
file: { url?: string; error?: string };
onProgress: (current: number, total: number) => void;
mustSucceed: boolean;
file: { url?: string; error?: string };
onProgress: (current: number, total: number) => void;
mustSucceed: boolean;
}): Promise<IResultWithStatus<IFile>> => {
const { url, error } = file;