@@ -2,13 +2,14 @@ import { Injectable } from '@angular/core';
22import { Observable , of , switchMap } from 'rxjs' ;
33import { map , take } from 'rxjs/operators' ;
44import { CookieService } from '../core/services/cookie.service' ;
5- import { hasValue , isNotEmpty , isNotEmptyOperator } from '../shared/empty.util' ;
5+ import { hasValue , isNotEmpty } from '../shared/empty.util' ;
66import { AuthService } from '../core/auth/auth.service' ;
77import { EPerson } from '../core/eperson/models/eperson.model' ;
88import { EPersonDataService } from '../core/eperson/eperson-data.service' ;
99import { getFirstCompletedRemoteData } from '../core/shared/operators' ;
1010import cloneDeep from 'lodash/cloneDeep' ;
1111import { environment } from '../../environments/environment' ;
12+ import { createSuccessfulRemoteDataObject$ } from '../shared/remote-data.utils' ;
1213
1314/**
1415 * Name of the cookie used to store the settings locally
@@ -198,8 +199,8 @@ export class AccessibilitySettingsService {
198199
199200 return this . ePersonService . createPatchFromCache ( user ) . pipe (
200201 take ( 1 ) ,
201- isNotEmptyOperator ( ) ,
202- switchMap ( operations => this . ePersonService . patch ( user , operations ) ) ,
202+ switchMap ( operations =>
203+ isNotEmpty ( operations ) ? this . ePersonService . patch ( user , operations ) : createSuccessfulRemoteDataObject$ ( { } ) ) ,
203204 getFirstCompletedRemoteData ( ) ,
204205 map ( rd => rd . hasSucceeded ) ,
205206 ) ;
@@ -216,6 +217,15 @@ export class AccessibilitySettingsService {
216217 }
217218 }
218219
220+ /**
221+ * Clears all settings in the cookie and attempts to clear settings in metadata.
222+ * Emits true if settings in metadata were cleared and false otherwise.
223+ */
224+ clearSettings ( ) : Observable < boolean > {
225+ this . setSettingsInCookie ( { } ) ;
226+ return this . setSettingsInAuthenticatedUserMetadata ( { } ) ;
227+ }
228+
219229 getPlaceholder ( setting : AccessibilitySetting ) : string {
220230 switch ( setting ) {
221231 case AccessibilitySetting . NotificationTimeOut :
0 commit comments