ecmarkup icon indicating copy to clipboard operation
ecmarkup copied to clipboard

Preserve toggled annotations when navigating multipage

Open syg opened this issue 2 years ago • 5 comments

When navigating both between single page/multipage mode and between different multipage pages, toggled user-code annotations should be preserved.

Probably the toggle should append a query string snippet that gets preserved. Also makes the annotations linkable.

syg avatar Jan 10 '22 20:01 syg

Probably the toggle should append a query string snippet that gets preserved

Alternative is to put it in localStorage, so it's also preserved when you come back to it. That means it's not linkable, though.

bakkot avatar Jan 10 '22 20:01 bakkot

Alternative is to put it in localStorage, so it's also preserved when you come back to it. That means it's not linkable, though.

Maybe both?

syg avatar Jan 10 '22 20:01 syg

Sure, that works. Makes the state machine a little complicated, though, because you don't want navigating to such a URL to set the persistent bit.

What I'm thinking is:

  • state of "annotation is displayed" is always in agreement with "url indicates annotations are displayed"
  • when hitting u:
    • if annotations are not displayed, they are turned on (and therefore also URL is updated) & bit in localStorage is set to on (regardless of its previous state)
    • if annotations are displayed, they are turned off (and therefore also URL is updated) & bit in localStorage is set to off (regardless of its previous state)
  • when loading a page:
    • if localStorage bit is set, annotations are turned on (and therefore also URL is updated)

(I guess that's not actually particularly complicated.)

bakkot avatar Jan 10 '22 20:01 bakkot

I was just about to open an issue regarding the loss of search results when I saw this one. Should they be considered together?

gibson042 avatar Jan 10 '22 22:01 gibson042

@gibson042 That's a slightly different thing - search results would probably go in sessionStorage, like we do for the references pane. So go ahead and open a different issue I think.

bakkot avatar Jan 10 '22 22:01 bakkot