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

Fixed bug where visualization shape is reset when navigating. #872

Merged
merged 2 commits into from
Aug 21, 2024

Conversation

wolfmanstout
Copy link
Contributor

Fixes #870

@lentinj
Copy link
Collaborator

lentinj commented Aug 19, 2024

Thanks for finding this! Yes this makes a lot more sense now.

FWIW, I think the bug is really here:

function setup_page_by_state(controller, state) {
var init = !tree_state.url_parsed;
if (state.hasOwnProperty('image_source')) controller.set_image_source(state.image_source, init)
if (state.hasOwnProperty('lang')) controller.set_language(state.lang, init)
if (state.hasOwnProperty('search_jump_mode')) controller.set_search_jump_mode(state.search_jump_mode, init)
if (state.hasOwnProperty('title')) document.title = unescape(state.title);
if (state.hasOwnProperty('home_ott_id')) config.home_ott_id = state.home_ott_id || null;
if (state.hasOwnProperty('ssaver_inactive_duration_seconds')) tree_settings.ssaver_inactive_duration_seconds = state.ssaver_inactive_duration_seconds || tree_settings.default.ssaver_inactive_duration_seconds
if (state.hasOwnProperty('cols')) controller.change_color_theme(state.cols, init)
controller.close_all();
// Change view type
// NB: In doing so, we implicitly rebuild the tree, which needs to happen regardless on init
return controller.change_view_type(state.vis_type, init).then(function () {

Note everything else only calls the appropriate change function only when there's a value to fill in. change_view_type() we do regardless, to rebuild the tree as a side-effect.

We could do something like ( init || state.hasOwnProperty('vis_type') ? controller.change_view_type(state.vis_type, init) : Promise.resolve() ), but up to you. Happy to merge this as-is too.

Really we shouldn't be relying on change_view_type to rebuild the tree anyway, but unpicking that isn't for today. I seem to have attempted this in the past and it went wrong...

@wolfmanstout
Copy link
Contributor Author

Updated the fix per your suggestion (and tested it).

@lentinj lentinj merged commit c2e33ab into OneZoom:main Aug 21, 2024
1 check passed
@lentinj
Copy link
Collaborator

lentinj commented Aug 21, 2024

Excellent. Thanks!

@wolfmanstout wolfmanstout deleted the fix_view_reset branch December 10, 2024 05:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Settings are reset upon clicking "Popular places" links
2 participants