File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,22 @@ export function setupDefaultViewer() {
161161 hashBinding . parseError ;
162162 } ) ,
163163 ) ;
164- hashBinding . updateFromUrlHash ( ) ;
164+ hashBinding . updateFromUrlHash ( ( state ) => {
165+ // convert graphene state timestamp to layer timestamp
166+ const fixTimestamp = ( layer : any ) => {
167+ if ( layer . source ?. state ?. timestamp ) {
168+ layer . timestamp = layer . source . state . timestamp ;
169+ layer . source . state . timestamp = undefined ;
170+ }
171+ } ;
172+ if ( state . layers ) {
173+ const layers = Array . isArray ( state . layers )
174+ ? state . layers
175+ : Object . values ( state . layers ) ;
176+ layers . map ( fixTimestamp ) ;
177+ }
178+ return state ;
179+ } ) ;
165180 viewer . registerDisposer ( bindTitle ( viewer . title ) ) ;
166181
167182 bindDefaultCopyHandler ( viewer ) ;
Original file line number Diff line number Diff line change @@ -113,7 +113,7 @@ export class UrlHashBinding extends RefCounted {
113113 * Sets the current state to match the URL hash. If it is desired to initialize the state based
114114 * on the URL hash, then this should be called immediately after construction.
115115 */
116- updateFromUrlHash ( ) {
116+ updateFromUrlHash ( upgradeState : ( a : any ) => any = ( x ) => x ) {
117117 try {
118118 let s = location . href . replace ( / ^ [ ^ # ] + / , "" ) ;
119119 if ( s === "" || s === "#" || s === "#!" ) {
@@ -160,7 +160,7 @@ export class UrlHashBinding extends RefCounted {
160160 this . root . reset ( ) ;
161161 const state = urlSafeParse ( s ) ;
162162 verifyObject ( state ) ;
163- this . root . restoreState ( state ) ;
163+ this . root . restoreState ( upgradeState ( state ) ) ;
164164 } else {
165165 throw new Error (
166166 `URL hash is expected to be of the form "#!{...}" or "#!+{...}".` ,
You can’t perform that action at this time.
0 commit comments