diff --git a/client/src/components/Apps/Apps.tsx b/client/src/components/Apps/Apps.tsx index 2185879..8d3a5df 100644 --- a/client/src/components/Apps/Apps.tsx +++ b/client/src/components/Apps/Apps.tsx @@ -40,10 +40,10 @@ export const Apps = (props: Props): JSX.Element => { const [appInUpdate, setAppInUpdate] = useState(appTemplate); useEffect(() => { - if (apps.length === 0) { + if (!apps.length) { getApps(); } - }, [getApps]); + }, []); const toggleModal = (): void => { setModalIsOpen(!modalIsOpen); @@ -85,7 +85,7 @@ export const Apps = (props: Props): JSX.Element => { {loading ? ( ) : !isInEdit ? ( - + ) : ( )} diff --git a/client/src/components/Bookmarks/BookmarkGrid/BookmarkGrid.tsx b/client/src/components/Bookmarks/BookmarkGrid/BookmarkGrid.tsx index cb4396f..516c3b2 100644 --- a/client/src/components/Bookmarks/BookmarkGrid/BookmarkGrid.tsx +++ b/client/src/components/Bookmarks/BookmarkGrid/BookmarkGrid.tsx @@ -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 = (

No bookmarks match your search criteria diff --git a/client/src/components/Bookmarks/Bookmarks.tsx b/client/src/components/Bookmarks/Bookmarks.tsx index fffb5ff..1205b59 100644 --- a/client/src/components/Bookmarks/Bookmarks.tsx +++ b/client/src/components/Bookmarks/Bookmarks.tsx @@ -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(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 ? ( ) : !isInEdit ? ( - + ) : ( { if (!apps.length) { getApps(); } - }, [getApps]); + }, []); // Load bookmark categories useEffect(() => { if (!categories.length) { getCategories(); } - }, [getCategories]); + }, []); useEffect(() => { if (localSearch) { diff --git a/client/src/store/reducers/bookmark.ts b/client/src/store/reducers/bookmark.ts index ed4cea2..b8e7e61 100644 --- a/client/src/store/reducers/bookmark.ts +++ b/client/src/store/reducers/bookmark.ts @@ -69,7 +69,10 @@ export const bookmarksReducer = ( ...state, categories: [ ...state.categories.slice(0, pinnedCategoryIdx), - action.payload, + { + ...action.payload, + bookmarks: [...state.categories[pinnedCategoryIdx].bookmarks], + }, ...state.categories.slice(pinnedCategoryIdx + 1), ], }; @@ -96,7 +99,10 @@ export const bookmarksReducer = ( ...state, categories: [ ...state.categories.slice(0, updatedCategoryIdx), - action.payload, + { + ...action.payload, + bookmarks: [...state.categories[updatedCategoryIdx].bookmarks], + }, ...state.categories.slice(updatedCategoryIdx + 1), ], };