diff --git a/src/components/flow/FlowHero/styles.scss b/src/components/flow/FlowHero/styles.scss index 738caa58..84f4776c 100644 --- a/src/components/flow/FlowHero/styles.scss +++ b/src/components/flow/FlowHero/styles.scss @@ -16,20 +16,20 @@ overflow: hidden; &::after { - content: ' '; + content: " "; position: absolute; top: 0; left: 0; width: 100%; height: 100%; - background: url('~/sprites/stripes.svg') rgba(0, 0, 0, 0.3); + background: url("~/sprites/stripes.svg") rgba(0, 0, 0, 0.3); z-index: 4; pointer-events: none; touch-action: none; } &::before { - content: ' '; + content: " "; position: absolute; top: 0; left: 0; diff --git a/src/redux/flow/sagas.ts b/src/redux/flow/sagas.ts index b1a9f452..2b09e6fe 100644 --- a/src/redux/flow/sagas.ts +++ b/src/redux/flow/sagas.ts @@ -41,14 +41,14 @@ function* onGetFlow() { hideLoader(); } - const start = - (stored && stored[0] && stored[0].created_at) || new Date().toISOString(); - - const end = - (stored && - stored[stored.length - 1] && - stored[stored.length - 1].created_at) || - new Date().toISOString(); + // const start = + // (stored && stored[0] && stored[0].created_at) || new Date().toISOString(); + // + // const end = + // (stored && + // stored[stored.length - 1] && + // stored[stored.length - 1].created_at) || + // new Date().toISOString(); yield put(flowSetFlow({ is_loading: true })); @@ -69,17 +69,17 @@ function* onGetFlow() { updated: IFlowState["updated"]; valid: INode["id"][]; }> = yield call(reqWrapper, getNodeDiff, { - start, - end, + start: new Date().toISOString(), + end: new Date().toISOString(), with_heroes: true, with_updated: true, with_recent: true, - with_valid: true + with_valid: false }); const result = uniq([ ...(before || []), - ...(valid ? stored.filter(node => valid.includes(node.id)) : stored), + // ...(valid ? stored.filter(node => valid.includes(node.id)) : stored), ...(after || []) ]); diff --git a/src/redux/store.ts b/src/redux/store.ts index 5f40b8b3..5a8f7e4e 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -45,8 +45,8 @@ const authPersistConfig: PersistConfig = { const flowPersistConfig: PersistConfig = { key: "flow", - // whitelist: ["nodes", "heroes", "recent", "updated"], - whitelist: [], + whitelist: ["nodes", "heroes", "recent", "updated"], + // whitelist: [], storage }; diff --git a/src/redux/types.ts b/src/redux/types.ts index d3b92066..6a9b38c0 100644 --- a/src/redux/types.ts +++ b/src/redux/types.ts @@ -1,7 +1,7 @@ -import { DetailedHTMLProps, InputHTMLAttributes } from 'react'; -import { DIALOGS } from '~/redux/modal/constants'; -import { ERRORS } from '~/constants/errors'; -import { IUser } from './auth/types'; +import { DetailedHTMLProps, InputHTMLAttributes } from "react"; +import { DIALOGS } from "~/redux/modal/constants"; +import { ERRORS } from "~/constants/errors"; +import { IUser } from "./auth/types"; export interface ITag { id: number; @@ -55,7 +55,7 @@ export interface IResultWithStatus { export type UUID = string; -export type IUploadType = 'image' | 'text' | 'audio' | 'video' | 'other'; +export type IUploadType = "image" | "text" | "audio" | "video" | "other"; export interface IFile { id?: number; @@ -91,15 +91,17 @@ export interface IFileWithUUID { subject?: string; target: string; type: string; + onSuccess?: (file: IFile) => void; + onFail?: () => void; } export interface IBlockText { - type: 'text'; + type: "text"; text: string; } export interface IBlockEmbed { - type: 'video'; + type: "video"; url: string; } @@ -122,7 +124,7 @@ export interface INode { is_heroic?: boolean; flow: { - display: 'single' | 'vertical' | 'horizontal' | 'quadro'; + display: "single" | "vertical" | "horizontal" | "quadro"; show_description: boolean; }; @@ -145,7 +147,7 @@ export interface IComment { update_at?: string; } -export type IMessage = Omit & { +export type IMessage = Omit & { from: IUser; to: IUser; }; @@ -153,7 +155,7 @@ export type IMessage = Omit & { export interface ICommentGroup { user: IUser; comments: IComment[]; - ids: IComment['id'][]; + ids: IComment["id"][]; } export type IUploadProgressHandler = (progress: ProgressEvent) => void; @@ -162,25 +164,25 @@ export type IValidationErrors = Record; export type InputHandler = (val: T) => void; export const NOTIFICATION_TYPES = { - message: 'message', - comment: 'comment', - node: 'node', + message: "message", + comment: "comment", + node: "node" }; export type IMessageNotification = { - type: typeof NOTIFICATION_TYPES['message']; + type: typeof NOTIFICATION_TYPES["message"]; content: Partial; created_at: string; }; export type ICommentNotification = { - type: typeof NOTIFICATION_TYPES['comment']; + type: typeof NOTIFICATION_TYPES["comment"]; content: Partial; created_at: string; }; export type INodeNotification = { - type: typeof NOTIFICATION_TYPES['node']; + type: typeof NOTIFICATION_TYPES["node"]; content: Partial; created_at: string; }; diff --git a/src/redux/uploads/sagas.ts b/src/redux/uploads/sagas.ts index 94868079..c03474d3 100644 --- a/src/redux/uploads/sagas.ts +++ b/src/redux/uploads/sagas.ts @@ -1,37 +1,49 @@ -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 })); } @@ -47,10 +59,10 @@ function* uploadCancelWorker(id) { } function* uploadWorker({ file, temp_id, target, type }: IFileWithUUID) { - const [promise, chan] = createUploader, Partial>( - uploadCall, - { temp_id, target, type } - ); + const [promise, chan] = createUploader< + Partial, + Partial + >(uploadCall, { temp_id, target, type }); yield fork(onUploadProgress, chan); @@ -58,15 +70,26 @@ function* uploadWorker({ file, temp_id, target, type }: IFileWithUUID) { temp_id, file, target, - type, + type }); return result; } -function* uploadFile({ file, temp_id, type, target }: IFileWithUUID) { +function* uploadFile({ + file, + temp_id, + type, + target, + onSuccess, + onFail +}: IFileWithUUID) { if (!file.type || !file.type || !FILE_MIMES[type].includes(file.type)) { - return { error: 'File_Not_Image', status: HTTP_RESPONSES.BAD_REQUEST, data: {} }; + return { + error: "File_Not_Image", + status: HTTP_RESPONSES.BAD_REQUEST, + data: {} + }; } const preview = yield call(uploadGetThumb, file); @@ -81,7 +104,7 @@ function* uploadFile({ file, temp_id, type, target }: IFileWithUUID) { // type: file.type, temp_id, type, - name: file.name, + name: file.name } ) ); @@ -91,9 +114,9 @@ function* uploadFile({ file, temp_id, type, target }: IFileWithUUID) { file, temp_id, target, - type, + type }), - cancel: call(uploadCancelWorker, temp_id), + 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), @@ -101,14 +124,24 @@ function* uploadFile({ file, temp_id, type, target }: IFileWithUUID) { }); if (cancel || cancel_editing) { + if (onFail) onFail(); 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(); + return yield put( - uploadSetStatus(temp_id, { is_uploading: false, error: data.detail || error, type }) + uploadSetStatus(temp_id, { + is_uploading: false, + error: data.detail || error, + type + }) ); } @@ -121,12 +154,14 @@ function* uploadFile({ file, temp_id, type, target }: IFileWithUUID) { type, thumbnail_url: data.full_path, progress: 1, - name: file.name, + name: file.name }) ); yield put(uploadAddFile(data)); + if (onSuccess) onSuccess(data); + return { error: null, status: HTTP_RESPONSES.CREATED, data: {} }; // add file here as data }