Fix UI content should change on version select and thumbnail

This commit is contained in:
shamoon
2026-02-12 11:05:10 -08:00
parent 31e57db7ab
commit 6813542f29
2 changed files with 35 additions and 1 deletions

View File

@@ -1616,6 +1616,9 @@ describe('DocumentDetailComponent', () => {
previewSpy.mockReturnValueOnce('preview-version')
jest.spyOn(documentService, 'getThumbUrl').mockReturnValue('thumb-version')
jest
.spyOn(documentService, 'get')
.mockReturnValue(of({ content: 'version-content' } as Document))
component.selectVersion(10)
httpTestingController.expectOne('preview-version').flush('version text')
@@ -1623,6 +1626,7 @@ describe('DocumentDetailComponent', () => {
expect(component.previewUrl).toBe('preview-version')
expect(component.thumbUrl).toBe('thumb-version')
expect(component.previewText).toBe('version text')
expect(component.documentForm.get('content').value).toBe('version-content')
const pdfSource = component.pdfSource as { url: string; password?: string }
expect(pdfSource.url).toBe('preview-version')
expect(pdfSource.password).toBeUndefined()

View File

@@ -805,8 +805,38 @@ export class DocumentDetailComponent
this.selectedVersionId
)
this.updatePdfSource()
this.thumbUrl = this.documentsService.getThumbUrl(this.selectedVersionId)
this.thumbUrl = this.documentsService.getThumbUrl(
this.documentId,
this.selectedVersionId
)
this.loadMetadataForSelectedVersion()
this.documentsService
.get(this.documentId, this.selectedVersionId, 'content')
.pipe(
first(),
takeUntil(this.unsubscribeNotifier),
takeUntil(this.docChangeNotifier)
)
.subscribe({
next: (doc) => {
const content = doc?.content ?? ''
this.document.content = content
this.documentForm.patchValue(
{
content,
},
{
emitEvent: false,
}
)
},
error: (error) => {
this.toastService.showError(
$localize`Error retrieving version content`,
error
)
},
})
// For text previews, refresh content
this.http
.get(this.previewUrl, { responseType: 'text' })