@@ -92,14 +92,20 @@ class ParseConfig {
92
92
/**
93
93
* Save value keys to the server.
94
94
* @static
95
+ * @param {Object } attrs The config parameters and values.
96
+ * @param {Object } masterKeyOnlyFlags The flags that define whether config parameters listed
97
+ * in `attrs` should be retrievable only by using the master key.
98
+ * For example: `param1: true` makes `param1` only retrievable by using the master key.
99
+ * If a parameter is not provided or set to `false`, it can be retrieved without
100
+ * using the master key.
95
101
* @return {Promise } A promise that is resolved with a newly-created
96
102
* configuration object or with the current with the update.
97
103
*/
98
- static save ( attrs : { [ key : string ] : any } , masterKeyOnly : { [ key : string ] : any } ) {
104
+ static save ( attrs : { [ key : string ] : any } , masterKeyOnlyFlags : { [ key : string ] : any } ) {
99
105
const controller = CoreManager . getConfigController ( ) ;
100
106
//To avoid a mismatch with the local and the cloud config we get a new version
101
- return controller . save ( attrs , masterKeyOnly ) . then ( ( ) => {
102
- return controller . get ( ) ;
107
+ return controller . save ( attrs , masterKeyOnlyFlags ) . then ( ( ) => {
108
+ return controller . get ( { useMasterKey : true } ) ;
103
109
} , ( error ) => {
104
110
return Promise . reject ( error ) ;
105
111
} ) ;
@@ -184,20 +190,16 @@ const DefaultController = {
184
190
} ) ;
185
191
} ,
186
192
187
- save ( attrs : { [ key : string ] : any } , masterKeyOnly : { [ key : string ] : any } ) {
193
+ save ( attrs : { [ key : string ] : any } , masterKeyOnlyFlags : { [ key : string ] : any } ) {
188
194
const RESTController = CoreManager . getRESTController ( ) ;
189
195
const encodedAttrs = { } ;
190
- const encodedMasterKeyOnly = { } ;
191
196
for ( const key in attrs ) {
192
197
encodedAttrs [ key ] = encode ( attrs [ key ] )
193
198
}
194
- for ( const key in masterKeyOnly ) {
195
- encodedMasterKeyOnly [ key ] = encode ( masterKeyOnly [ key ] )
196
- }
197
199
return RESTController . request (
198
200
'PUT' ,
199
201
'config' ,
200
- { params : encodedAttrs , masterKeyOnly : encodedMasterKeyOnly } ,
202
+ { params : encodedAttrs , masterKeyOnly : masterKeyOnlyFlags } ,
201
203
{ useMasterKey : true }
202
204
) . then ( response => {
203
205
if ( response && response . result ) {
0 commit comments