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(core): preserve the zoom status only when needed #974

Merged
merged 5 commits into from
Sep 27, 2023

Conversation

sehilyi
Copy link
Member

@sehilyi sehilyi commented Sep 26, 2023

Fix #973

Change List

  • Do not preserve zoom status across examples. This is fixed by adding an additional if statement. Also, added tests for this.

Checklist

  • Ensure the PR works with all demos on the online editor
  • Unit tests added or updated
  • Examples added or updated
  • Documentation updated (e.g., added API functions)
  • Screenshots for visual changes (e.g., new encoding support or UI change on Editor)

@sehilyi sehilyi changed the title fix: preserve the zoom status only when needed fix(core): preserve the zoom status only when needed Sep 26, 2023
const lockUid = locksByViewUid[viewUid];
const linkedViewUid = Object.entries(locksByViewUid).find(([_, uid]) => _ && uid === lockUid)?.[0];
// Only if the linked view existed in the previous spec, we copy the zooming status
const linkedViewExistedPrev = !!prevSpec.views.find(v => v.uid === linkedViewUid);
Copy link
Member Author

@sehilyi sehilyi Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main code I added to fix the issue. This basically checks whether if this view is linked with a view that existed previously.

@@ -13,6 +13,7 @@ import { isEqual } from 'lodash-es';
import * as uuid from 'uuid';
import { publish } from '../api/pubsub';
import type { IdTable } from '../api/track-and-view-ids';
import { preverseZoomStatus } from '../compiler/spec-preprocess';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved under \compiler – a better place than this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this function is only used in gosling-component.tsx I think it should be kept in /core? I see you logic though, that it is making manipulations on the spec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Would be better to put a file closer to where it is used! Added a util file for this function.

@sehilyi sehilyi requested a review from etowahadams September 26, 2023 17:26
Copy link
Contributor

@etowahadams etowahadams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested with the built editor by adding and removing tracks and switching between specs. Looks good to me! Thanks for taking care of this.

@@ -13,6 +13,7 @@ import { isEqual } from 'lodash-es';
import * as uuid from 'uuid';
import { publish } from '../api/pubsub';
import type { IdTable } from '../api/track-and-view-ids';
import { preverseZoomStatus } from '../compiler/spec-preprocess';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this function is only used in gosling-component.tsx I think it should be kept in /core? I see you logic though, that it is making manipulations on the spec.

@sehilyi sehilyi merged commit b74f10e into master Sep 27, 2023
5 checks passed
@sehilyi sehilyi deleted the sehilyi/fix-zoom-preverse-in-editor branch September 27, 2023 14:51
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.

Zooms are preserved between Editor examples
2 participants