Fix an issue causing a blank index when navigating
Status 304 a bitch.
This commit is contained in:
parent
9b9a2980aa
commit
91a63d1bc2
@ -3058,7 +3058,7 @@
|
||||
}
|
||||
},
|
||||
pageNav: function(pageNum) {
|
||||
if (Index.currentPage === pageNum) {
|
||||
if (Index.currentPage === pageNum && !Index.root.parentElement) {
|
||||
return;
|
||||
}
|
||||
history.pushState(null, '', pageNum === 0 ? './' : pageNum);
|
||||
@ -3156,7 +3156,7 @@
|
||||
return $('#hidden-count', Index.hideLabel).textContent = hiddenCount === 1 ? '1 hidden thread' : "" + hiddenCount + " hidden threads";
|
||||
},
|
||||
update: function(pageNum) {
|
||||
var now, onload, _ref, _ref1;
|
||||
var board, now, onload, sortedThreads, _ref, _ref1;
|
||||
if (!navigator.onLine) {
|
||||
return;
|
||||
}
|
||||
@ -3176,6 +3176,10 @@
|
||||
if ((_ref1 = Index.notice) != null) {
|
||||
_ref1.close();
|
||||
}
|
||||
sortedThreads = Index.sortedThreads;
|
||||
if (sortedThreads) {
|
||||
board = sortedThreads[0].board.ID;
|
||||
}
|
||||
now = Date.now();
|
||||
$.ready(function() {
|
||||
return Index.nTimeout = setTimeout((function() {
|
||||
@ -3190,11 +3194,11 @@
|
||||
onload = function(e) {
|
||||
return Index.load(e, pageNum);
|
||||
};
|
||||
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD + "/catalog.json", {
|
||||
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
|
||||
onabort: onload,
|
||||
onloadend: onload
|
||||
}, {
|
||||
whenModified: Index.board === ("" + g.BOARD)
|
||||
whenModified: board === g.BOARD.ID
|
||||
});
|
||||
return $.addClass(Index.button, 'fa-spin');
|
||||
},
|
||||
@ -3225,12 +3229,11 @@
|
||||
return;
|
||||
}
|
||||
Navigate.title();
|
||||
Index.board = "" + g.BOARD;
|
||||
try {
|
||||
if (req.status === 200) {
|
||||
Index.parse(req.response, pageNum);
|
||||
} else if (req.status === 304 && (pageNum != null)) {
|
||||
Index.pageNav(pageNum);
|
||||
} else if (req.status === 304) {
|
||||
Index.pageNav(pageNum || 0);
|
||||
}
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
|
||||
@ -3117,7 +3117,7 @@
|
||||
}
|
||||
},
|
||||
pageNav: function(pageNum) {
|
||||
if (Index.currentPage === pageNum) {
|
||||
if (Index.currentPage === pageNum && !Index.root.parentElement) {
|
||||
return;
|
||||
}
|
||||
history.pushState(null, '', pageNum === 0 ? './' : pageNum);
|
||||
@ -3215,7 +3215,7 @@
|
||||
return $('#hidden-count', Index.hideLabel).textContent = hiddenCount === 1 ? '1 hidden thread' : "" + hiddenCount + " hidden threads";
|
||||
},
|
||||
update: function(pageNum) {
|
||||
var now, onload, _ref, _ref1;
|
||||
var board, now, onload, sortedThreads, _ref, _ref1;
|
||||
if (!navigator.onLine) {
|
||||
return;
|
||||
}
|
||||
@ -3235,6 +3235,10 @@
|
||||
if ((_ref1 = Index.notice) != null) {
|
||||
_ref1.close();
|
||||
}
|
||||
sortedThreads = Index.sortedThreads;
|
||||
if (sortedThreads) {
|
||||
board = sortedThreads[0].board.ID;
|
||||
}
|
||||
now = Date.now();
|
||||
$.ready(function() {
|
||||
return Index.nTimeout = setTimeout((function() {
|
||||
@ -3249,11 +3253,11 @@
|
||||
onload = function(e) {
|
||||
return Index.load(e, pageNum);
|
||||
};
|
||||
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD + "/catalog.json", {
|
||||
Index.req = $.ajax("//a.4cdn.org/" + g.BOARD.ID + "/catalog.json", {
|
||||
onabort: onload,
|
||||
onloadend: onload
|
||||
}, {
|
||||
whenModified: Index.board === ("" + g.BOARD)
|
||||
whenModified: board === g.BOARD.ID
|
||||
});
|
||||
return $.addClass(Index.button, 'fa-spin');
|
||||
},
|
||||
@ -3284,12 +3288,11 @@
|
||||
return;
|
||||
}
|
||||
Navigate.title();
|
||||
Index.board = "" + g.BOARD;
|
||||
try {
|
||||
if (req.status === 200) {
|
||||
Index.parse(req.response, pageNum);
|
||||
} else if (req.status === 304 && (pageNum != null)) {
|
||||
Index.pageNav(pageNum);
|
||||
} else if (req.status === 304) {
|
||||
Index.pageNav(pageNum || 0);
|
||||
}
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
|
||||
@ -412,7 +412,7 @@ Index =
|
||||
Index.pageNav pageNum
|
||||
|
||||
pageNav: (pageNum) ->
|
||||
return if Index.currentPage is pageNum
|
||||
return if Index.currentPage is pageNum and not Index.root.parentElement
|
||||
history.pushState null, '', if pageNum is 0 then './' else pageNum
|
||||
Index.pageLoad pageNum
|
||||
|
||||
@ -498,6 +498,10 @@ Index =
|
||||
delete Index.pageNum
|
||||
Index.req?.abort()
|
||||
Index.notice?.close()
|
||||
|
||||
{sortedThreads} = Index
|
||||
if sortedThreads
|
||||
board = sortedThreads[0].board.ID
|
||||
|
||||
# This notice only displays if Index Refresh is taking too long
|
||||
now = Date.now()
|
||||
@ -509,11 +513,11 @@ Index =
|
||||
|
||||
pageNum = null if typeof pageNum isnt 'number' # event
|
||||
onload = (e) -> Index.load e, pageNum
|
||||
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD}/catalog.json",
|
||||
Index.req = $.ajax "//a.4cdn.org/#{g.BOARD.ID}/catalog.json",
|
||||
onabort: onload
|
||||
onloadend: onload
|
||||
,
|
||||
whenModified: Index.board is "#{g.BOARD}"
|
||||
whenModified: board is g.BOARD.ID
|
||||
$.addClass Index.button, 'fa-spin'
|
||||
|
||||
load: (e, pageNum) ->
|
||||
@ -541,13 +545,11 @@ Index =
|
||||
|
||||
Navigate.title()
|
||||
|
||||
Index.board = "#{g.BOARD}"
|
||||
|
||||
try
|
||||
if req.status is 200
|
||||
Index.parse req.response, pageNum
|
||||
else if req.status is 304 and pageNum?
|
||||
Index.pageNav pageNum
|
||||
else if req.status is 304
|
||||
Index.pageNav pageNum or 0
|
||||
catch err
|
||||
c.error "Index failure: #{err.message}", err.stack
|
||||
# network error or non-JSON content for example.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user