Fix relative to unsplash service

This commit is contained in:
Joris Bertomeu
2024-11-19 16:03:07 +01:00
parent bbd4649bc2
commit fd0b1395f7

View File

@@ -1,9 +1,9 @@
import { generatePictureFilename } from '../utils/helper.js'; import { generatePictureFilename } from '../utils/helper.js';
import { UnsplashService } from './UnsplashService.js';
export class PhotoService { export class PhotoService {
constructor(fileService, unsplashService) { constructor(fileService) {
this.fileService = fileService; this.fileService = fileService;
this.unsplashService = unsplashService;
} }
async pickPictureFromFile(collections = [], burnPic = true) { async pickPictureFromFile(collections = [], burnPic = true) {
@@ -22,9 +22,10 @@ export class PhotoService {
return pic; return pic;
} }
const newPics = await UnsplashService.getRandomPhotos(collections);
const newPics = await this.unsplashService.getRandomPhotos(collections); if (newPics.length === 0) {
if (newPics.length === 0) return null; return null;
}
this.fileService.writeJsonFile(filename, newPics); this.fileService.writeJsonFile(filename, newPics);
return newPics[0]; return newPics[0];