[Squash me] Fix bug refusing to switch channel when clicking back after closing image viewer

This commit is contained in:
Jérémie Astori 2017-09-10 15:00:27 -04:00
parent b33ea0f567
commit a921d7bf04
No known key found for this signature in database
GPG Key ID: B9A4F245CD67BDE8
2 changed files with 6 additions and 5 deletions

View File

@ -331,7 +331,7 @@ $(function() {
const state = {};
if (self.hasClass("chan")) {
state.clickTarget = `.chan[data-id="${self.data("id")}"]`;
state.clickTarget = `#sidebar .chan[data-id="${self.data("id")}"]`;
} else {
state.clickTarget = `#footer button[data-target="${target}"]`;
}
@ -812,9 +812,7 @@ $(function() {
if (clickTarget) {
// This will be true when click target corresponds to opening a thumbnail,
// browsing to the previous/next thumbnail, or closing the image viewer.
const imageViewerRelated =
clickTarget === "#image-viewer" ||
clickTarget.includes(".toggle-thumbnail");
const imageViewerRelated = clickTarget.includes(".toggle-thumbnail");
// If the click target is not related to the image viewer but the viewer
// is currently opened, we need to close it.

View File

@ -202,6 +202,9 @@ function closeImageViewer({pushState = true} = {}) {
// History management
if (pushState) {
history.pushState({clickTarget: "#image-viewer"}, null, null);
const clickTarget =
"#sidebar " +
`.chan[data-id="${$("#sidebar .chan.active").data("id")}"]`;
history.pushState({clickTarget}, null, null);
}
}