mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-23 08:50:27 +01:00
Revert "fix: #8955, popstate to purged topic should go to homepage"
This reverts commit 39dae0aaff.
This commit is contained in:
@@ -423,34 +423,16 @@ ajaxify = window.ajaxify || {};
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$(window).on('popstate', function (ev) {
|
$(window).on('popstate', function (ev) {
|
||||||
ev = ev.originalEvent;
|
ev = ev.originalEvent;
|
||||||
let url = ev.state.url;
|
|
||||||
const execute = function () {
|
|
||||||
ajaxify.go(url, function () {
|
|
||||||
$(window).trigger('action:popstate', { url: url });
|
|
||||||
}, true);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (ev !== null && ev.state) {
|
if (ev !== null && ev.state) {
|
||||||
if (url === null && ev.state.returnPath !== undefined) {
|
if (ev.state.url === null && ev.state.returnPath !== undefined) {
|
||||||
window.history.replaceState({
|
window.history.replaceState({
|
||||||
url: ev.state.returnPath,
|
url: ev.state.returnPath,
|
||||||
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
|
}, ev.state.returnPath, config.relative_path + '/' + ev.state.returnPath);
|
||||||
} else if (url !== undefined) {
|
} else if (ev.state.url !== undefined) {
|
||||||
if (url.startsWith('topic/')) {
|
ajaxify.go(ev.state.url, function () {
|
||||||
// Check topic exists
|
$(window).trigger('action:popstate', { url: ev.state.url });
|
||||||
fetch(`${config.relative_path}/${url}`, {
|
}, true);
|
||||||
method: 'HEAD',
|
|
||||||
cache: 'no-cache',
|
|
||||||
}).then((res) => {
|
|
||||||
if (res.status === 404) {
|
|
||||||
url = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
execute();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
execute();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user