Skip to content

Commit

Permalink
Merge pull request #878 from City-of-Helsinki/UHF-11208
Browse files Browse the repository at this point in the history
UHF-11208: wait for the cookies
  • Loading branch information
rpnykanen authored Jan 7, 2025
2 parents 812b8a2 + 81ff666 commit b55b2bd
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions assets/js/chat_leijuke.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,29 @@
class EuCookieManager {
cookieCheck(cookieNames) {
let cookiesOk = true;
cookieNames.map((cookieName) => {
if (!Drupal.cookieConsent.getConsentStatus([cookieName])) cookiesOk = false;
});

// If cookies are not available yet, wait for a while.
if (Drupal.cookieConsent.getConsentStatus(cookieNames) === undefined) {
let i = 0;

const interval = setInterval(()=> {
let found = false;
cookieNames.map((cookieName) => {
found = Drupal.cookieConsent.getConsentStatus([cookieName]) || false;
});

if (i >= 3 || found) {
cookiesOk = found;
clearInterval(interval);
}
i++;
}, 1000)
} else {
cookieNames.map((cookieName) => {
if (!Drupal.cookieConsent.getConsentStatus([cookieName])) cookiesOk = false;
});
}

return cookiesOk;
}
cookieSet() {
Expand Down

0 comments on commit b55b2bd

Please sign in to comment.