Skip to content

Commit 1386536

Browse files
committed
Really just need to fix project-details
1 parent 5c259cb commit 1386536

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

components/project-details/index.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "../../components/line-image/index.js"
44
import CheckPermissions from "../check-permissions/checkPermissions.js"
55
import { onProjectReady } from "../../utilities/projectReady.js"
66
import { CleanupRegistry } from "../../utilities/CleanupRegistry.js"
7+
import vault from "../../js/vault.js"
78

89
/**
910
* ProjectDetails - Displays project title, owner, collaborator count, and thumbnail.
@@ -63,6 +64,11 @@ class ProjectDetails extends HTMLElement {
6364
.hidden {
6465
display: none;
6566
}
67+
.manifest-error {
68+
color: var(--gray, #888);
69+
font-style: italic;
70+
padding: 1em 0;
71+
}
6672
#edit-project-title {
6773
background: none;
6874
border: none;
@@ -121,6 +127,7 @@ class ProjectDetails extends HTMLElement {
121127
return
122128
}
123129
this.render()
130+
this.initializeAsync()
124131
}
125132

126133
disconnectedCallback() {
@@ -130,6 +137,32 @@ class ProjectDetails extends HTMLElement {
130137
this._currentManifestKey = null
131138
}
132139

140+
/**
141+
* Performs async initialization after authgate passes.
142+
* Pre-fetches the manifest and replaces the sequence-panel with an
143+
* error message if the manifest cannot be loaded.
144+
*/
145+
async initializeAsync() {
146+
const project = this.Project ?? TPEN.activeProject
147+
const manifestId = Array.isArray(project?.manifest) ? project.manifest[0] : project?.manifest
148+
if (!manifestId) return
149+
150+
const manifest = await vault.get(manifestId, 'manifest')
151+
if (!manifest) {
152+
const panel = this.shadowRoot.querySelector('sequence-panel')
153+
if (panel) {
154+
const errorMsg = document.createElement('p')
155+
errorMsg.textContent = 'Manuscript images could not be loaded.'
156+
errorMsg.className = 'manifest-error'
157+
panel.replaceWith(errorMsg)
158+
}
159+
TPEN.eventDispatcher.dispatch('tpen-toast', {
160+
status: 'error',
161+
message: 'Failed to load manuscript images. Some pages may not display correctly.'
162+
})
163+
}
164+
}
165+
133166
render() {
134167
const project = this.Project ?? TPEN.activeProject
135168

0 commit comments

Comments
 (0)