Skip to content
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 URL hash change #3746

Merged
merged 5 commits into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).

### Fixed

- Fixed an error that occured when changing the URL hash. [#3746](https://github.com/scalableminds/webknossos/pull/3746)
- The modals for a new task description and recommended task settings are no longer shown in read-only tracings. [#3724](https://github.com/scalableminds/webknossos/pull/3724)
- Fixed a bug where some NMLs caused the webKnossos tab to freeze during NML upload. [#3758](https://github.com/scalableminds/webknossos/pull/3758)

Expand Down
12 changes: 8 additions & 4 deletions frontend/javascripts/oxalis/controller/url_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,18 @@ class UrlManager {
window.history.replaceState({}, null, url);
}

onHashChange() {
onHashChange = () => {
const stateString = location.hash.slice(1);
if (stateString) {
if (stateString.includes("=")) {
// The hash was changed by a comment link, for example `activeNode=12`
const [key, value] = stateString.split("=");
// The value can either be a single number or multiple numbers delimited by a ,
applyState({ [key]: value.indexOf(",") > -1 ? value.split(",").map(Number) : Number(value) });
applyState({ [key]: value.includes(",") ? value.split(",").map(Number) : Number(value) });
} else {
// The hash was changed by the user
applyState(this.parseUrl());
}
}
};

parseUrl(): UrlManagerState {
// State string format:
Expand Down