Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit eae2bbb

Browse files
committed
core: add retry check to api.cheese function
- on retry we only need the cheese message again, save some lines of code Change-Id: I21f89d3e8deb0c649e1793cf86678cc8481e454c
1 parent 72ecae6 commit eae2bbb

File tree

1 file changed

+22
-31
lines changed

1 file changed

+22
-31
lines changed

src/js/core.js

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ const photoBooth = (function () {
320320
};
321321

322322
// Cheese
323-
api.cheese = function (photoStyle) {
323+
api.cheese = function (photoStyle, retry = 0) {
324324
photoboothTools.console.logDev('Photostyle: ' + photoStyle);
325325

326326
counter.empty();
@@ -339,27 +339,29 @@ const photoBooth = (function () {
339339
.appendTo('.cheese');
340340
}
341341

342-
if (config.preview.mode === 'gphoto' && !config.picture.no_cheese) {
343-
api.stopPreviewVideo();
344-
}
342+
if (retry <= 0) {
343+
if (config.preview.mode === 'gphoto' && !config.picture.no_cheese) {
344+
api.stopPreviewVideo();
345+
}
345346

346-
if (
347-
config.preview.mode === 'device_cam' &&
348-
config.preview.camTakesPic &&
349-
!api.stream &&
350-
!config.dev.demo_images
351-
) {
352-
photoboothTools.console.log('No preview by device cam available!');
347+
if (
348+
config.preview.mode === 'device_cam' &&
349+
config.preview.camTakesPic &&
350+
!api.stream &&
351+
!config.dev.demo_images
352+
) {
353+
photoboothTools.console.log('No preview by device cam available!');
353354

354-
api.errorPic({
355-
error: 'No preview by device cam available!'
356-
});
357-
} else if (config.picture.no_cheese) {
358-
api.takePic(photoStyle);
359-
} else {
360-
setTimeout(() => {
355+
api.errorPic({
356+
error: 'No preview by device cam available!'
357+
});
358+
} else if (config.picture.no_cheese) {
361359
api.takePic(photoStyle);
362-
}, config.picture.cheese_time);
360+
} else {
361+
setTimeout(() => {
362+
api.takePic(photoStyle);
363+
}, config.picture.cheese_time);
364+
}
363365
}
364366
};
365367

@@ -435,23 +437,12 @@ const photoBooth = (function () {
435437
);
436438
api.startCountdown(config.picture.retry_timeout, counter, () => {
437439
loading.empty();
438-
counter.empty();
439-
cheese.empty();
440440

441441
if (config.picture.no_cheese) {
442442
photoboothTools.console.log('Cheese is disabled.');
443443
api.callTakePicApi(data, retry);
444444
} else {
445-
if (data.style === 'photo' || data.style === 'chroma') {
446-
const cheesemsg = photoboothTools.getTranslation('cheese');
447-
cheese.text(cheesemsg);
448-
} else {
449-
const cheesemsg = photoboothTools.getTranslation('cheeseCollage');
450-
cheese.text(cheesemsg);
451-
$('<p>')
452-
.text(`${nextCollageNumber + 1} / ${config.collage.limit}`)
453-
.appendTo('.cheese');
454-
}
445+
api.cheese(data.style, retry);
455446
setTimeout(() => {
456447
api.callTakePicApi(data, retry);
457448
}, config.picture.cheese_time);

0 commit comments

Comments
 (0)