mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +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,12 +1,11 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
import { includes, path, values } from 'ramda';
|
||||
|
||||
import { EventMessageType } from '~/constants/events';
|
||||
import { Dialog } from '~/constants/modal';
|
||||
import { useAuth } from '~/hooks/auth/useAuth';
|
||||
import { useOAuth } from '~/hooks/auth/useOAuth';
|
||||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { includes, path, values } from '~/utils/ramda';
|
||||
|
||||
/** reacts to events passed by window.postMessage */
|
||||
export const useMessageEventReactions = () => {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { path } from 'ramda';
|
||||
import useSWR from 'swr';
|
||||
|
||||
import { apiAttachSocial, apiDropSocial, apiGetSocials, apiLoginWithSocial } from '~/api/auth';
|
||||
|
@ -10,6 +9,7 @@ import { useAuth } from '~/hooks/auth/useAuth';
|
|||
import { useModal } from '~/hooks/modal/useModal';
|
||||
import { OAuthProvider } from '~/types/auth';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { path } from '~/utils/ramda';
|
||||
|
||||
export const useOAuth = () => {
|
||||
const { isUser, setToken } = useAuth();
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { useCallback, useEffect, useRef } from 'react';
|
||||
|
||||
import { FormikHelpers, useFormik, useFormikContext } from 'formik';
|
||||
import { hasPath, path } from 'ramda';
|
||||
import { array, object, string } from 'yup';
|
||||
|
||||
import { IComment, INode } from '~/types';
|
||||
import { Uploader } from '~/utils/context/UploaderContextProvider';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { hasPath, path } from '~/utils/ramda';
|
||||
|
||||
const validationSchema = object().shape({
|
||||
text: string(),
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { flatten, isNil } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { apiGetNodeComments } from '~/api/node';
|
||||
import { API } from '~/constants/api';
|
||||
import { COMMENTS_DISPLAY } from '~/constants/node';
|
||||
import { IComment } from '~/types';
|
||||
import { flatten, isNil } from '~/utils/ramda';
|
||||
|
||||
const getKey: (nodeId: number) => SWRInfiniteKeyLoader = (nodeId: number) => (
|
||||
pageIndex,
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import { useMemo } from 'react';
|
||||
|
||||
import { has } from 'ramda';
|
||||
|
||||
import { ERROR_LITERAL } from '~/constants/errors';
|
||||
import { has } from '~/utils/ramda';
|
||||
|
||||
export const useTranslatedError = (error: string | undefined) => {
|
||||
return useMemo(() => {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { useCallback } from 'react';
|
||||
|
||||
import { useLocalObservable } from 'mobx-react-lite';
|
||||
import { keys } from 'ramda';
|
||||
import uuid from 'uuid4';
|
||||
|
||||
import { apiUploadFile } from '~/api/uploads';
|
||||
|
@ -9,7 +8,7 @@ import { UploadSubject, UploadTarget } from '~/constants/uploads';
|
|||
import { UploaderStore } from '~/store/uploader/UploaderStore';
|
||||
import { IFile } from '~/types';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
|
||||
import { keys } from '~/utils/ramda';
|
||||
|
||||
export const useUploader = (
|
||||
subject: UploadSubject,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useCallback, useState } from 'react';
|
||||
|
||||
import { runInAction } from 'mobx';
|
||||
import { uniq } from 'ramda';
|
||||
|
||||
import { getNodeDiff } from '~/api/node';
|
||||
import { useFlowStore } from '~/store/flow/useFlowStore';
|
||||
import { showErrorToast } from '~/utils/errors/showToast';
|
||||
import { uniq } from '~/utils/ramda';
|
||||
|
||||
export const useFlowLoader = () => {
|
||||
const [isSyncing, setIsSyncing] = useState(false);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { flatten, last, uniqBy } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { getLabNodes } from '~/api/lab';
|
||||
|
@ -8,6 +7,7 @@ import { useAuth } from '~/hooks/auth/useAuth';
|
|||
import { useLabStore } from '~/store/lab/useLabStore';
|
||||
import { INode } from '~/types';
|
||||
import { GetLabNodesRequest, ILabNode } from '~/types/lab';
|
||||
import { flatten, last, uniqBy } from '~/utils/ramda';
|
||||
|
||||
const getKey: (isUser: boolean) => SWRInfiniteKeyLoader = isUser => (index, prev: ILabNode[]) => {
|
||||
if (!isUser) return null;
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
import { createElement, FC, useCallback, useMemo } from 'react';
|
||||
|
||||
import { isNil, prop } from 'ramda';
|
||||
|
||||
import { INodeComponentProps, LAB_PREVIEW_LAYOUT, NODE_COMPONENTS, NODE_HEADS, NODE_INLINES } from '~/constants/node';
|
||||
import {
|
||||
INodeComponentProps,
|
||||
LAB_PREVIEW_LAYOUT,
|
||||
NODE_COMPONENTS,
|
||||
NODE_HEADS,
|
||||
NODE_INLINES,
|
||||
} from '~/constants/node';
|
||||
import { INode } from '~/types';
|
||||
import { isNil, prop } from '~/utils/ramda';
|
||||
|
||||
// useNodeBlocks returns head, block and inline blocks of node
|
||||
export const useNodeBlocks = (node: INode, isLoading: boolean) => {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
|
||||
import { flatten } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { getSearchResults } from '~/api/flow';
|
||||
import { INode } from '~/types';
|
||||
import { GetSearchResultsRequest } from '~/types/flow';
|
||||
import { flatten } from '~/utils/ramda';
|
||||
|
||||
const RESULTS_COUNT = 20;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { useCallback, useMemo } from 'react';
|
||||
|
||||
import { flatten, isNil } from 'ramda';
|
||||
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
|
||||
|
||||
import { apiGetNodesOfTag } from '~/api/tags';
|
||||
import { API } from '~/constants/api';
|
||||
import { INode } from '~/types';
|
||||
import { flatten, isNil } from '~/utils/ramda';
|
||||
|
||||
const PAGE_SIZE = 10;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue