mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
eslint auto-fix
This commit is contained in:
parent
312156bdf8
commit
4c4461ea19
55 changed files with 107 additions and 110 deletions
|
@ -13,6 +13,18 @@ module.exports = {
|
||||||
eslint: {
|
eslint: {
|
||||||
enable: false,
|
enable: false,
|
||||||
mode: 'file',
|
mode: 'file',
|
||||||
|
rules: {
|
||||||
|
'sort-imports': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
ignoreCase: false,
|
||||||
|
ignoreDeclarationSort: false,
|
||||||
|
ignoreMemberSort: false,
|
||||||
|
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
|
||||||
|
allowSeparatedGroups: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
jest: {
|
jest: {
|
||||||
setupTestFrameworkScriptFile: '<rootDir>/src/setupTests.js',
|
setupTestFrameworkScriptFile: '<rootDir>/src/setupTests.js',
|
||||||
|
|
|
@ -20,7 +20,7 @@ const CommentFormFormatButtons: FC<IProps> = ({ element, handler }) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
wrapTextInsideInput(element, '**', '**', handler);
|
wrapTextInsideInput(element, '**', '**', handler);
|
||||||
},
|
},
|
||||||
[wrap, handler]
|
[element, handler]
|
||||||
);
|
);
|
||||||
|
|
||||||
const wrapItalic = useCallback(
|
const wrapItalic = useCallback(
|
||||||
|
@ -28,7 +28,7 @@ const CommentFormFormatButtons: FC<IProps> = ({ element, handler }) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
wrapTextInsideInput(element, '*', '*', handler);
|
wrapTextInsideInput(element, '*', '*', handler);
|
||||||
},
|
},
|
||||||
[wrap, handler]
|
[element, handler]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onKeyPress = useCallback(
|
const onKeyPress = useCallback(
|
||||||
|
|
|
@ -29,7 +29,7 @@ const InfiniteScroll: FC<IProps> = ({ children, hasMore, scrollReactPx, loadMore
|
||||||
observer.observe(ref.current);
|
observer.observe(ref.current);
|
||||||
|
|
||||||
return () => observer.disconnect();
|
return () => observer.disconnect();
|
||||||
}, [ref.current, onScrollEnd]);
|
}, [onScrollEnd]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div {...props}>
|
<div {...props}>
|
||||||
|
|
|
@ -34,7 +34,7 @@ const EditorUploadButton: FC<IProps> = ({
|
||||||
|
|
||||||
uploadFiles(files);
|
uploadFiles(files);
|
||||||
},
|
},
|
||||||
[uploadFiles]
|
[type, uploadFiles]
|
||||||
);
|
);
|
||||||
|
|
||||||
const color = values.is_promoted ? 'primary' : 'lab';
|
const color = values.is_promoted ? 'primary' : 'lab';
|
||||||
|
|
|
@ -21,7 +21,7 @@ const CellShade: FC<Props> = ({ color, size = 50, ...rest }) => {
|
||||||
|
|
||||||
return `linear-gradient(7deg, ${normalized} ${size}px, ${transparentize(normalized, 1)} ${size *
|
return `linear-gradient(7deg, ${normalized} ${size}px, ${transparentize(normalized, 1)} ${size *
|
||||||
5}px)`;
|
5}px)`;
|
||||||
}, [color]);
|
}, [color, size]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div {...rest} className={classNames(rest.className, styles.shade)} style={{ background }} />
|
<div {...rest} className={classNames(rest.className, styles.shade)} style={{ background }} />
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import React, { FC, useState, useCallback, useEffect, useRef, useMemo } from 'react';
|
import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { IFlowState } from '~/redux/flow/reducer';
|
import { IFlowState } from '~/redux/flow/reducer';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { getURL } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
import { withRouter, RouteComponentProps, useHistory } from 'react-router';
|
import { RouteComponentProps, useHistory, withRouter } from 'react-router';
|
||||||
import { URLS, PRESETS } from '~/constants/urls';
|
import { PRESETS, URLS } from '~/constants/urls';
|
||||||
import { Icon } from '~/components/input/Icon';
|
import { Icon } from '~/components/input/Icon';
|
||||||
import { INode } from '~/redux/types';
|
import { INode } from '~/redux/types';
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ const FlowHeroUnconnected: FC<IProps> = ({ heroes }) => {
|
||||||
|
|
||||||
const title = useMemo(() => {
|
const title = useMemo(() => {
|
||||||
return loaded[current]?.title || '';
|
return loaded[current]?.title || '';
|
||||||
}, [loaded, current, heroes]);
|
}, [loaded, current]);
|
||||||
|
|
||||||
const onNext = useCallback(() => {
|
const onNext = useCallback(() => {
|
||||||
if (heroes.length > limit) setLimit(limit + 1);
|
if (heroes.length > limit) setLimit(limit + 1);
|
||||||
|
@ -45,16 +45,16 @@ const FlowHeroUnconnected: FC<IProps> = ({ heroes }) => {
|
||||||
|
|
||||||
const goToNode = useCallback(() => {
|
const goToNode = useCallback(() => {
|
||||||
history.push(URLS.NODE_URL(loaded[current].id));
|
history.push(URLS.NODE_URL(loaded[current].id));
|
||||||
}, [current, loaded]);
|
}, [current, history, loaded]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
timer.current = setTimeout(onNext, 5000);
|
timer.current = setTimeout(onNext, 5000);
|
||||||
return () => clearTimeout(timer.current);
|
return () => clearTimeout(timer.current);
|
||||||
}, [current, timer.current]);
|
}, [current, onNext]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (loaded.length === 1) onNext();
|
if (loaded.length === 1) onNext();
|
||||||
}, [loaded]);
|
}, [loaded, onNext]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
|
|
|
@ -61,7 +61,7 @@ const FlowStamp: FC<IProps> = ({
|
||||||
) : (
|
) : (
|
||||||
<Icon icon="search" size={24} className={styles.search_icon} />
|
<Icon icon="search" size={24} className={styles.search_icon} />
|
||||||
),
|
),
|
||||||
[searchText]
|
[onClearSearch, searchText]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -48,7 +48,7 @@ const Button: FC<IButtonProps> = memo(
|
||||||
has_icon_right: !!iconRight,
|
has_icon_right: !!iconRight,
|
||||||
round,
|
round,
|
||||||
}),
|
}),
|
||||||
[round, disabled, className, stretchy, iconLeft, iconRight, size, color]
|
[className, size, color, disabled, stretchy, iconLeft, iconRight, title, children, iconOnly, round]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -20,7 +20,7 @@ type Props = {
|
||||||
|
|
||||||
const LabBottomPanel: FC<Props> = ({ node, hasNewComments, commentCount, isLoading }) => {
|
const LabBottomPanel: FC<Props> = ({ node, hasNewComments, commentCount, isLoading }) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const onClick = useCallback(() => history.push(URLS.NODE_URL(node.id)), [node.id]);
|
const onClick = useCallback(() => history.push(URLS.NODE_URL(node.id)), [history, node.id]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group horizontal className={styles.wrap} onClick={onClick}>
|
<Group horizontal className={styles.wrap} onClick={onClick}>
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { Paragraph } from '~/components/placeholders/Paragraph';
|
||||||
|
|
||||||
const LabText: FC<INodeComponentProps> = ({ node, isLoading }) => {
|
const LabText: FC<INodeComponentProps> = ({ node, isLoading }) => {
|
||||||
const content = useMemo(() => formatTextParagraphs(path(['blocks', 0, 'text'], node) || ''), [
|
const content = useMemo(() => formatTextParagraphs(path(['blocks', 0, 'text'], node) || ''), [
|
||||||
node.blocks,
|
node,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const onClick = useGotoNode(node.id);
|
const onClick = useGotoNode(node.id);
|
||||||
|
|
|
@ -62,7 +62,7 @@ const HeaderUnconnected: FC<IProps> = memo(
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onScroll();
|
onScroll();
|
||||||
}, []);
|
}, [onScroll]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.addEventListener('scroll', onScroll);
|
window.addEventListener('scroll', onScroll);
|
||||||
|
@ -74,7 +74,7 @@ const HeaderUnconnected: FC<IProps> = memo(
|
||||||
is_user &&
|
is_user &&
|
||||||
boris_commented_at &&
|
boris_commented_at &&
|
||||||
(!last_seen_boris || isBefore(new Date(last_seen_boris), new Date(boris_commented_at))),
|
(!last_seen_boris || isBefore(new Date(last_seen_boris), new Date(boris_commented_at))),
|
||||||
[boris_commented_at, last_seen_boris]
|
[boris_commented_at, is_user, last_seen_boris]
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasLabUpdates = useMemo(() => labUpdates.length > 0, [labUpdates]);
|
const hasLabUpdates = useMemo(() => labUpdates.length > 0, [labUpdates]);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { FC, useMemo, useState, useCallback, useEffect } from 'react';
|
import React, { FC, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { Icon } from '~/components/input/Icon';
|
import { Icon } from '~/components/input/Icon';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
@ -7,7 +7,7 @@ import { pick } from 'ramda';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import * as AUTH_ACTIONS from '~/redux/auth/actions';
|
import * as AUTH_ACTIONS from '~/redux/auth/actions';
|
||||||
import { NotificationBubble } from '../../notifications/NotificationBubble';
|
import { NotificationBubble } from '../../notifications/NotificationBubble';
|
||||||
import { INotification, IMessageNotification } from '~/redux/types';
|
import { IMessageNotification, INotification } from '~/redux/types';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
user: pick(['last_seen_messages'], selectAuthUser(state)),
|
user: pick(['last_seen_messages'], selectAuthUser(state)),
|
||||||
|
@ -62,7 +62,7 @@ const NotificationsUnconnected: FC<IProps> = ({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!visible || !has_new || !last) return;
|
if (!visible || !has_new || !last) return;
|
||||||
authSetLastSeenMessages(last);
|
authSetLastSeenMessages(last);
|
||||||
}, [visible, last]);
|
}, [visible, last, has_new, authSetLastSeenMessages]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import React, { useCallback, useState, useEffect, memo, useMemo } from 'react';
|
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectPlayer } from '~/redux/player/selectors';
|
import { selectPlayer } from '~/redux/player/selectors';
|
||||||
import * as PLAYER_ACTIONS from '~/redux/player/actions';
|
import * as PLAYER_ACTIONS from '~/redux/player/actions';
|
||||||
import { IFile } from '~/redux/types';
|
import { IFile } from '~/redux/types';
|
||||||
import { PLAYER_STATES } from '~/redux/player/constants';
|
import { PLAYER_STATES } from '~/redux/player/constants';
|
||||||
import { Player, IPlayerProgress } from '~/utils/player';
|
import { IPlayerProgress, Player } from '~/utils/player';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { Icon } from '~/components/input/Icon';
|
import { Icon } from '~/components/input/Icon';
|
||||||
|
@ -90,7 +90,7 @@ const AudioPlayerUnconnected = memo(
|
||||||
[file.metadata.id3artist, file.metadata.id3title].filter(el => el).join(' - '))) ||
|
[file.metadata.id3artist, file.metadata.id3title].filter(el => el).join(' - '))) ||
|
||||||
file.orig_name ||
|
file.orig_name ||
|
||||||
'',
|
'',
|
||||||
[file.metadata]
|
[file.metadata, file.orig_name]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onRename = useCallback(
|
const onRename = useCallback(
|
||||||
|
|
|
@ -44,7 +44,7 @@ const ImagePreloader: FC<IProps> = ({ file, color, onLoad, onClick, className })
|
||||||
|
|
||||||
const [width, height] = useMemo(
|
const [width, height] = useMemo(
|
||||||
() => [file?.metadata?.width || DEFAULT_WIDTH, file?.metadata?.height || DEFAULT_HEIGHT],
|
() => [file?.metadata?.width || DEFAULT_WIDTH, file?.metadata?.height || DEFAULT_HEIGHT],
|
||||||
[file?.metadata]
|
[file]
|
||||||
);
|
);
|
||||||
|
|
||||||
useResizeHandler(onResize);
|
useResizeHandler(onResize);
|
||||||
|
|
|
@ -9,7 +9,7 @@ interface IProps {
|
||||||
}
|
}
|
||||||
|
|
||||||
const CommendDeleted: FC<IProps> = ({ id, onDelete }) => {
|
const CommendDeleted: FC<IProps> = ({ id, onDelete }) => {
|
||||||
const onRestore = useCallback(() => onDelete(id, false), [onDelete]);
|
const onRestore = useCallback(() => onDelete(id, false), [id, onDelete]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
|
|
|
@ -10,7 +10,7 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
const NodeAuthorBlock: FC<Props> = ({ user }) => {
|
const NodeAuthorBlock: FC<Props> = ({ user }) => {
|
||||||
const onOpenProfile = useCallback(() => openUserProfile(user?.username), [user?.username]);
|
const onOpenProfile = useCallback(() => openUserProfile(user?.username), [user]);
|
||||||
|
|
||||||
const description = useUserDescription(user);
|
const description = useUserDescription(user);
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,8 @@ import classNames from 'classnames';
|
||||||
import { INode } from '~/redux/types';
|
import { INode } from '~/redux/types';
|
||||||
import { PRESETS, URLS } from '~/constants/urls';
|
import { PRESETS, URLS } from '~/constants/urls';
|
||||||
import { RouteComponentProps, withRouter } from 'react-router';
|
import { RouteComponentProps, withRouter } from 'react-router';
|
||||||
import { getURL, stringToColour } from '~/utils/dom';
|
import { getURL } from '~/utils/dom';
|
||||||
import { Avatar } from '~/components/common/Avatar';
|
import { Avatar } from '~/components/common/Avatar';
|
||||||
import { normalizeBrightColor } from '~/utils/color';
|
|
||||||
import { adjustHue } from 'color2k';
|
|
||||||
import { useColorGradientFromString } from '~/utils/hooks/useColorGradientFromString';
|
import { useColorGradientFromString } from '~/utils/hooks/useColorGradientFromString';
|
||||||
|
|
||||||
type IProps = RouteComponentProps & {
|
type IProps = RouteComponentProps & {
|
||||||
|
@ -53,7 +51,7 @@ const NodeRelatedItemUnconnected: FC<IProps> = memo(({ item, history }) => {
|
||||||
cb();
|
cb();
|
||||||
|
|
||||||
return () => window.removeEventListener('resize', cb);
|
return () => window.removeEventListener('resize', cb);
|
||||||
}, [ref.current]);
|
}, []);
|
||||||
|
|
||||||
const size = useMemo<CellSize>(() => {
|
const size = useMemo<CellSize>(() => {
|
||||||
if (width > 90) return 'large';
|
if (width > 90) return 'large';
|
||||||
|
|
|
@ -9,9 +9,7 @@ import markdown from '~/styles/common/markdown.module.scss';
|
||||||
interface IProps extends INodeComponentProps {}
|
interface IProps extends INodeComponentProps {}
|
||||||
|
|
||||||
const NodeTextBlock: FC<IProps> = ({ node }) => {
|
const NodeTextBlock: FC<IProps> = ({ node }) => {
|
||||||
const content = useMemo(() => formatTextParagraphs(path(['blocks', 0, 'text'], node) || ''), [
|
const content = useMemo(() => formatTextParagraphs(path(['blocks', 0, 'text'], node) || ''), [node]);
|
||||||
node.blocks,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { Button } from '~/components/input/Button';
|
||||||
import { Group } from '~/components/containers/Group';
|
import { Group } from '~/components/containers/Group';
|
||||||
import { Filler } from '~/components/containers/Filler';
|
import { Filler } from '~/components/containers/Filler';
|
||||||
import { InputText } from '~/components/input/InputText';
|
import { InputText } from '~/components/input/InputText';
|
||||||
import { reject } from 'ramda';
|
|
||||||
import * as AUTH_ACTIONS from '~/redux/auth/actions';
|
import * as AUTH_ACTIONS from '~/redux/auth/actions';
|
||||||
import { ERROR_LITERAL } from '~/constants/errors';
|
import { ERROR_LITERAL } from '~/constants/errors';
|
||||||
import { ProfileAccounts } from '~/components/profile/ProfileAccounts';
|
import { ProfileAccounts } from '~/components/profile/ProfileAccounts';
|
||||||
|
@ -61,7 +60,7 @@ const ProfileSettingsUnconnected: FC<IProps> = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
authSetProfile({ patch_errors: {} });
|
authSetProfile({ patch_errors: {} });
|
||||||
}, [password, new_password, data]);
|
}, [password, new_password, data, authSetProfile]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className={styles.wrap} onSubmit={onSubmit}>
|
<form className={styles.wrap} onSubmit={onSubmit}>
|
||||||
|
|
|
@ -83,7 +83,7 @@ const TagAutocompleteUnconnected: FC<Props> = ({
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelected(-1);
|
setSelected(-1);
|
||||||
tagLoadAutocomplete(search, exclude);
|
tagLoadAutocomplete(search, exclude);
|
||||||
}, [search]);
|
}, [exclude, search, tagLoadAutocomplete]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
tagSetAutocomplete({ options: [] });
|
tagSetAutocomplete({ options: [] });
|
||||||
|
@ -102,7 +102,7 @@ const TagAutocompleteUnconnected: FC<Props> = ({
|
||||||
if (clientHeight - scrollTop + el.clientHeight < offsetTop || offsetTop < scrollTop) {
|
if (clientHeight - scrollTop + el.clientHeight < offsetTop || offsetTop < scrollTop) {
|
||||||
scroll.current.scrollTo(0, el.offsetTop - el.clientHeight);
|
scroll.current.scrollTo(0, el.offsetTop - el.clientHeight);
|
||||||
}
|
}
|
||||||
}, [selected, scroll.current]);
|
}, [selected]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -45,7 +45,7 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
|
|
||||||
setInput(items[items.length - 1] || '');
|
setInput(items[items.length - 1] || '');
|
||||||
},
|
},
|
||||||
[setInput]
|
[onAppend]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onKeyDown = useCallback(
|
const onKeyDown = useCallback(
|
||||||
|
@ -71,7 +71,7 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
setInput('');
|
setInput('');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[input, setInput, onClearTag, onAppend, onSubmit, ref.current, wrapper.current]
|
[input, setInput, onClearTag, onAppend]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onFocus = useCallback(() => setFocused(true), []);
|
const onFocus = useCallback(() => setFocused(true), []);
|
||||||
|
@ -94,7 +94,7 @@ const TagInput: FC<IProps> = ({ exclude, onAppend, onClearTag, onSubmit }) => {
|
||||||
|
|
||||||
onSubmit([]);
|
onSubmit([]);
|
||||||
},
|
},
|
||||||
[input, onAppend, setInput, onSubmit]
|
[input, setInput, onSubmit]
|
||||||
);
|
);
|
||||||
|
|
||||||
const onAutocompleteSelect = useCallback(
|
const onAutocompleteSelect = useCallback(
|
||||||
|
|
|
@ -43,12 +43,12 @@ export const Tags: FC<IProps> = ({
|
||||||
|
|
||||||
onTagsChange(uniqueTags);
|
onTagsChange(uniqueTags);
|
||||||
},
|
},
|
||||||
[data]
|
[data, onTagsChange, tags]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setData(data.filter(title => !tags.some(tag => tag?.title?.trim() === title.trim())));
|
setData(data.filter(title => !tags.some(tag => tag?.title?.trim() === title.trim())));
|
||||||
}, [tags]);
|
}, [data, tags]);
|
||||||
|
|
||||||
const onAppendTag = useCallback(
|
const onAppendTag = useCallback(
|
||||||
(created: string[]) => {
|
(created: string[]) => {
|
||||||
|
|
|
@ -19,7 +19,7 @@ const UploadDropzone: FC<IProps> = ({ children, onUpload, helperClassName, ...re
|
||||||
onStopDragging();
|
onStopDragging();
|
||||||
onUpload(files);
|
onUpload(files);
|
||||||
},
|
},
|
||||||
[onUpload]
|
[onStopDragging, onUpload]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -64,4 +64,4 @@ export const PHRASES = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useRandomPhrase = (key: keyof typeof PHRASES) =>
|
export const useRandomPhrase = (key: keyof typeof PHRASES) =>
|
||||||
useMemo(() => PHRASES[key][Math.floor(Math.random() * PHRASES[key].length)], []);
|
useMemo(() => PHRASES[key][Math.floor(Math.random() * PHRASES[key].length)], [key]);
|
||||||
|
|
|
@ -15,7 +15,6 @@ import { ModalWrapper } from '~/components/dialogs/ModalWrapper';
|
||||||
import { useTranslatedError } from '~/utils/hooks/useTranslatedError';
|
import { useTranslatedError } from '~/utils/hooks/useTranslatedError';
|
||||||
import { useCloseOnEscape } from '~/utils/hooks';
|
import { useCloseOnEscape } from '~/utils/hooks';
|
||||||
import { EditorConfirmClose } from '~/components/editors/EditorConfirmClose';
|
import { EditorConfirmClose } from '~/components/editors/EditorConfirmClose';
|
||||||
import { UploadDropzone } from '~/components/upload/UploadDropzone';
|
|
||||||
|
|
||||||
interface Props extends IDialogProps {
|
interface Props extends IDialogProps {
|
||||||
node: INode;
|
node: INode;
|
||||||
|
@ -46,7 +45,7 @@ const EditorDialog: FC<Props> = ({ node, onRequestClose }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
setConfirmModalShown(true);
|
setConfirmModalShown(true);
|
||||||
}, [onRequestClose, dirty, isConfirmModalShown, setConfirmModalShown]);
|
}, [dirty, isConfirmModalShown, onRequestClose, closeConfirmModal]);
|
||||||
|
|
||||||
const error = useTranslatedError(status);
|
const error = useTranslatedError(status);
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ const EditorDialog: FC<Props> = ({ node, onRequestClose }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
setStatus('');
|
setStatus('');
|
||||||
}, [values]);
|
}, [setStatus, status, values]);
|
||||||
|
|
||||||
useCloseOnEscape(onClose);
|
useCloseOnEscape(onClose);
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { FC, FormEvent, useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { FC, FormEvent, useCallback, useEffect, useState } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { DIALOGS, IDialogProps } from '~/redux/modal/constants';
|
import { DIALOGS, IDialogProps } from '~/redux/modal/constants';
|
||||||
import { useCloseOnEscape } from '~/utils/hooks';
|
import { useCloseOnEscape } from '~/utils/hooks';
|
||||||
|
@ -18,7 +18,6 @@ import { pick } from 'ramda';
|
||||||
import { LoginDialogButtons } from '~/containers/dialogs/LoginDialogButtons';
|
import { LoginDialogButtons } from '~/containers/dialogs/LoginDialogButtons';
|
||||||
import { OAUTH_EVENT_TYPES } from '~/redux/types';
|
import { OAUTH_EVENT_TYPES } from '~/redux/types';
|
||||||
import { DialogTitle } from '~/components/dialogs/DialogTitle';
|
import { DialogTitle } from '~/components/dialogs/DialogTitle';
|
||||||
import { ERROR_LITERAL } from '~/constants/errors';
|
|
||||||
import { useTranslatedError } from '~/utils/hooks/useTranslatedError';
|
import { useTranslatedError } from '~/utils/hooks/useTranslatedError';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
|
@ -60,7 +59,7 @@ const LoginDialogUnconnected: FC<IProps> = ({
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
modalShowDialog(DIALOGS.RESTORE_REQUEST);
|
modalShowDialog(DIALOGS.RESTORE_REQUEST);
|
||||||
},
|
},
|
||||||
[modalShowDialog, userSetLoginError]
|
[modalShowDialog]
|
||||||
);
|
);
|
||||||
|
|
||||||
const openOauthWindow = useCallback(
|
const openOauthWindow = useCallback(
|
||||||
|
@ -83,7 +82,7 @@ const LoginDialogUnconnected: FC<IProps> = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error) userSetLoginError('');
|
if (error) userSetLoginError('');
|
||||||
}, [username, password]);
|
}, [username, password, error, userSetLoginError]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.addEventListener('message', onMessage);
|
window.addEventListener('message', onMessage);
|
||||||
|
|
|
@ -51,15 +51,15 @@ const LoginSocialRegisterDialogUnconnected: FC<Props> = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (errors.username) authSetRegisterSocialErrors({ username: '' });
|
if (errors.username) authSetRegisterSocialErrors({ username: '' });
|
||||||
}, [username]);
|
}, [authSetRegisterSocialErrors, errors.username, username]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (errors.password) authSetRegisterSocialErrors({ password: '' });
|
if (errors.password) authSetRegisterSocialErrors({ password: '' });
|
||||||
}, [password]);
|
}, [authSetRegisterSocialErrors, errors.password, password]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error) authSetRegisterSocial({ error: '' });
|
if (error) authSetRegisterSocial({ error: '' });
|
||||||
}, [username, password]);
|
}, [username, password, error, authSetRegisterSocial]);
|
||||||
|
|
||||||
useCloseOnEscape(onRequestClose);
|
useCloseOnEscape(onRequestClose);
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ const PhotoSwipeUnconnected: FC<Props> = ({ photoswipe, modalSetShown }) => {
|
||||||
ps.listen('destroy', closeModal);
|
ps.listen('destroy', closeModal);
|
||||||
ps.listen('close', closeModal);
|
ps.listen('close', closeModal);
|
||||||
});
|
});
|
||||||
}, [photoswipe.images, photoswipe.index]);
|
}, [closeModal, photoswipe.images, photoswipe.index]);
|
||||||
|
|
||||||
useBlockBackButton(closeModal);
|
useBlockBackButton(closeModal);
|
||||||
|
|
||||||
|
|
|
@ -44,14 +44,14 @@ const RestorePasswordDialogUnconnected: FC<IProps> = ({
|
||||||
|
|
||||||
authRestorePassword(password);
|
authRestorePassword(password);
|
||||||
},
|
},
|
||||||
[doesnt_match, authRestorePassword]
|
[doesnt_match, authRestorePassword, password]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (error || is_succesfull) {
|
if (error || is_succesfull) {
|
||||||
authSetRestore({ error: '', is_succesfull: false });
|
authSetRestore({ error: '', is_succesfull: false });
|
||||||
}
|
}
|
||||||
}, [password, password_again]);
|
}, [authSetRestore, error, is_succesfull, password, password_again]);
|
||||||
|
|
||||||
const buttons = useMemo(
|
const buttons = useMemo(
|
||||||
() => (
|
() => (
|
||||||
|
@ -80,7 +80,7 @@ const RestorePasswordDialogUnconnected: FC<IProps> = ({
|
||||||
) : (
|
) : (
|
||||||
undefined
|
undefined
|
||||||
),
|
),
|
||||||
[is_succesfull]
|
[is_succesfull, onRequestClose, user]
|
||||||
);
|
);
|
||||||
|
|
||||||
const not_ready = useMemo(
|
const not_ready = useMemo(
|
||||||
|
@ -105,7 +105,7 @@ const RestorePasswordDialogUnconnected: FC<IProps> = ({
|
||||||
) : (
|
) : (
|
||||||
undefined
|
undefined
|
||||||
),
|
),
|
||||||
[is_loading, user, error]
|
[is_loading, user, error, onRequestClose]
|
||||||
);
|
);
|
||||||
|
|
||||||
useCloseOnEscape(onRequestClose);
|
useCloseOnEscape(onRequestClose);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { FC, useState, useMemo, useCallback, useEffect } from 'react';
|
import React, { FC, useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import { IDialogProps } from '~/redux/types';
|
import { IDialogProps } from '~/redux/types';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { BetterScrollDialog } from '../BetterScrollDialog';
|
import { BetterScrollDialog } from '../BetterScrollDialog';
|
||||||
|
@ -45,7 +45,7 @@ const RestoreRequestDialogUnconnected: FC<IProps> = ({
|
||||||
if (error || is_succesfull) {
|
if (error || is_succesfull) {
|
||||||
authSetRestore({ error: '', is_succesfull: false });
|
authSetRestore({ error: '', is_succesfull: false });
|
||||||
}
|
}
|
||||||
}, [field]);
|
}, [authSetRestore, error, field, is_succesfull]);
|
||||||
|
|
||||||
const buttons = useMemo(
|
const buttons = useMemo(
|
||||||
() => (
|
() => (
|
||||||
|
@ -75,7 +75,7 @@ const RestoreRequestDialogUnconnected: FC<IProps> = ({
|
||||||
) : (
|
) : (
|
||||||
undefined
|
undefined
|
||||||
),
|
),
|
||||||
[is_succesfull]
|
[is_succesfull, onRequestClose]
|
||||||
);
|
);
|
||||||
|
|
||||||
useCloseOnEscape(onRequestClose);
|
useCloseOnEscape(onRequestClose);
|
||||||
|
|
|
@ -31,10 +31,7 @@ const LoadingNode = () => (
|
||||||
);
|
);
|
||||||
|
|
||||||
const LabGrid: FC<IProps> = ({ isLoading, nodes, onLoadMore }) => {
|
const LabGrid: FC<IProps> = ({ isLoading, nodes, onLoadMore }) => {
|
||||||
const columns = useMemo(() => Array.from(document.querySelectorAll(`.${styles.column}`)), [
|
const columns = useMemo(() => Array.from(document.querySelectorAll(`.${styles.column}`)), []);
|
||||||
isLoading,
|
|
||||||
nodes,
|
|
||||||
]);
|
|
||||||
|
|
||||||
useLabPagination(isLoading, columns, onLoadMore);
|
useLabPagination(isLoading, columns, onLoadMore);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ const ProfileLayoutUnconnected: FC<IProps> = ({ history, nodeSetCoverImage }) =>
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user) setUser(undefined);
|
if (user) setUser(undefined);
|
||||||
}, [username]);
|
}, [user, username]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user && user.id && user.cover) {
|
if (user && user.id && user.cover) {
|
||||||
|
@ -33,7 +33,7 @@ const ProfileLayoutUnconnected: FC<IProps> = ({ history, nodeSetCoverImage }) =>
|
||||||
nodeSetCoverImage(undefined);
|
nodeSetCoverImage(undefined);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [user]);
|
}, [nodeSetCoverImage, user]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group className={styles.wrap} horizontal>
|
<Group className={styles.wrap} horizontal>
|
||||||
|
|
|
@ -47,7 +47,7 @@ const ProfileMessagesUnconnected: FC<IProps> = ({
|
||||||
if (profile.is_loading || !profile.user || !profile.user.username) return;
|
if (profile.is_loading || !profile.user || !profile.user.username) return;
|
||||||
|
|
||||||
messagesGetMessages(profile.user.username);
|
messagesGetMessages(profile.user.username);
|
||||||
}, [profile.user]);
|
}, [messagesGetMessages, profile.is_loading, profile.user]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const timer = setInterval(messagesRefreshMessages, 20000);
|
const timer = setInterval(messagesRefreshMessages, 20000);
|
||||||
|
@ -73,7 +73,7 @@ const ProfileMessagesUnconnected: FC<IProps> = ({
|
||||||
if (wasAtBottom.current) {
|
if (wasAtBottom.current) {
|
||||||
parent.scrollTo(0, parent.scrollHeight);
|
parent.scrollTo(0, parent.scrollHeight);
|
||||||
}
|
}
|
||||||
}, [messages.messages]);
|
}, [messages.messages, wrap]);
|
||||||
|
|
||||||
const onScroll = useCallback(() => {
|
const onScroll = useCallback(() => {
|
||||||
const parent = wrap?.parentElement;
|
const parent = wrap?.parentElement;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { FC, useCallback, useEffect, useState } from 'react';
|
import React, { FC, useCallback, useEffect } from 'react';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { SidebarWrapper } from '~/containers/sidebars/SidebarWrapper';
|
import { SidebarWrapper } from '~/containers/sidebars/SidebarWrapper';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
@ -37,11 +37,11 @@ const ProfileSidebarUnconnected: FC<Props> = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
authLoadProfile(username);
|
authLoadProfile(username);
|
||||||
}, [username]);
|
}, [authLoadProfile, username]);
|
||||||
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const basePath = url.replace(new RegExp(`\/~${username}$`), '');
|
const basePath = url.replace(new RegExp(`\/~${username}$`), '');
|
||||||
const onClose = useCallback(() => history.push(basePath), [basePath]);
|
const onClose = useCallback(() => history.push(basePath), [basePath, history]);
|
||||||
|
|
||||||
useCloseOnEscape(onClose);
|
useCloseOnEscape(onClose);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { FC, useEffect, useRef } from 'react';
|
import React, { FC, useEffect, useRef } from 'react';
|
||||||
import styles from './styles.module.scss';
|
import styles from './styles.module.scss';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock';
|
import { clearAllBodyScrollLocks, disableBodyScroll } from 'body-scroll-lock';
|
||||||
import { useCloseOnEscape } from '~/utils/hooks';
|
import { useCloseOnEscape } from '~/utils/hooks';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
@ -18,7 +18,7 @@ const SidebarWrapper: FC<IProps> = ({ children, onClose }) => {
|
||||||
disableBodyScroll(ref.current, { reserveScrollBarGap: true });
|
disableBodyScroll(ref.current, { reserveScrollBarGap: true });
|
||||||
|
|
||||||
return () => clearAllBodyScrollLocks();
|
return () => clearAllBodyScrollLocks();
|
||||||
}, [ref.current]);
|
}, []);
|
||||||
|
|
||||||
return createPortal(
|
return createPortal(
|
||||||
<div className={styles.wrapper} ref={ref}>
|
<div className={styles.wrapper} ref={ref}>
|
||||||
|
|
|
@ -31,7 +31,7 @@ const TagSidebarUnconnected: FC<Props> = ({ nodes, tagLoadNodes, tagSetNodes })
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const basePath = url.replace(new RegExp(`\/tag\/${tag}$`), '');
|
const basePath = url.replace(new RegExp(`\/tag\/${tag}$`), '');
|
||||||
const onClose = useCallback(() => history.push(basePath), [basePath]);
|
const onClose = useCallback(() => history.push(basePath), [basePath, history]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
tagLoadNodes(tag);
|
tagLoadNodes(tag);
|
||||||
|
@ -39,7 +39,7 @@ const TagSidebarUnconnected: FC<Props> = ({ nodes, tagLoadNodes, tagSetNodes })
|
||||||
return () => {
|
return () => {
|
||||||
tagSetNodes({ list: [], count: 0 });
|
tagSetNodes({ list: [], count: 0 });
|
||||||
};
|
};
|
||||||
}, [tag]);
|
}, [tag, tagLoadNodes, tagSetNodes]);
|
||||||
|
|
||||||
const loadMore = useCallback(() => {
|
const loadMore = useCallback(() => {
|
||||||
if (nodes.isLoading) return;
|
if (nodes.isLoading) return;
|
||||||
|
|
|
@ -27,7 +27,7 @@ const ProfileLayout: FC<Props> = ({
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(authLoadProfile(username));
|
dispatch(authLoadProfile(username));
|
||||||
}, [username]);
|
}, [dispatch, username]);
|
||||||
|
|
||||||
const profile = useShallowSelect(selectAuthProfile);
|
const profile = useShallowSelect(selectAuthProfile);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ const BorisPage: VFC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (node.is_loading) return;
|
if (node.is_loading) return;
|
||||||
dispatch(nodeLoadNode(696, 'DESC'));
|
dispatch(nodeLoadNode(696, 'DESC'));
|
||||||
}, [dispatch]);
|
}, [dispatch, node.is_loading]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CommentProvider
|
<CommentProvider
|
||||||
|
|
|
@ -20,7 +20,7 @@ export const useFlow = () => {
|
||||||
|
|
||||||
const onChangeCellView = useCallback(
|
const onChangeCellView = useCallback(
|
||||||
(id: INode['id'], val: FlowDisplay) => dispatch(flowSetCellView(id, val)),
|
(id: INode['id'], val: FlowDisplay) => dispatch(flowSetCellView(id, val)),
|
||||||
[]
|
[dispatch]
|
||||||
);
|
);
|
||||||
|
|
||||||
return { nodes, heroes, recent, updates, isFluid, toggleLayout, onChangeCellView };
|
return { nodes, heroes, recent, updates, isFluid, toggleLayout, onChangeCellView };
|
||||||
|
|
|
@ -9,7 +9,7 @@ export const useFlowCellControls = (
|
||||||
) => {
|
) => {
|
||||||
const onChange = useCallback(
|
const onChange = useCallback(
|
||||||
(value: Partial<FlowDisplay>) => onChangeCellView(id, { ...flow, ...value }),
|
(value: Partial<FlowDisplay>) => onChangeCellView(id, { ...flow, ...value }),
|
||||||
[flow, onChangeCellView]
|
[flow, id, onChangeCellView]
|
||||||
);
|
);
|
||||||
|
|
||||||
const hasDescription = !!description && description.length > 32;
|
const hasDescription = !!description && description.length > 32;
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { flowGetMore } from '~/redux/flow/actions';
|
import { flowGetMore } from '~/redux/flow/actions';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { useInfiniteLoader } from '~/utils/hooks/useInfiniteLoader';
|
import { useInfiniteLoader } from '~/utils/hooks/useInfiniteLoader';
|
||||||
|
|
||||||
export const useFlowPagination = ({ isLoading }) => {
|
export const useFlowPagination = ({ isLoading }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const loadMore = useCallback(() => dispatch(flowGetMore()), []);
|
const loadMore = useCallback(() => dispatch(flowGetMore()), [dispatch]);
|
||||||
useInfiniteLoader(loadMore, isLoading);
|
useInfiniteLoader(loadMore, isLoading);
|
||||||
};
|
};
|
||||||
|
|
|
@ -53,6 +53,6 @@ export const useFileDropZone = (onUpload: (file: File[]) => void, allowedTypes?:
|
||||||
|
|
||||||
onUpload(files);
|
onUpload(files);
|
||||||
},
|
},
|
||||||
[onUpload]
|
[allowedTypes, onUpload]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -40,5 +40,5 @@ export const useLabPagination = (
|
||||||
return () => {
|
return () => {
|
||||||
lastItems.forEach(item => observer.unobserve(item));
|
lastItems.forEach(item => observer.unobserve(item));
|
||||||
};
|
};
|
||||||
}, [observer, columns]);
|
}, [observer, columns, isLoading]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,5 +6,5 @@ import { URLS } from '~/constants/urls';
|
||||||
// useGotoNode returns fn, that navigates to node
|
// useGotoNode returns fn, that navigates to node
|
||||||
export const useGotoNode = (id: INode['id']) => {
|
export const useGotoNode = (id: INode['id']) => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
return useCallback(() => history.push(URLS.NODE_URL(id)), [id]);
|
return useCallback(() => history.push(URLS.NODE_URL(id)), [history, id]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,5 +13,5 @@ export const useGrouppedComments = (
|
||||||
groupCommentsByUser(lastSeen),
|
groupCommentsByUser(lastSeen),
|
||||||
[]
|
[]
|
||||||
),
|
),
|
||||||
[comments, order]
|
[comments, lastSeen, order]
|
||||||
);
|
);
|
||||||
|
|
|
@ -14,5 +14,5 @@ export const useLoadNode = (id: any, isLoading: boolean) => {
|
||||||
return () => {
|
return () => {
|
||||||
dispatch(nodeSetCurrent(EMPTY_NODE));
|
dispatch(nodeSetCurrent(EMPTY_NODE));
|
||||||
};
|
};
|
||||||
}, [dispatch, id]);
|
}, [dispatch, id, isLoading]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,14 +6,10 @@ import { nodeEdit, nodeLike, nodeLock, nodeStar } from '~/redux/node/actions';
|
||||||
export const useNodeActions = (node: INode) => {
|
export const useNodeActions = (node: INode) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const onEdit = useCallback(() => dispatch(nodeEdit(node.id)), [dispatch, nodeEdit, node]);
|
const onEdit = useCallback(() => dispatch(nodeEdit(node.id)), [dispatch, node]);
|
||||||
const onLike = useCallback(() => dispatch(nodeLike(node.id)), [dispatch, nodeLike, node]);
|
const onLike = useCallback(() => dispatch(nodeLike(node.id)), [dispatch, node]);
|
||||||
const onStar = useCallback(() => dispatch(nodeStar(node.id)), [dispatch, nodeStar, node]);
|
const onStar = useCallback(() => dispatch(nodeStar(node.id)), [dispatch, node]);
|
||||||
const onLock = useCallback(() => dispatch(nodeLock(node.id, !node.deleted_at)), [
|
const onLock = useCallback(() => dispatch(nodeLock(node.id, !node.deleted_at)), [dispatch, node]);
|
||||||
dispatch,
|
|
||||||
nodeLock,
|
|
||||||
node,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return { onEdit, onLike, onStar, onLock };
|
return { onEdit, onLike, onStar, onLock };
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,6 @@ export const useBlockBackButton = (callback?: () => void) => {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
[callback, history]
|
[callback]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const useClickOutsideFocus = () => {
|
||||||
document.addEventListener('mouseup', deactivator);
|
document.addEventListener('mouseup', deactivator);
|
||||||
|
|
||||||
return () => document.removeEventListener('mouseup', deactivator);
|
return () => document.removeEventListener('mouseup', deactivator);
|
||||||
}, [isActive]);
|
}, [deactivate, isActive]);
|
||||||
|
|
||||||
useCloseOnEscape(deactivate);
|
useCloseOnEscape(deactivate);
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,6 @@ import { stringToColour } from '~/utils/dom';
|
||||||
export const useColorFromString = (val?: string, saturation = 3, lightness = 3) => {
|
export const useColorFromString = (val?: string, saturation = 3, lightness = 3) => {
|
||||||
return useMemo(
|
return useMemo(
|
||||||
() => (val && normalizeBrightColor(stringToColour(val), saturation, lightness)) || '',
|
() => (val && normalizeBrightColor(stringToColour(val), saturation, lightness)) || '',
|
||||||
[]
|
[lightness, saturation, val]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,4 +19,4 @@ export const useColorGradientFromString = (
|
||||||
const third = normalizeBrightColor(adjustHue(color, 90), saturation, lightness);
|
const third = normalizeBrightColor(adjustHue(color, 90), saturation, lightness);
|
||||||
|
|
||||||
return `linear-gradient(${angle}deg, ${color}, ${second}, ${third})`;
|
return `linear-gradient(${angle}deg, ${color}, ${second}, ${third})`;
|
||||||
}, [val]);
|
}, [angle, lightness, saturation, val]);
|
||||||
|
|
|
@ -71,7 +71,7 @@ export const useCommentFormFormik = (
|
||||||
if (formik.status) {
|
if (formik.status) {
|
||||||
formik.setStatus('');
|
formik.setStatus('');
|
||||||
}
|
}
|
||||||
}, [formik.values.text]);
|
}, [formik, formik.values.text]);
|
||||||
|
|
||||||
return formik;
|
return formik;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import React, { FC, useContext } from 'react';
|
import React, { createContext, FC, useCallback, useContext, useEffect, useState } from 'react';
|
||||||
import { createContext, useCallback, useEffect, useState } from 'react';
|
|
||||||
|
|
||||||
const DragContext = createContext({
|
const DragContext = createContext({
|
||||||
isDragging: false,
|
isDragging: false,
|
||||||
|
@ -44,7 +43,7 @@ export const useDragDetector = () => {
|
||||||
document.removeEventListener('blur', removeClass);
|
document.removeEventListener('blur', removeClass);
|
||||||
document.removeEventListener('drop', onStopDragging);
|
document.removeEventListener('drop', onStopDragging);
|
||||||
};
|
};
|
||||||
}, [setIsDragging]);
|
}, [onStopDragging, setIsDragging]);
|
||||||
|
|
||||||
return { isDragging, onStopDragging };
|
return { isDragging, onStopDragging };
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,7 @@ export const useInputPasteUpload = (
|
||||||
if (!image) return;
|
if (!image) return;
|
||||||
|
|
||||||
onUpload([image]);
|
onUpload([image]);
|
||||||
}, []);
|
}, [onUpload]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!input) return;
|
if (!input) return;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { IComment, INode } from '~/redux/types';
|
import { INode } from '~/redux/types';
|
||||||
import { FileUploader } from '~/utils/hooks/useFileUploader';
|
import { FileUploader } from '~/utils/hooks/useFileUploader';
|
||||||
import { useCallback, useEffect, useRef } from 'react';
|
import { useCallback, useEffect, useRef } from 'react';
|
||||||
import { FormikHelpers, useFormik, useFormikContext } from 'formik';
|
import { FormikHelpers, useFormik, useFormikContext } from 'formik';
|
||||||
import { object, string } from 'yup';
|
import { object } from 'yup';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { nodeSubmitLocal } from '~/redux/node/actions';
|
import { nodeSubmitLocal } from '~/redux/node/actions';
|
||||||
import { keys } from 'ramda';
|
import { keys } from 'ramda';
|
||||||
|
@ -39,7 +39,7 @@ export const useNodeFormFormik = (
|
||||||
const onSubmit = useCallback((values: INode, helpers: FormikHelpers<INode>) => {
|
const onSubmit = useCallback((values: INode, helpers: FormikHelpers<INode>) => {
|
||||||
helpers.setSubmitting(true);
|
helpers.setSubmitting(true);
|
||||||
dispatch(nodeSubmitLocal(values, onSuccess(helpers)));
|
dispatch(nodeSubmitLocal(values, onSuccess(helpers)));
|
||||||
}, []);
|
}, [dispatch]);
|
||||||
|
|
||||||
const { current: initialValues } = useRef(values);
|
const { current: initialValues } = useRef(values);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ export const useNodeFormFormik = (
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
formik.setFieldValue('files', uploader.files);
|
formik.setFieldValue('files', uploader.files);
|
||||||
}, [formik.setFieldValue, uploader.files]);
|
}, [formik, formik.setFieldValue, uploader.files]);
|
||||||
|
|
||||||
return formik;
|
return formik;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue