-
Notifications
You must be signed in to change notification settings - Fork 12
Make review popup #1227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Make review popup #1227
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -67,11 +67,25 @@ | |||||||||||||||||||||||||||||||
| previousPaths.unshift(currentUrl); | ||||||||||||||||||||||||||||||||
| previousPathsTitles.unshift(title); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Keep only the top 10 items | ||||||||||||||||||||||||||||||||
| // Only display last 10 items | ||||||||||||||||||||||||||||||||
| if (previousPaths.length > 10) { | ||||||||||||||||||||||||||||||||
| previousPaths = previousPaths.slice(0, 10); | ||||||||||||||||||||||||||||||||
| // previousPaths = previousPaths.slice(0, 10); | ||||||||||||||||||||||||||||||||
| previousPathsTitles = previousPathsTitles.slice(0, 10); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| // Prevent too many courses from being stored, max 20 | ||||||||||||||||||||||||||||||||
| if (previousPaths.length > 20) { | ||||||||||||||||||||||||||||||||
| previousPaths = previousPaths.slice(0, 20); | ||||||||||||||||||||||||||||||||
| previousPathsTitles = previousPathsTitles.slice(0, 20); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (previousPaths.length % 5 === 0 && previousPaths.length >= 10) { | ||||||||||||||||||||||||||||||||
| // Check if URL matches .../course/[letters]/[numbers] and ends there | ||||||||||||||||||||||||||||||||
| const courseRegex = /course\/[a-zA-Z]+\/\d+\/?$/; | ||||||||||||||||||||||||||||||||
| if (courseRegex.test(currentUrl)) { | ||||||||||||||||||||||||||||||||
| $('#viewLimitModal').modal('show'); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
Comment on lines
+81
to
+88
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix lint/formatting failures flagged by CI. Line 81 has an extra blank line with whitespace (prettier failure), and Line 86 should use double quotes per ESLint config. Proposed fix-
-
- if (previousPaths.length % 5 === 0 && previousPaths.length >= 10) {
+ if (previousPaths.length % 5 === 0 && previousPaths.length >= 10) {
// Check if URL matches .../course/[letters]/[numbers] and ends there
const courseRegex = /course\/[a-zA-Z]+\/\d+\/?$/;
if (courseRegex.test(currentUrl)) {
- $('#viewLimitModal').modal('show');
+ $("#viewLimitModal").modal("show");
}
}📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: Continuous Integration[error] 81-81: prettier/prettier: Delete 🪛 GitHub Check: eslint[failure] 86-86: [failure] 81-81: 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Save back to localStorage | ||||||||||||||||||||||||||||||||
| localStorage.setItem("previous_paths", JSON.stringify(previousPaths)); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,15 @@ | ||||||||||||||||||||
| <!-- View limit modal (imported in index.html) --> | ||||||||||||||||||||
| {% load static %} | ||||||||||||||||||||
| <div class="modal fade" id="viewLimitModal" tabindex="-1" role="dialog" aria-labelledby="viewLimitModalLabel" | ||||||||||||||||||||
| aria-hidden="true" data-backdrop="static" data-keyboard="false"> | ||||||||||||||||||||
|
Comment on lines
+3
to
+4
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No element in this template has Also, Proposed fix-<div class="modal fade" id="viewLimitModal" tabindex="-1" role="dialog" aria-labelledby="viewLimitModalLabel"
- aria-hidden="true" data-backdrop="static" data-keyboard="false">
+<div class="modal fade" id="viewLimitModal" tabindex="-1" role="dialog" aria-labelledby="viewLimitModalLabel"
+ aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-body text-center pt-4 pb-4">
<img src="{% static 'base/img/new_logo.svg' %}" alt="theCourseForum" class="img-fluid mb-3" style="max-height: 60px;">
- <h5 class="mb-3">You've viewed a lot of courses!</h5>
+ <h5 id="viewLimitModalLabel" class="mb-3">You've viewed a lot of courses!</h5>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| <div class="modal-dialog modal-dialog-centered" role="document"> | ||||||||||||||||||||
| <div class="modal-content"> | ||||||||||||||||||||
| <div class="modal-body text-center pt-4 pb-4"> | ||||||||||||||||||||
| <img src="{% static 'base/img/new_logo.svg' %}" alt="theCourseForum" class="img-fluid mb-3" style="max-height: 60px;"> | ||||||||||||||||||||
| <h5 class="mb-3">You've viewed a lot of courses!</h5> | ||||||||||||||||||||
| <p class="mb-4">Consider making a review to help others students like you.</p> | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "others students" → "other students". Proposed fix- <p class="mb-4">Consider making a review to help others students like you.</p>
+ <p class="mb-4">Consider making a review to help other students like you.</p>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| <button type="button" class="btn btn-primary bg-tcf-indigo pl-4 pr-4" data-dismiss="modal">Close</button> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
| </div> | ||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug:
previousPathsandpreviousPathsTitlesgo out of sync.Line 72 comments out the slice for
previousPathswhile Line 73 still slicespreviousPathsTitlesto 10. These two arrays are parallel (same index = same item). OncepreviousPathshas more than 10 entries, titles will have fewer entries than paths, breaking the index correspondence. Any code that iterates both arrays together (e.g., the history/recently-viewed display) will pair wrong titles with wrong URLs or have missing titles.If the intent is to keep 20 paths for the modal counter but only display 10 in the UI, derive the display list at read time rather than corrupting the stored data.
Proposed fix — keep both arrays in sync, derive display count at read time
Then wherever the recently-viewed list is displayed, limit to the first 10 entries at read time.
📝 Committable suggestion
🤖 Prompt for AI Agents