Fix: tweak doc detail component behavior while awaiting metadata (#5546)

This commit is contained in:
shamoon 2024-01-25 13:22:03 -08:00 committed by GitHub
parent 1e4d284b30
commit 6fb4daf03e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 33 deletions

View File

@ -324,7 +324,7 @@
<ng-container i18n>Loading...</ng-container>
</div>
</div>
}
} @else {
@switch (contentRenderType) {
@case (ContentRenderType.PDF) {
@if (!useNativePdfViewer) {
@ -364,4 +364,5 @@
</form>
</div>
}
}
</ng-template>

View File

@ -681,6 +681,7 @@ describe('DocumentDetailComponent', () => {
it('should support Enter key in password field', () => {
initNormally()
component.metadata = { has_archive_version: true }
component.onError({ name: 'PasswordException' }) // normally dispatched by pdf viewer
fixture.detectChanges()
expect(component.password).toBeUndefined()

View File

@ -82,6 +82,7 @@ enum ContentRenderType {
Image = 'image',
Text = 'text',
Other = 'other',
Unknown = 'unknown',
}
enum ZoomSetting {
@ -211,6 +212,7 @@ export class DocumentDetailComponent
}
get contentRenderType(): ContentRenderType {
if (!this.metadata) return ContentRenderType.Unknown
const contentType = this.metadata?.has_archive_version
? 'application/pdf'
: this.metadata?.original_mime_type