@@ -3,6 +3,7 @@ import CheckPermissions from "../../components/check-permissions/checkPermission
33import { renderPermissionError } from "../../utilities/renderPermissionError.js"
44import { onProjectReady } from "../../utilities/projectReady.js"
55import { CleanupRegistry } from '../../utilities/CleanupRegistry.js'
6+ import vault from '../../js/vault.js'
67
78/**
89 * TpenManageColumns - Interface for managing column assignments on annotation pages.
@@ -633,27 +634,14 @@ class TpenManageColumns extends HTMLElement {
633634 return { x : xywh [ 0 ] , y : xywh [ 1 ] , w : xywh [ 2 ] , h : xywh [ 3 ] }
634635 }
635636
636- isValidUrl ( str ) {
637- try {
638- new URL ( str )
639- return true
640- } catch {
641- return false
642- }
643- }
644-
645- async getSpecificTypeData ( type ) {
646- if ( ! type ) throw new Error ( "No IIIF resource provided" )
647- if ( typeof type === "string" && this . isValidUrl ( type ) ) {
648- const res = await fetch ( type , { cache : "no-store" } )
649- if ( ! res . ok ) throw new Error ( `Fetch failed: ${ res . status } ` )
650- return await res . json ( )
651- }
652- }
653-
654637 async fetchPageViewerData ( pageID = null ) {
655- const annotationPageData = pageID ? await this . getSpecificTypeData ( pageID ) : null
656- const canvasData = await this . getSpecificTypeData ( annotationPageData . target )
638+ if ( ! pageID ) throw new Error ( "No page ID provided" )
639+ const annotationPageData = await vault . getWithFallback ( pageID , 'annotationpage' , TPEN . activeProject ?. manifest , true )
640+ if ( ! annotationPageData ) throw new Error ( "Failed to load annotation page" )
641+ const canvasData = await vault . getWithFallback (
642+ annotationPageData . target , 'canvas' , TPEN . activeProject ?. manifest
643+ )
644+ if ( ! canvasData ) throw new Error ( "Failed to load canvas data" )
657645 return await this . processDirectCanvasData ( canvasData , annotationPageData )
658646 }
659647
@@ -667,8 +655,11 @@ class TpenManageColumns extends HTMLElement {
667655 if ( ! annotationPageData ?. items ) return [ ]
668656 const results = await Promise . all ( annotationPageData . items . map ( async anno => {
669657 try {
670- const res = await fetch ( anno . id , { cache : "no-store" } )
671- const data = await res . json ( )
658+ let data = anno
659+ if ( ! data ?. target ) {
660+ data = await vault . get ( anno . id ?? anno , 'annotation' , true )
661+ }
662+ if ( ! data ) return null
672663 return { target : data ?. target ?. selector ?. value ?? data ?. target , lineId : data ?. id }
673664 } catch { return null }
674665 } ) )
0 commit comments