File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -567,7 +567,7 @@ class AnnotoriousAnnotator extends HTMLElement {
567567 let resolvedCanvas = await this . vault . get ( uri , 'canvas' )
568568 if ( ! resolvedCanvas && TPEN . activeProject ?. manifest ) {
569569 // Canvas not directly resolvable, try to hydrate from all manifests
570- await this . vault . prefetchDocuments ( TPEN . activeProject . manifest )
570+ await this . vault . prefetchManifests ( TPEN . activeProject . manifest )
571571 // After manifests are cached, try again
572572 resolvedCanvas = await this . vault . get ( uri , 'canvas' )
573573 }
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ export default class ColumnSelector extends HTMLElement {
7070
7171 this . #page = await vault . get ( pageId , 'annotationpage' , true )
7272 if ( ! this . #page && TPEN . activeProject ?. manifest ) {
73- await vault . prefetchDocuments ( TPEN . activeProject . manifest )
73+ await vault . prefetchManifests ( TPEN . activeProject . manifest )
7474 this . #page = await vault . get ( pageId , 'annotationpage' , true )
7575 }
7676 if ( ! this . #page) return
Original file line number Diff line number Diff line change @@ -181,7 +181,7 @@ class ContinueWorking extends HTMLElement {
181181 canvas = await vault . get ( canvasId , 'canvas' )
182182 if ( ! canvas && project . manifest ?. [ 0 ] ) {
183183 // Try to hydrate from all manifests
184- await vault . prefetchDocuments ( project . manifest )
184+ await vault . prefetchManifests ( project . manifest )
185185 // After manifests are cached, try again
186186 canvas = await vault . get ( canvasId , 'canvas' )
187187 }
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ class TpenTranscriptionElement extends HTMLElement {
7171 async #loadPage( annotationPageID ) {
7272 let page = await vault . get ( annotationPageID , 'annotationpage' )
7373 if ( ! page && TPEN . activeProject ?. manifest ) {
74- await vault . prefetchDocuments ( TPEN . activeProject . manifest )
74+ await vault . prefetchManifests ( TPEN . activeProject . manifest )
7575 page = await vault . get ( annotationPageID , 'annotationpage' )
7676 }
7777 if ( ! page ) {
Original file line number Diff line number Diff line change @@ -314,7 +314,7 @@ class LegacyAnnotator extends HTMLElement {
314314 if ( ! page ) return
315315 let resolvedPage = await vault . get ( page , 'annotationpage' )
316316 if ( ! resolvedPage && TPEN . activeProject ?. manifest ) {
317- await vault . prefetchDocuments ( TPEN . activeProject . manifest )
317+ await vault . prefetchManifests ( TPEN . activeProject . manifest )
318318 resolvedPage = await vault . get ( page , 'annotationpage' )
319319 }
320320 if ( ! resolvedPage ) {
@@ -400,7 +400,7 @@ class LegacyAnnotator extends HTMLElement {
400400 let resolvedCanvas = await vault . get ( canvas , 'canvas' )
401401 if ( ! resolvedCanvas && TPEN . activeProject ?. manifest ) {
402402 // Try to hydrate from all manifests
403- await vault . prefetchDocuments ( TPEN . activeProject . manifest )
403+ await vault . prefetchManifests ( TPEN . activeProject . manifest )
404404 // After manifests are cached, try again
405405 resolvedCanvas = await vault . get ( canvas , 'canvas' )
406406 }
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ class TpenImageFragment extends HTMLElement {
208208 this . cleanup . onDocument ( 'canvas-change' , async ( event ) => {
209209 let canvas = await vault . get ( event . detail . canvasId , 'canvas' )
210210 if ( ! canvas && TPEN . activeProject ?. manifest ) {
211- await vault . prefetchDocuments ( TPEN . activeProject . manifest )
211+ await vault . prefetchManifests ( TPEN . activeProject . manifest )
212212 canvas = await vault . get ( event . detail . canvasId , 'canvas' )
213213 }
214214 if ( ! canvas ) {
Original file line number Diff line number Diff line change @@ -483,7 +483,7 @@ export default class SimpleTranscriptionInterface extends HTMLElement {
483483 // Use vault.get to fetch the page properly
484484 let fetchedPage = await vault . get ( pageID , 'annotationpage' , true )
485485 if ( ! fetchedPage && TPEN . activeProject ?. manifest ) {
486- await vault . prefetchDocuments ( TPEN . activeProject . manifest )
486+ await vault . prefetchManifests ( TPEN . activeProject . manifest )
487487 fetchedPage = await vault . get ( pageID , 'annotationpage' , true )
488488 }
489489 if ( ! fetchedPage ) {
@@ -521,7 +521,7 @@ export default class SimpleTranscriptionInterface extends HTMLElement {
521521
522522 let fetchedCanvas = await vault . get ( canvasID , 'canvas' )
523523 if ( ! fetchedCanvas && TPEN . activeProject ?. manifest ) {
524- await vault . prefetchDocuments ( TPEN . activeProject . manifest )
524+ await vault . prefetchManifests ( TPEN . activeProject . manifest )
525525 fetchedCanvas = await vault . get ( canvasID , 'canvas' )
526526 }
527527 if ( ! fetchedCanvas ) {
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ export default class TranscriptionBlock extends HTMLElement {
9696 if ( ! this . #page && TPEN . activeProject ?. manifest ) {
9797 // Try to hydrate from all manifests
9898 const manifestUrls = TPEN . activeProject ?. manifest
99- await vault . prefetchDocuments ( manifestUrls )
99+ await vault . prefetchManifests ( manifestUrls )
100100 // After manifests are cached, try again
101101 this . #page = await vault . get ( pageID , 'annotationpage' , true )
102102 }
Original file line number Diff line number Diff line change @@ -627,7 +627,7 @@ export default class TranscriptionInterface extends HTMLElement {
627627 let canvas = await vault . get ( canvasID , 'canvas' )
628628 if ( ! canvas && TPEN . activeProject ?. manifest ) {
629629 // Canvas not directly resolvable, try to hydrate from all manifests
630- await vault . prefetchDocuments ( TPEN . activeProject . manifest )
630+ await vault . prefetchManifests ( TPEN . activeProject . manifest )
631631 // After manifests are cached, try again
632632 canvas = await vault . get ( canvasID , 'canvas' )
633633 }
@@ -662,7 +662,7 @@ export default class TranscriptionInterface extends HTMLElement {
662662 if ( ! this . #page && TPEN . activeProject ?. manifest ) {
663663 // Try to hydrate from all manifests
664664 const manifestUrls = TPEN . activeProject ?. manifest
665- await vault . prefetchDocuments ( manifestUrls )
665+ await vault . prefetchManifests ( manifestUrls )
666666 // After manifests are cached, try again
667667 this . #page = await vault . get ( pageID , 'annotationpage' , true )
668668 }
Original file line number Diff line number Diff line change @@ -216,11 +216,12 @@ class Vault {
216216 return Object . values ( this . store )
217217 }
218218
219- async prefetchDocuments ( items ) {
219+ async prefetchDocuments ( items , docType ) {
220220 if ( ! Array . isArray ( items ) ) items = [ items ]
221221 const errors = [ ]
222222 const promises = items . map ( item => {
223- return this . get ( item , item ?. [ '@type' ] ?? item ?. type )
223+ const type = docType ?? item ?. [ '@type' ] ?? item ?. type
224+ return this . get ( item , type )
224225 . catch ( err => {
225226 errors . push ( { item, error : err ?. message || String ( err ) } )
226227 return null
@@ -232,6 +233,14 @@ class Vault {
232233 }
233234 return errors
234235 }
236+
237+ async prefetchManifests ( items ) {
238+ return this . prefetchDocuments ( items , 'manifest' )
239+ }
240+
241+ async prefetchCollections ( items ) {
242+ return this . prefetchDocuments ( items , 'collection' )
243+ }
235244}
236245
237246const vault = new Vault ( )
You can’t perform that action at this time.
0 commit comments