mirror of
https://github.com/kiwix/kiwix-js.git
synced 2025-09-22 12:01:15 -04:00
Remove callback function for when redirect. Rename early return condition checking function
This commit is contained in:
parent
274d8d8bb9
commit
91c44a3fd1
@ -1003,7 +1003,8 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
||||
if (dirEntry.isRedirect()) {
|
||||
// Update expectedArticleURLToBeDisplayed before redirect.
|
||||
selectedArchive.resolveRedirect(dirEntry, function (resolvedDirEntry) {
|
||||
updatedExpectedURLOnRedirect(resolvedDirEntry, readArticle);
|
||||
expectedArticleURLToBeDisplayed = resolvedDirEntry.namespace + "/" + resolvedDirEntry.url;
|
||||
readArticle(resolvedDirEntry);
|
||||
});
|
||||
} else {
|
||||
params.isLandingPage = false;
|
||||
@ -1019,7 +1020,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
||||
* Check whether the given URL from given dirEntry equals the expectedArticleURLToBeDisplayed
|
||||
* @param {DirEntry} dirEntry The directory entry of the article to read
|
||||
*/
|
||||
function entryIsToExpectedBeDisplayed(dirEntry) {
|
||||
function isDirEntryExpectedToBeDisplayed(dirEntry) {
|
||||
var curArticleURL = dirEntry.namespace + "/" + dirEntry.url;
|
||||
|
||||
if (expectedArticleURLToBeDisplayed !== curArticleURL) {
|
||||
@ -1030,18 +1031,6 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the expectedArticleURLToBeDisplayed after redirect. Fires up the callback function with resolvedDirEntry
|
||||
* @param {*} resolvedDirEntry The resolvedDirEntry returned from resolvedRedirect() function.
|
||||
* @param {*} callback The callback function after updating the expectedArticleURLToBeDisplayed.
|
||||
*/
|
||||
function updatedExpectedURLOnRedirect(resolvedDirEntry, callback){
|
||||
expectedArticleURLToBeDisplayed = resolvedDirEntry.namespace + "/" + resolvedDirEntry.url;
|
||||
console.debug("On redirect, update expectedArticleURLToBeDisplayed to be :" + expectedArticleURLToBeDisplayed);
|
||||
callback(resolvedDirEntry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the article corresponding to the given dirEntry
|
||||
* @param {DirEntry} dirEntry The directory entry of the article to read
|
||||
@ -1054,7 +1043,7 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
||||
// Early return if article's title is not expected to be displayed
|
||||
// Cause an issue if the current dirEntry is redirected from another dirEntry since the urlExpecedToBedisplayed is not updated
|
||||
// before redirecting.
|
||||
if(! entryIsToExpectedBeDisplayed(dirEntry)){
|
||||
if(! isDirEntryExpectedToBeDisplayed(dirEntry)){
|
||||
console.debug(dirEntry, " is not expected to be displayed. Early retrun in readArticle().")
|
||||
return;
|
||||
}
|
||||
@ -1100,7 +1089,8 @@ define(['jquery', 'zimArchiveLoader', 'util', 'uiUtil', 'cookies','abstractFiles
|
||||
if (dirEntry.isRedirect()) {
|
||||
// Update expectedArticleURLToBeDisplayed before redirect then call readArticle.
|
||||
selectedArchive.resolveRedirect(dirEntry, function (resolvedDirEntry) {
|
||||
updatedExpectedURLOnRedirect(resolvedDirEntry, readArticle)
|
||||
expectedArticleURLToBeDisplayed = resolvedDirEntry.namespace + "/" + resolvedDirEntry.url;
|
||||
readArticle(resolvedDirEntry)
|
||||
});
|
||||
} else {
|
||||
// Line below was inserted to prevent the spinner being hidden, possibly by an async function, when pressing the Random button in quick succession
|
||||
|
Loading…
x
Reference in New Issue
Block a user