debounce for update requests

This commit is contained in:
lotte
2020-09-04 14:44:00 +02:00
parent 90f0597baa
commit d4027cc1d1
3 changed files with 25 additions and 19 deletions

View File

@@ -18,10 +18,13 @@ $footer-logo-height: 55px;
height: $footer-logo-height;
}
ul li {
ul {
padding-top: $spacer * 0.5;
li {
display: inline-flex;
a {
padding: 0 $spacer/2;
color: inherit
}
@@ -29,9 +32,9 @@ $footer-logo-height: 55px;
&:after {
content: '';
border-right: 1px map-get($theme-colors, secondary) solid;
margin: 0 $spacer/2;
}
}
}
}
}

View File

@@ -7,18 +7,13 @@ import { environment } from '../../../environments/environment';
import { switchMap, take } from 'rxjs/operators';
import { EPerson } from '../../core/eperson/models/eperson.model';
import { KlaroService } from './klaro.service';
import { hasValue, isEmpty, isNotEmpty } from '../empty.util';
import { hasValue, isNotEmpty } from '../empty.util';
import { CookieService } from '../../core/services/cookie.service';
import { EPersonDataService } from '../../core/eperson/eperson-data.service';
import { cloneDeep } from 'lodash';
import { cloneDeep, debounce } from 'lodash';
import { ANONYMOUS_STORAGE_NAME_KLARO, klaroConfiguration } from './klaro-configuration';
import { Operation } from 'fast-json-patch';
/**
* Cookie for has_agreed_end_user
*/
export const HAS_AGREED_END_USER = 'dsHasAgreedEndUser';
/**
* Metadata field to store a user's cookie consent preferences in
*/
@@ -39,6 +34,10 @@ const cookieDescriptionMessagePrefix = 'cookies.consent.app.description.';
*/
const cookiePurposeMessagePrefix = 'cookies.consent.purpose.';
/**
* Update request debounce in ms
*/
const updateDebounce = 300;
/**
* Browser implementation for the KlaroService, representing a service for handling Klaro consent preferences and UI
*/
@@ -100,7 +99,7 @@ export class BrowserKlaroService extends KlaroService {
* @param user The authenticated user
*/
private initializeUser(user: EPerson) {
this.klaroConfig.callback = (consent, app) => this.updateSettingsForUsers(user);
this.klaroConfig.callback = debounce((consent, app) => this.updateSettingsForUsers(user), updateDebounce);
this.klaroConfig.storageName = this.getStorageName(user.uuid);
const anonCookie = this.cookieService.get(ANONYMOUS_STORAGE_NAME_KLARO);

View File

@@ -1,7 +1,11 @@
import { TOKENITEM } from '../../core/auth/models/auth-token-info.model';
import { IMPERSONATING_COOKIE, REDIRECT_COOKIE } from '../../core/auth/auth.service';
import { LANG_COOKIE } from '../../core/locale/locale.service';
import { HAS_AGREED_END_USER } from './browser-klaro.service';
/**
* Cookie for has_agreed_end_user
*/
export const HAS_AGREED_END_USER = 'dsHasAgreedEndUser';
/**
* Storage name used to store klaro cookie