-
Notifications
You must be signed in to change notification settings - Fork 651
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
fix(DiffViewer & ArticleViewer): handle moved articles using MediaWik… #6072
fix(DiffViewer & ArticleViewer): handle moved articles using MediaWik… #6072
Conversation
3a99736
to
f4a8315
Compare
I don't know why the build is failing for the test article_viewer_spec.rb. It’s passing for me locally.😅 2024-12-22.18-19-58.mp4 |
@@ -14,7 +14,7 @@ const Article = ({ article, index, course, fetchArticleDetails, updateArticleTra | |||
|
|||
const fetchMissingArticleDetails = () => { | |||
if (!articleDetails) { | |||
fetchArticleDetails(article.id, course.id); | |||
fetchArticleDetails(article.id, course.id, article.title, article.mw_page_id); |
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.
I think this gets called from several places, including Assignment.jsx which you haven't changed. Did you check them all to verify that this doesn't break anything?
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.
Did you check everything to ensure this doesn't break anything?
No 😅, I forgot to check.
Now, I have updated fetchArticleDetails to fetch the article title and the MW page ID directly from the Redux store using the existing article ID via getState. This means other places using fetchArticleDetails no longer need to pass the title and page ID.
@@ -12,5 +12,6 @@ json.course do | |||
json.rating_num rating_priority(article.rating) | |||
json.pretty_rating rating_display(article.rating) | |||
json.user_ids ac.user_ids | |||
json.mw_page_id article.mw_page_id |
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.
This could probably be done within the json.call(article ...)
instead of on its own line? I guess url
and user_ids
could be consolidated as well?
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.
Okay.
return function (dispatch) { | ||
export function fetchArticleDetails(articleId, courseId, articleTitle, article_mw_page_id) { | ||
return async function (dispatch) { | ||
const crossCheckedArticleTitle = await dispatch(crossCheckArticleTitle(articleId, articleTitle, article_mw_page_id)); |
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.
Hmm... this will add an extra network call to every time we use fetchArticleDetails, even though in most cases the page has not moved.
Is it possible to implement this strategy only for cases where the query for article data doesn't work?
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.
Is it possible to implement this strategy only for cases where the query for article data doesn't work?
Yes, I made the changes to call crossCheckedArticle
only if the last and first revisions are undefined, indicating that the article title has been moved.
…i page ID - Added "crossCheckArticleTitle" function to verify and update article titles and URLs using the MediaWiki API based on the page ID. - Introduced "UPDATE_ARTICLE_TITLE_AND_URL" action in the reducer to update article titles and URLs in the Redux store when article title is changed. - Updated "fetchArticleDetails" to integrate "crossCheckArticleTitle" for dynamic title validation and updates before if fetching article first and last revision fails. - Enhanced handling of moved articles by verifying and updating titles via MediaWiki API by using "crossCheckArticleTitle" in ArticleViewer.
f4a8315
to
d8d46eb
Compare
Updated.1.mp4 |
closes #6056
What this PR does
This PR addresses an issue where the
DiffViewer
andArticleViewer
components did not handle moved articles correctly, resulting inerrors
forDiffViewer
andCould not fetch authorship data: Requested page not found. [404]
forArticleViewer
.Fix
Check the current article title by fetching it from the Wikipedia API using the article's page ID if first and last revision are undefined and update the title and URL for the respective article.
Screenshots
Before:
Before.mp4
After:
After.mp4