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

Added Mirador redux store observer + keep track of current Mirador canvas in Zustand store #330

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

svandaalen
Copy link
Collaborator

Fixes #178.

This PR adds:

  • Observer on the internal Mirador Redux store to better track changes in the internal Mirador state
  • Zustand slice for keeping track of the current canvas displayed in Mirador

Using the current canvas state from the Zustand store in the BrowseScanButtons component (combined with the new observer) fixes the link issue between the prev/next scan buttons and the page break markers. Previously, when the user clicked on one of the page markers, the prev/next scan buttons still thought the user was on the first scan. Now, the (state behind the) prev/next scan buttons update correctly when the user clicks one of the page markers.

@@ -82,6 +90,8 @@ export function Mirador() {
}

function performPostInitialisationActions() {
observeMiradorStore(viewer.store, projectConfig.id, onCanvasChange);
Copy link
Contributor

Choose a reason for hiding this comment

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

Moet er nog iets met de 'unsubscribe' gebeuren?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Goede! Ik heb het toegevoegd in 63d52c3.

if (projectConfig.visualizeAnnosMirador) {
const newCanvas = miradorStore?.getState().windows[projectName]
Copy link
Contributor

Choose a reason for hiding this comment

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

Kun je hier ook de mirador canvas slice gebruiken?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ik heb het geprobeerd, maar op dit punt van de code loopt currentCanvas 1 achter op newCanvas. Bv. je zit op 131r en gaat naar 131v, dan is newCanvas netjes 131v, maar currentCanvas is hier dan nog 131r. De slice wordt dus niet snel genoeg geupdate, terwijl de interne Mirador state wel tijdig geupdate is.

Copy link
Contributor

Choose a reason for hiding this comment

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

A, volgens mij snap ik hem, omdat je hier de change dispatcht in de internal store, is de canvas alleen in de internal store up to date?
Als de internal store leidend is, misschien dan simpeler om een util functie te maken van miradorStore?.getState().windows[projectName].canvasId as string;.
En dan kan de canvas slice weg, aangezien die enkel maar kijkt naar de internal store?

if (projectConfig.visualizeAnnosMirador) {
const newCanvas = miradorStore?.getState().windows[projectName]
Copy link
Contributor

Choose a reason for hiding this comment

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

En hier?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Zie boven.

…useEffect so the observer gets properly subscribed and unsubscribed when the component gets reloaded
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.

Prev/next scan and page break markers are not linked
2 participants