mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
removed search reducer completely
This commit is contained in:
parent
38eedab3c2
commit
b82ccfb786
22 changed files with 146 additions and 570 deletions
|
@ -1,37 +1,18 @@
|
|||
import React, { FC, useCallback } from 'react';
|
||||
import React, { FC } from 'react';
|
||||
import styles from './styles.module.scss';
|
||||
import { LoaderCircle } from '~/components/input/LoaderCircle';
|
||||
import { FlowRecentItem } from '../FlowRecentItem';
|
||||
import { Icon } from '~/components/input/Icon';
|
||||
import { INode } from '~/redux/types';
|
||||
import { InfiniteScroll } from '~/components/containers/InfiniteScroll';
|
||||
|
||||
interface IProps {
|
||||
isLoading: boolean;
|
||||
results: INode[];
|
||||
hasMore: boolean;
|
||||
onLoadMore: () => void;
|
||||
}
|
||||
|
||||
const FlowSearchResults: FC<IProps> = ({ results, isLoading, onLoadMore }) => {
|
||||
const onScroll = useCallback(
|
||||
event => {
|
||||
const el = event.target;
|
||||
const bottom = el.scrollHeight - el.scrollTop - el.clientHeight;
|
||||
|
||||
if (bottom > 100) return;
|
||||
|
||||
onLoadMore();
|
||||
},
|
||||
[onLoadMore]
|
||||
);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className={styles.loading}>
|
||||
<LoaderCircle size={64} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const FlowSearchResults: FC<IProps> = ({ results, isLoading, onLoadMore, hasMore }) => {
|
||||
if (!results.length) {
|
||||
return (
|
||||
<div className={styles.loading}>
|
||||
|
@ -42,10 +23,12 @@ const FlowSearchResults: FC<IProps> = ({ results, isLoading, onLoadMore }) => {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className={styles.wrap} onScroll={onScroll}>
|
||||
{results.map(node => (
|
||||
<FlowRecentItem node={node} key={node.id} />
|
||||
))}
|
||||
<div className={styles.wrap}>
|
||||
<InfiniteScroll hasMore={hasMore} loadMore={onLoadMore}>
|
||||
{results.map(node => (
|
||||
<FlowRecentItem node={node} key={node.id} />
|
||||
))}
|
||||
</InfiniteScroll>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue