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

Commit

Permalink
core: move GET request to api.thrill function
Browse files Browse the repository at this point in the history
- avoid making a get request while retrying to take a picture

Change-Id: Ie59ec8cfc7687dd3558d7b101e51c94e77130cff
  • Loading branch information
andi34 committed Jan 12, 2022
1 parent 396ed2e commit 72ecae6
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ const photoBooth = (function () {
loader.addClass('open');

api.startCountdown(nextCollageNumber ? config.collage.cntdwn_time : config.picture.cntdwn_time, counter, () => {
if (config.get_request.countdown) {
api.getRequest(photoStyle);
}
api.cheese(photoStyle);
});
};
Expand Down Expand Up @@ -920,22 +923,23 @@ const photoBooth = (function () {
$('#mail-form-message').html('');
};

// GET Request
api.getRequest = function (photoStyle) {
const getMode =
photoStyle === 'photo' || photoStyle === 'chroma' ? config.get_request.picture : config.get_request.collage;
const getUrl = config.get_request.server + '/' + getMode;
const request = new XMLHttpRequest();
photoboothTools.console.log('Sending GET request to: ' + getUrl);
request.open('GET', getUrl);
request.send();
};

// Countdown Function
api.startCountdown = function (start, element, cb) {
let count = 0;
let current = start;
const stop = start > 2 ? start - 2 : start;

if (config.get_request.countdown) {
const getMode =
start === config.picture.cntdwn_time ? config.get_request.picture : config.get_request.collage;
const getUrl = config.get_request.server + '/' + getMode;
const request = new XMLHttpRequest();
photoboothTools.console.log('Sending GET request to: ' + getUrl);
request.open('GET', getUrl);
request.send();
}

function timerFunction() {
element.text(Number(current) + Number(config.picture.cntdwn_offset));
current--;
Expand Down

0 comments on commit 72ecae6

Please sign in to comment.