Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,9 @@ const App = () => {
<Route element={<Dashboard />} path="dashboard" exact />
<Route element={<ProfilePage />} path="profile" exact />
</Route>
<Route element={<BrowseScreen />} path="browse">
<Route element={<BrowseScreen />} path=":code">
<Route element={<BrowseScreen />} path=":folderId" />
</Route>
</Route>
<Route element={<BrowseScreen />} path="browse" />
<Route element={<BrowseScreen />} path="browse/:code" />
<Route element={<BrowseScreen />} path="browse/:code/:folderId" />
<Route element={<LandingPage />} path="/" />
<Route element={<ErrorScreen />} path="*" />
</Routes>
Expand Down
6 changes: 6 additions & 0 deletions client/src/screens/browse/components/browsefolder/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { ConfirmDialog } from "./confirmDialog";
import { FolderRename } from "./folderRename.jsx";
import { getSubtreeFileCount } from "../../../../utils/folderUtils";

import { useNavigate } from "react-router-dom";

const BrowseFolder = ({
name,
subject,
Expand All @@ -17,6 +19,7 @@ const BrowseFolder = ({
isMobileView = false,
}) => {
const dispatch = useDispatch();
const navigate = useNavigate();
const currentFolder = useSelector((state) => state.fileBrowser.currentFolder);
const isBR = useSelector((state) => state.user.user.isBR);
const [showConfirm, setShowConfirm] = useState(false);
Expand Down Expand Up @@ -58,6 +61,9 @@ const BrowseFolder = ({
dispatch(PushFolderHistory(currentFolder));
}
dispatch(ChangeFolder(folderData));
if (courseCode && folderData?._id) {
navigate(`/browse/${courseCode}/${folderData._id}`);
}
};

const handleDelete = async (e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { ChangeFolder } from "../../../../../../actions/filebrowser_actions";
import { useEffect } from "react";
import { getSubtreeFileCount } from "../../../../../../utils/folderUtils";

import { useNavigate } from "react-router-dom";

const Folder = ({ folder, state }) => {
const dispatch = useDispatch();
const navigate = useNavigate();
const _state = useSelector((state) => state.fileBrowser);
const [open, setOpen] = useState(state ? state : false);
const fileCount = getSubtreeFileCount(folder);
Expand All @@ -23,6 +26,9 @@ const Folder = ({ folder, state }) => {
const onClick = (folderData) => {
dispatch(ChangeFolder(folderData));
setOpen(true);
if (_state.currentCourseCode && folderData?._id) {
navigate(`/browse/${_state.currentCourseCode}/${folderData._id}`);
}
};

useEffect(() => {
Expand Down
7 changes: 4 additions & 3 deletions client/src/screens/browse/components/collapsible/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Collapsible = ({ course, color, state = false }) => {
const allCourseData = useSelector((state) => state.fileBrowser.allCourseData);
const dispatch = useDispatch();
const navigate = useNavigate();
const currentFolder = useSelector((state) => state.fileBrowser.currentFolder);
const { code, folderId } = useParams();

const isCurrentCourse =
Expand Down Expand Up @@ -142,12 +143,12 @@ const Collapsible = ({ course, color, state = false }) => {
useEffect(() => {
if (!isCurrentCourse || !code || !folderId) return;
if (code?.toLowerCase() !== normalizedCode) return;

const searchedFolder = searchFolderById(currentCourse, folderId);
if (searchedFolder) {

if (searchedFolder && searchedFolder._id !== currentFolder?._id) {
dispatch(ChangeFolder(searchedFolder));
}
}, [isCurrentCourse, code, folderId, normalizedCode, currentCourse, dispatch]);
}, [isCurrentCourse, code, folderId, normalizedCode, currentCourse, currentFolder, dispatch]);

const showTree =
!loading &&
Expand Down
Loading