Skip to content

Commit 8b2afad

Browse files
committed
added docs; removed unnecessary encoding
1 parent aaa34db commit 8b2afad

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/ParseConfig.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,20 @@ class ParseConfig {
9292
/**
9393
* Save value keys to the server.
9494
* @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.
95101
* @return {Promise} A promise that is resolved with a newly-created
96102
* configuration object or with the current with the update.
97103
*/
98-
static save(attrs: { [key: string]: any }, masterKeyOnly: { [key: string]: any }) {
104+
static save(attrs: { [key: string]: any }, masterKeyOnlyFlags: { [key: string]: any }) {
99105
const controller = CoreManager.getConfigController();
100106
//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});
103109
},(error) => {
104110
return Promise.reject(error);
105111
});
@@ -184,20 +190,16 @@ const DefaultController = {
184190
});
185191
},
186192

187-
save(attrs: { [key: string]: any }, masterKeyOnly: { [key: string]: any }) {
193+
save(attrs: { [key: string]: any }, masterKeyOnlyFlags: { [key: string]: any }) {
188194
const RESTController = CoreManager.getRESTController();
189195
const encodedAttrs = {};
190-
const encodedMasterKeyOnly = {};
191196
for(const key in attrs){
192197
encodedAttrs[key] = encode(attrs[key])
193198
}
194-
for(const key in masterKeyOnly){
195-
encodedMasterKeyOnly[key] = encode(masterKeyOnly[key])
196-
}
197199
return RESTController.request(
198200
'PUT',
199201
'config',
200-
{ params: encodedAttrs, masterKeyOnly: encodedMasterKeyOnly },
202+
{ params: encodedAttrs, masterKeyOnly: masterKeyOnlyFlags },
201203
{ useMasterKey: true }
202204
).then(response => {
203205
if(response && response.result){

0 commit comments

Comments
 (0)