From 1056c943d3de790cb96ddd829eb0e65c9d576a50 Mon Sep 17 00:00:00 2001 From: fadingNA Date: Sun, 10 Nov 2024 14:39:56 -0500 Subject: [PATCH] fix remove button on navigation sidebar and setting/document --- frontend/src/Navigation.tsx | 9 +++++ .../src/components/DocumentPagination.tsx | 8 +++-- frontend/src/models/misc.ts | 1 + frontend/src/settings/Documents.tsx | 33 ++++++++++--------- frontend/src/settings/index.tsx | 28 ++++++++++++---- 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/frontend/src/Navigation.tsx b/frontend/src/Navigation.tsx index 72c0d57a..324d5aa0 100644 --- a/frontend/src/Navigation.tsx +++ b/frontend/src/Navigation.tsx @@ -34,10 +34,12 @@ import { selectSelectedDocs, selectSelectedDocsStatus, selectSourceDocs, + selectPaginatedDocuments, setConversations, setModalStateDeleteConv, setSelectedDocs, setSourceDocs, + setPaginatedDocuments, } from './preferences/preferenceSlice'; import Spinner from './assets/spinner.svg'; import SpinnerDark from './assets/spinner-dark.svg'; @@ -72,6 +74,7 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { const conversations = useSelector(selectConversations); const modalStateDeleteConv = useSelector(selectModalStateDeleteConv); const conversationId = useSelector(selectConversationId); + const paginatedDocuments = useSelector(selectPaginatedDocuments); const [isDeletingConversation, setIsDeletingConversation] = useState(false); const { isMobile } = useMediaQuery(); @@ -143,6 +146,12 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) { }) .then((updatedDocs) => { dispatch(setSourceDocs(updatedDocs)); + const updatedPaginatedDocs = paginatedDocuments?.filter( + (document) => document.id !== doc.id, + ); + dispatch( + setPaginatedDocuments(updatedPaginatedDocs || paginatedDocuments), + ); dispatch( setSelectedDocs( Array.isArray(updatedDocs) && diff --git a/frontend/src/components/DocumentPagination.tsx b/frontend/src/components/DocumentPagination.tsx index 3edeff9d..b0532362 100644 --- a/frontend/src/components/DocumentPagination.tsx +++ b/frontend/src/components/DocumentPagination.tsx @@ -48,10 +48,14 @@ const Pagination: React.FC = ({