mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
fixed ramda imports to reduce bundle size
This commit is contained in:
parent
a497912049
commit
097b091abd
47 changed files with 208 additions and 91 deletions
|
@ -1,8 +1,8 @@
|
|||
import axios, { AxiosError, AxiosResponse } from 'axios';
|
||||
import { assocPath } from 'ramda';
|
||||
|
||||
import { API } from '~/constants/api';
|
||||
import { getMOBXStore } from '~/store';
|
||||
import { assocPath } from '~/utils/ramda';
|
||||
|
||||
export const api = axios.create({
|
||||
baseURL: API.BASE,
|
||||
|
|
|
@ -4,7 +4,6 @@ import format from 'date-fns/format';
|
|||
import formatDistanceToNow from 'date-fns/formatDistanceToNow';
|
||||
import isAfter from 'date-fns/isAfter';
|
||||
import ru from 'date-fns/locale/ru';
|
||||
import { pipe } from 'ramda';
|
||||
|
||||
import { COMMENT_BLOCK_DETECTORS, COMMENT_BLOCK_TYPES, ICommentBlock } from '~/constants/comment';
|
||||
import { PRESETS } from '~/constants/urls';
|
||||
|
@ -20,6 +19,7 @@ import {
|
|||
formatTextSanitizeYoutube,
|
||||
formatTextTodos,
|
||||
} from '~/utils/formatText';
|
||||
import { pipe } from '~/utils/ramda';
|
||||
import { splitTextByYoutube, splitTextOmitEmpty } from '~/utils/splitText';
|
||||
|
||||
function polarToCartesian(centerX, centerY, radius, angleInDegrees) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { has, path } from 'ramda';
|
||||
|
||||
import { ERROR_LITERAL, ERRORS } from '~/constants/errors';
|
||||
import { has, path } from '~/utils/ramda';
|
||||
|
||||
export const getErrorMessage = (error: unknown): string | undefined => {
|
||||
if (error === undefined) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { hasPath, path } from 'ramda';
|
||||
import { hasPath, path } from '~/utils/ramda';
|
||||
|
||||
export const getValidationErrors = (error: unknown): Record<string, string> | undefined => {
|
||||
if (hasPath(['response', 'data', 'errors'], error)) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { isAfter, isValid, parseISO } from 'date-fns';
|
||||
import { curry, insert, nth, path, remove } from 'ramda';
|
||||
|
||||
import { IComment, ICommentGroup } from '~/types';
|
||||
import { curry, insert, nth, path, remove } from '~/utils/ramda';
|
||||
|
||||
export const moveArrItem = curry((at, to, list) => insert(to, nth(at, list), remove(at, 1, list)));
|
||||
export const objFromArray = (array: any[], key: string) =>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { path } from 'ramda';
|
||||
|
||||
import { Role } from '~/constants/auth';
|
||||
import { NODE_TYPES } from '~/constants/node';
|
||||
import { ICommentGroup, INode } from '~/types';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
export const canEditNode = (node?: Partial<INode>, user?: Partial<IUser>): boolean =>
|
||||
path(['role'], user) === Role.Admin || path(['user', 'id'], node) === path(['id'], user);
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
import React, { createContext, FC, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
import React, {
|
||||
createContext,
|
||||
FC,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
|
||||
import { PlayerState } from '~/constants/player';
|
||||
import { IFile } from '~/types';
|
||||
import { PlayerProgress } from '~/types/player';
|
||||
import { getURL } from '~/utils/dom';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
interface AudioPlayerProps {
|
||||
file?: IFile;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import React, { createContext, FC, useContext, useMemo } from 'react';
|
||||
|
||||
import { observer } from 'mobx-react-lite';
|
||||
import { uniq } from 'ramda';
|
||||
|
||||
import { useFlow } from '~/hooks/flow/useFlow';
|
||||
import { FlowDisplay, IFlowNode, INode } from '~/types';
|
||||
import { GetNodeDiffResult } from '~/types/node';
|
||||
import { uniq } from '~/utils/ramda';
|
||||
|
||||
export interface FlowProviderProps {
|
||||
fallbackData?: GetNodeDiffResult;
|
||||
|
|
24
src/utils/ramda.ts
Normal file
24
src/utils/ramda.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
export { default as has } from 'ramda/es/has';
|
||||
export { default as path } from 'ramda/es/path';
|
||||
export { default as append } from 'ramda/es/append';
|
||||
export { default as assocPath } from 'ramda/es/assocPath';
|
||||
export { default as reduce } from 'ramda/es/reduce';
|
||||
export { default as values } from 'ramda/es/values';
|
||||
export { default as range } from 'ramda/es/range';
|
||||
export { default as prop } from 'ramda/es/prop';
|
||||
export { default as includes } from 'ramda/es/includes';
|
||||
export { default as hasPath } from 'ramda/es/hasPath';
|
||||
export { default as isNil } from 'ramda/es/isNil';
|
||||
export { default as flatten } from 'ramda/es/flatten';
|
||||
export { default as keys } from 'ramda/es/keys';
|
||||
export { default as uniq } from 'ramda/es/uniq';
|
||||
export { default as last } from 'ramda/es/last';
|
||||
export { default as uniqBy } from 'ramda/es/uniqBy';
|
||||
export { default as omit } from 'ramda/es/omit';
|
||||
export { default as curry } from 'ramda/es/curry';
|
||||
export { default as pipe } from 'ramda/es/pipe';
|
||||
export { default as without } from 'ramda/es/without';
|
||||
export { default as nth } from 'ramda/es/nth';
|
||||
export { default as insert } from 'ramda/es/insert';
|
||||
export { default as isEmpty } from 'ramda/es/isEmpty';
|
||||
export { default as remove } from 'ramda/es/remove';
|
|
@ -1,4 +1,4 @@
|
|||
import { flatten, isEmpty } from 'ramda';
|
||||
import { flatten, isEmpty } from '~/utils/ramda';
|
||||
|
||||
export const splitTextByYoutube = (strings: string[]): string[] =>
|
||||
flatten(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue