Skip to content

implemented url based folder routing - #186

Open
akashroy8210 wants to merge 8 commits into
devfrom
url-based-folder-routing
Open

implemented url based folder routing#186
akashroy8210 wants to merge 8 commits into
devfrom
url-based-folder-routing

Conversation

@akashroy8210

Copy link
Copy Markdown
Contributor

File Changes & Rationale
client/src/App.jsx
What I Changed: Added flat route paths for /browse, /browse/:code, and /browse/:code/:folderId.
Why: To teach the app to recognize web links that include a folder ID.

client/src/screens/browse/index.jsx
What I Changed: Added code to read :folderId from the URL, automatically update the folder view when the URL changes, and handle invalid links.
Why: So that when a user refreshes the page, opens a shared link, or clicks the browser Back button, the app reads the URL and shows the correct folder.

client/src/screens/browse/components/browsefolder/index.jsx
What I Changed: Updated the folder click handler to run navigate('/browse/:code/:folderId').
Why: So that clicking a folder card updates the browser address bar and creates a step in the browser's Back/Forward history.

client/src/screens/browse/components/collapsible/components/folder/index.jsx
What I Changed: Updated the sidebar folder click handler to run navigate('/browse/:code/:folderId').
Why: So that clicking a folder in the left sidebar menu also updates the browser address bar.

client/src/screens/browse/components/collapsible/index.jsx
What I Changed: Added a check to verify if the searched folder is already active (searchedFolder._id !== currentFolder?._id). If it is already active, do not dispatch the folder change.
Why: Because without this check, useEffect was continuously dispatching folder updates on every render, causing an infinite background loop that crashed the page.

@RsbhThakur RsbhThakur left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall amazing PR, but two minor fixes before we can merge:

  1. Revert the changes of client/package-lock.json, it appears some local dev npm install noise to me, definitely not required in the diff and may cause problems.
  2. The navigation is working fine overall but with one major problem: when we are at the root of the course folder then say we go to some folder like exams and then press the back button - it should again go to the course page root, but instead its doing nothing just changing the href link. The navigation inside the subfolders are working fine.

@akashroy8210

Copy link
Copy Markdown
Contributor Author

Fix course root navigation when pressing Back from a subfolder

Resolved an issue where pressing the Back button from a subfolder (like exams) changed the browser URL back to the main course page (/browse/:code), but the screen UI remained stuck displaying the subfolder content. Navigating back now correctly updates both the URL and the displayed course page view.

@DreamBot706 DreamBot706 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DreamBot706 DreamBot706 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement URL-based folder routing for intuitive browser back button navigation

4 participants