Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/shared/services/api/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const LeanWhitelist = [
'thumbURL500',
'thumbURL1000',
'thumbURL2000',
'thumbnail256',
'thumbDT',
'refArchiveNbr',
'folder_linkId',
Expand Down
45 changes: 44 additions & 1 deletion src/app/shared/services/api/record.repo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
import { of } from 'rxjs';
import { environment } from '@root/environments/environment';
import { HttpService } from '@shared/services/http/http.service';
import { RecordRepo, RecordResponse } from '@shared/services/api/record.repo';
import {
convertStelaRecordToRecordVO,
RecordRepo,
RecordResponse,
StelaRecord,
} from '@shared/services/api/record.repo';
import { RecordVO } from '@root/app/models';
import {
provideHttpClient,
Expand All @@ -15,6 +20,44 @@ import {
import { ShareLink } from '@root/app/share-links/models/share-link';
import { HttpV2Service } from '../http-v2/http-v2.service';

describe('convertStelaRecordToRecordVO', () => {
it('maps thumbnailUrls to all thumb fields', () => {
const stelaRecord = {
recordId: 1,
displayName: 'Test',
archiveNumber: 'arch-1',
displayDate: '2025-01-01',
folderLinkId: '1',
folderLinkType: 'type.folder_link.private',
parentFolderLinkId: '2',
thumbnailUrls: {
'200': 'https://example.com/200',
'256': 'https://example.com/256',
'500': 'https://example.com/500',
'1000': 'https://example.com/1000',
'2000': 'https://example.com/2000',
},
location: null,
files: [],
createdAt: '2025-01-01',
updatedAt: '2025-01-01',
archive: { id: '1', name: 'Archive', thumbURL200: '' },
shares: null,
tags: null,
};

const result = convertStelaRecordToRecordVO(
stelaRecord as unknown as StelaRecord,
);

expect(result.thumbURL200).toBe('https://example.com/200');
expect(result.thumbURL500).toBe('https://example.com/500');
expect(result.thumbURL1000).toBe('https://example.com/1000');
expect(result.thumbURL2000).toBe('https://example.com/2000');
expect(result.thumbnail256).toBe('https://example.com/256');
});
});

describe('RecordRepo', () => {
let repo: RecordRepo;
let httpMock: HttpTestingController;
Expand Down
20 changes: 12 additions & 8 deletions src/app/shared/services/api/record.repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,13 @@ export type StelaRecord = Omit<RecordVO, 'files'> & {
folderLinkId: string;
folderLinkType: FolderLinkType;
parentFolderLinkId: string;
thumbUrl200: string;
thumbUrl500: string;
thumbUrl1000: string;
thumbUrl2000: string;
thumbnailUrls: {
'200': string;
'256': string;
'500': string;
'1000': string;
'2000': string;
};
Comment on lines +107 to +113
location: StelaLocation | null;
files: Array<StelaFile>;
createdAt: string;
Expand Down Expand Up @@ -171,10 +174,11 @@ export const convertStelaRecordToRecordVO = (
): RecordVO =>
new RecordVO({
...stelaRecord,
thumbURL200: stelaRecord.thumbUrl200,
thumbURL500: stelaRecord.thumbUrl500,
thumbURL1000: stelaRecord.thumbUrl1000,
thumbURL2000: stelaRecord.thumbUrl2000,
thumbURL200: stelaRecord.thumbnailUrls?.['200'],
thumbURL500: stelaRecord.thumbnailUrls?.['500'],
thumbURL1000: stelaRecord.thumbnailUrls?.['1000'],
thumbURL2000: stelaRecord.thumbnailUrls?.['2000'],
thumbnail256: stelaRecord.thumbnailUrls?.['256'],
Comment on lines +177 to +181
TagVOs: (stelaRecord.tags ?? []).map((stelaTag) =>
convertStelaTagToTagVO(stelaTag, stelaRecord.archiveId),
),
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/services/data/data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export class DataService {
if (
!item.isFolder &&
!item.thumbURL200 &&
!item.thumbnail256 &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just add a test for this change?

item.parentFolderId === this.currentFolder.folderId
) {
Comment on lines 253 to 258
this.debug('thumbRefreshQueue push %s', item.archiveNbr);
Expand Down