1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-05 02:45:18 +02:00

Fixed state bug while updating categories. Fixed bug with bookmarks not being displayed under categories.

This commit is contained in:
Paweł Malak 2021-11-09 15:51:50 +01:00
parent 0d5a4c418e
commit f127a354ef
5 changed files with 18 additions and 14 deletions

View file

@ -15,8 +15,8 @@ interface Props {
export const BookmarkGrid = (props: Props): JSX.Element => {
let bookmarks: JSX.Element;
if (props.categories.length > 0) {
if (props.searching && props.categories[0].bookmarks.length === 0) {
if (props.categories.length) {
if (props.searching && !props.categories[0].bookmarks.length) {
bookmarks = (
<p className={classes.BookmarksMessage}>
No bookmarks match your search criteria

View file

@ -41,8 +41,6 @@ export const Bookmarks = (props: Props): JSX.Element => {
const dispatch = useDispatch();
const { getCategories } = bindActionCreators(actionCreators, dispatch);
const { searching = false } = props;
const [modalIsOpen, setModalIsOpen] = useState(false);
const [formContentType, setFormContentType] = useState(ContentType.category);
const [isInEdit, setIsInEdit] = useState(false);
@ -56,10 +54,10 @@ export const Bookmarks = (props: Props): JSX.Element => {
useState<Bookmark>(bookmarkTemplate);
useEffect(() => {
if (categories.length === 0) {
if (!categories.length) {
getCategories();
}
}, [getCategories]);
}, []);
const toggleModal = (): void => {
setModalIsOpen(!modalIsOpen);
@ -148,7 +146,7 @@ export const Bookmarks = (props: Props): JSX.Element => {
{loading ? (
<Spinner />
) : !isInEdit ? (
<BookmarkGrid categories={categories} searching />
<BookmarkGrid categories={categories} searching={props.searching} />
) : (
<BookmarkTable
contentType={tableContentType}