From 0fafa074068e6fccdbd0dccd7d32e4fdc68541e6 Mon Sep 17 00:00:00 2001 From: Phill Date: Sun, 23 Jun 2019 16:40:24 +0100 Subject: [PATCH 01/12] Merged v1.0.22 --- example/lib/domain/constants/application_constants.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/example/lib/domain/constants/application_constants.dart b/example/lib/domain/constants/application_constants.dart index 6b74994a9..01491a0dc 100644 --- a/example/lib/domain/constants/application_constants.dart +++ b/example/lib/domain/constants/application_constants.dart @@ -1,4 +1,4 @@ -const String keyApplicationName = 'BodyCal'; -const String keyParseApplicationId = 'bodycaldb'; -const String keyParseMasterKey = '343gf35g4t6hev445f4t5f45g45d'; -const String keyParseServerUrl = 'http://45.76.129.16:1338/parse/'; +const String keyApplicationName = ''; +const String keyParseApplicationId = ''; +const String keyParseMasterKey = ''; +const String keyParseServerUrl = ''; From 8a15ee05a1bfb915a484240c640f7ed4280cc41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=90=A7=E7=8E=89?= Date: Tue, 2 Jul 2019 12:37:22 +0800 Subject: [PATCH 02/12] 1. Fix return result from save method. This is important. (#208) 2. Fix unsavedChanges issue in ParseUser login and signUp method. 3. Delete useless and reduplicative decode in ParseUser. Because this is already done in handleResponse method. This also cause wrong unsaved changes. --- lib/src/objects/parse_object.dart | 1 + lib/src/objects/parse_user.dart | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/src/objects/parse_object.dart b/lib/src/objects/parse_object.dart index d23d6127a..2c790c2c8 100644 --- a/lib/src/objects/parse_object.dart +++ b/lib/src/objects/parse_object.dart @@ -108,6 +108,7 @@ class ParseObject extends ParseBase implements ParseCloneable { else { _revertSavingChanges(); } + return response; } } return childrenResponse; diff --git a/lib/src/objects/parse_user.dart b/lib/src/objects/parse_user.dart index 3da6d4496..f2b99e2f5 100644 --- a/lib/src/objects/parse_user.dart +++ b/lib/src/objects/parse_user.dart @@ -136,11 +136,13 @@ class ParseUser extends ParseObject implements ParseCloneable { bodyData[keyVarPassword] = password; bodyData[keyVarUsername] = username; final Uri url = getSanitisedUri(_client, '$path'); + final String body = json.encode(bodyData); + _saveChanges(); final Response response = await _client.post(url, headers: { keyHeaderRevocableSession: '1', }, - body: json.encode(bodyData)); + body: body); return _handleResponse( this, response, ParseApiRQ.signUp, _debug, parseClassName); @@ -162,7 +164,7 @@ class ParseUser extends ParseObject implements ParseCloneable { final Uri url = getSanitisedUri(_client, '$keyEndPointLogin', queryParams: queryParams); - + _saveChanges(); final Response response = await _client.get(url, headers: { keyHeaderRevocableSession: '1', @@ -356,7 +358,6 @@ class ParseUser extends ParseObject implements ParseCloneable { final Map responseData = jsonDecode(response.body); if (responseData.containsKey(keyVarObjectId)) { - parseResponse.result.fromJson(responseData); user.sessionToken = responseData[keyParamSessionToken]; ParseCoreData().setSessionId(user.sessionToken); } From 68b4c62ae26b5ca6c436633d152a81983b2df47e Mon Sep 17 00:00:00 2001 From: Phill Wiggins Date: Thu, 4 Jul 2019 08:22:07 +0100 Subject: [PATCH 03/12] README.md updated from https://stackedit.io/ --- README.md | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 8c6cd9020..139ea04d9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + ![enter image description here](https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png) ![enter image description here](https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png?fit=200%2C200&ssl=1&resize=350%2C200) @@ -15,7 +16,7 @@ Want to get involved? Join our Slack channel and help out! (http://flutter-parse To install, either add to your pubspec.yaml ```yml dependencies: - parse_server_sdk: ^1.0.22 + parse_server_sdk: ^1.0.2 ``` or clone this repository and add to your project. As this is an early development with multiple contributors, it is probably best to download/clone and keep updating as an when a new feature is added. @@ -24,30 +25,33 @@ Once you have the library added to your project, upon first call to your app (Si ```dart await Parse().initialize( - ApplicationConstants.keyApplicationId, - ApplicationConstants.keyParseServerUrl); + keyApplicationId, + keyParseServerUrl); ``` if you want to use secure storage also that's allow using sdk on desktop application ```dart - await Parse().initialize(keyParseApplicationId, keyParseServerUrl, - masterKey: keyParseMasterKey, - debug: true, - coreStore: await CoreStoreSembastImp.getInstance()); +await Parse().initialize( + keyParseApplicationId, + keyParseServerUrl, + coreStore: await CoreStoreSembastImp.getInstance()); ``` It's possible to add other params, such as ... ```dart await Parse().initialize( - ApplicationConstants.keyApplicationId, - ApplicationConstants.keyParseServerUrl, - masterKey: ApplicationConstants.keyParseMasterKey, - clientKey: ApplicationConstants.keyParseClientKey, - debug: true, - liveQueryUrl: ApplicationConstants.keyLiveQueryUrl, - autoSendSessionId: true, - securityContext: securityContext, + keyApplicationId, + keyParseServerUrl, + masterKey: coreStore: await CoreStoreSharedPrefsImp.getInstance()); + cityConttserCnte,etre: atendSessionId: true,keyParseMasterKey, // Required for Back4App and others + clientKey: keyParseClientKey, // Required for some setups + debug: true, // When enabled, prints logs to console + liveQueryUrl: keyLiveQueryUrl, // Required if using LiveQuery + autoSCoetoeSe // Some confurations require this to be true + dresetnstne, + // Again, required for some setups + coreStore: await CoreStoreSharedPrefsImp.getInstance()); // Will use SharedPreferences instead of Sembast as an internal DB ``` ## Objects @@ -587,3 +591,7 @@ This project was authored by Phill Wiggins. You can contact me at phill.wiggins@ + + \ No newline at end of file From efba177c362966dbb2fa8bb2b596d96a8d8df952 Mon Sep 17 00:00:00 2001 From: Phill Wiggins Date: Thu, 4 Jul 2019 08:23:41 +0100 Subject: [PATCH 04/12] README.md updated from https://stackedit.io/ --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 139ea04d9..a194c923d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Once you have the library added to your project, upon first call to your app (Si keyApplicationId, keyParseServerUrl); ``` -if you want to use secure storage also that's allow using sdk on desktop application +if you want to use secure storage or use the Flutter web/desktop SDK, please change to the below instance of CoreStorage as it has no dependencies on Flutter. ```dart await Parse().initialize( @@ -36,7 +36,7 @@ await Parse().initialize( keyParseServerUrl, coreStore: await CoreStoreSembastImp.getInstance()); ``` -It's possible to add other params, such as ... +It's possible to add other parameters to work with your instance of Parse Server:- ```dart await Parse().initialize( @@ -593,5 +593,5 @@ eyJoaXN0b3J5IjpbLTU4MDA4MDUwNCw3MTg2NTA0MjBdfQ== --> \ No newline at end of file From 9480d0d0236b6a0b480d996abebb3d1113da1a52 Mon Sep 17 00:00:00 2001 From: Phill Wiggins Date: Thu, 4 Jul 2019 08:25:15 +0100 Subject: [PATCH 05/12] README.md updated from https://stackedit.io/ --- README.md | 70 ++++++++++++++----------------------------------------- 1 file changed, 18 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index a194c923d..0ead7b5a7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,5 @@ -![enter image description here](https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png) -![enter image description here](https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png?fit=200%2C200&ssl=1&resize=350%2C200) - -[![Build Status](https://travis-ci.org/phillwiggins/flutter_parse_sdk.svg?branch=master)](https://travis-ci.org/phillwiggins/flutter_parse_sdk) +![enter image description here](https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png)![enter image description here](https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png?fit=200%2C200&ssl=1&resize=350%2C200) ## Parse For Flutter! Hi, this is a Flutter plugin that allows communication with a Parse Server, (https://parseplatform.org) either hosted on your own server or another, like (http://Back4App.com). @@ -16,7 +13,7 @@ Want to get involved? Join our Slack channel and help out! (http://flutter-parse To install, either add to your pubspec.yaml ```yml dependencies: - parse_server_sdk: ^1.0.2 + parse_server_sdk: ^1.0.22 ``` or clone this repository and add to your project. As this is an early development with multiple contributors, it is probably best to download/clone and keep updating as an when a new feature is added. @@ -24,11 +21,12 @@ or clone this repository and add to your project. As this is an early developmen Once you have the library added to your project, upon first call to your app (Similar to what your application class would be) add the following... ```dart - await Parse().initialize( +await Parse().initialize( keyApplicationId, keyParseServerUrl); ``` -if you want to use secure storage or use the Flutter web/desktop SDK, please change to the below instance of CoreStorage as it has no dependencies on Flutter. + +If you want to use secure storage or use the Flutter web/desktop SDK, please change to the below instance of CoreStorage as it has no dependencies on Flutter. ```dart await Parse().initialize( @@ -39,22 +37,17 @@ await Parse().initialize( It's possible to add other parameters to work with your instance of Parse Server:- ```dart - await Parse().initialize( - keyApplicationId, - keyParseServerUrl, +Parse().initialize( + ApplicationConstants.keyApplicationId, + ApplicationConstants.keyParseServerUrl, masterKey: coreStore: await CoreStoreSharedPrefsImp.getInstance()); - cityConttserCnte,etre: atendSessionId: true,keyParseMasterKey, // Required for Back4App and others - clientKey: keyParseClientKey, // Required for some setups - debug: true, // When enabled, prints logs to console - liveQueryUrl: keyLiveQueryUrl, // Required if using LiveQuery - autoSCoetoeSe // Some confurations require this to be true - dresetnstne, - // Again, required for some setups - coreStore: await CoreStoreSharedPrefsImp.getInstance()); // Will use SharedPreferences instead of Sembast as an internal DB -``` - -## Objects + cityConttserCnte,etre: atendSessionId: true,ApplicationConstants.keyParseMasterKey, + clientKey: ApplicationConstants.keyParseClientKey, + debug: true, + liveQueryUrl: ApplicationConstants.keyLiveQueryUrl, + autoSCoetoeSe + dresetnstne); // Wi## Objects You can create custom objects by calling: ```dart var dietPlan = ParseObject('DietPlan') @@ -138,14 +131,6 @@ and to retrieve it var dietPlan = DietPlan().fromPin('OBJECT ID OF OBJECT'); ``` -## Storage -We now have 2 types of storage, secure and unsecure. We currently rely on 2 third party options: - - * SharedPreferences - * Sembast - -Sembast offers secured storage, whilst SharePreferences wraps NSUserDefaults (on iOS) and SharedPreferences (on Android). - ## Increment Counter values in objects Retrieve it, call @@ -176,9 +161,9 @@ var response = await dietPlan.remove("listKeywords", ["a"]); or using with save function ```dart -dietPlan.setAddAll('listKeywords', ['a','a','d']); -dietPlan.setAddAllUnique('listKeywords', ['a','a','d']); -dietPlan.setRemoveAll('listKeywords', ['a']); +dietPlan.setAdd('listKeywords', ['a','a','d']); +dietPlan.setAddUnique('listKeywords', ['a','a','d']); +dietPlan.setRemove('listKeywords', ['a']); var response = dietPlan.save() ``` @@ -552,21 +537,6 @@ final Map params = {'plan': 'paid'}; function.execute(parameters: params); ``` -## Relation -The SDK supports Relation. - -To Retrive a relation instance for user, call: -```dart -final relation = user.getRelation('dietPlans'); -``` - -and then you can add a relation to the passed in object. - -```dart -relation.add(dietPlan); -final result = await user.save(); -``` - ## Other Features of this library Main: * Installation (View the example application) @@ -589,9 +559,5 @@ Objects: ## Author:- This project was authored by Phill Wiggins. You can contact me at phill.wiggins@gmail.com - - \ No newline at end of file From cd7c192562ce090e9387b2adb14de5daf2a1a7c2 Mon Sep 17 00:00:00 2001 From: Phill Wiggins Date: Thu, 4 Jul 2019 08:26:48 +0100 Subject: [PATCH 06/12] README.md updated from https://stackedit.io/ --- README.md | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0ead7b5a7..69e243499 100644 --- a/README.md +++ b/README.md @@ -37,17 +37,19 @@ await Parse().initialize( It's possible to add other parameters to work with your instance of Parse Server:- ```dart -Parse().initialize( - ApplicationConstants.keyApplicationId, - ApplicationConstants.keyParseServerUrl, - masterKey: - coreStore: await CoreStoreSharedPrefsImp.getInstance()); - cityConttserCnte,etre: atendSessionId: true,ApplicationConstants.keyParseMasterKey, - clientKey: ApplicationConstants.keyParseClientKey, - debug: true, - liveQueryUrl: ApplicationConstants.keyLiveQueryUrl, - autoSCoetoeSe - dresetnstne); // Wi## Objects + await Parse().initialize( + keyApplicationId, + keyParseServerUrl, + masterKey: keyParseMasterKey, // Required for Back4App and others + clientKey: keyParseClientKey, // Required for some setups + debug: true, // When enabled, prints logs to console + liveQueryUrl: keyLiveQueryUrl, // Required if using LiveQuery + autoSendSessionId: true, // Some confurations require this to be true + securityContext: securityContext, // Again, required for some setups + coreStore: await CoreStoreSharedPrefsImp.getInstance()); // Will use SharedPreferences instead of Sembast as an internal DB +``` + +## Objects You can create custom objects by calling: ```dart var dietPlan = ParseObject('DietPlan') @@ -559,5 +561,5 @@ Objects: ## Author:- This project was authored by Phill Wiggins. You can contact me at phill.wiggins@gmail.com \ No newline at end of file From 400d29759b8c8788fe6b85cedd8f044cbb767ea6 Mon Sep 17 00:00:00 2001 From: Phill Wiggins Date: Thu, 4 Jul 2019 08:28:24 +0100 Subject: [PATCH 07/12] README.md updated from https://stackedit.io/ --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 69e243499..10bc6a932 100644 --- a/README.md +++ b/README.md @@ -55,13 +55,13 @@ You can create custom objects by calling: var dietPlan = ParseObject('DietPlan') ..set('Name', 'Ketogenic') ..set('Fat', 65); -await dietPlan.save() +await dietPlan.save(); ``` Verify that the object has been successfully saved using ```dart var response = await dietPlan.save(); if (response.success) { - dietPlan = response.result; + dietPlan = response.results.first; } ``` Types supported: @@ -205,7 +205,7 @@ var queryBuilder = QueryBuilder(DietPlan()) var response = await queryBuilder.query(); if (response.success) { - print(ApplicationConstants.keyAppName + ": " + ((response.result as List).first as DietPlan).toString()); + print(ApplicationConstants.keyAppName + ": " + ((response.results as List).first as DietPlan).toString()); } else { print(ApplicationConstants.keyAppName + ": " + response.exception.message); } @@ -295,11 +295,11 @@ The Parse Server configuration guide on the server is found here https://docs.pa Initialize the Parse Live Query by entering the parameter liveQueryUrl in Parse().initialize: ```dart Parse().initialize( - ApplicationConstants.keyApplicationId, - ApplicationConstants.keyParseServerUrl, - clientKey: ApplicationConstants.keyParseClientKey, + keyApplicationId, + keyParseServerUrl, + clientKey: keyParseClientKey, debug: true, - liveQueryUrl: ApplicationConstants.keyLiveQueryUrl, + liveQueryUrl: keyLiveQueryUrl, autoSendSessionId: true); ``` @@ -561,5 +561,5 @@ Objects: ## Author:- This project was authored by Phill Wiggins. You can contact me at phill.wiggins@gmail.com \ No newline at end of file From ba17643f27820010494f55cf79ce9006daf997f3 Mon Sep 17 00:00:00 2001 From: Phill Wiggins Date: Thu, 4 Jul 2019 08:28:42 +0100 Subject: [PATCH 08/12] Update README.md --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 10bc6a932..f174b36e9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -![enter image description here](https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png)![enter image description here](https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png?fit=200%2C200&ssl=1&resize=350%2C200) +![Parse Logo](https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png)![Flutter Logo](https://i2.wp.com/blog.openshift.com/wp-content/uploads/parse-server-logo-1.png?fit=200%2C200&ssl=1&resize=350%2C200) ## Parse For Flutter! Hi, this is a Flutter plugin that allows communication with a Parse Server, (https://parseplatform.org) either hosted on your own server or another, like (http://Back4App.com). @@ -560,6 +560,3 @@ Objects: ## Author:- This project was authored by Phill Wiggins. You can contact me at phill.wiggins@gmail.com - \ No newline at end of file From 79b3df9844ab9c287ed36585f25d74f38fa99d60 Mon Sep 17 00:00:00 2001 From: matskosan Date: Sat, 10 Aug 2019 19:53:55 +0200 Subject: [PATCH 09/12] Added some missing async/await (#248) * Updated dependencies. * ParseUser._handleResponse was calling saveInStorage() async without an await, which caused 'invalid session token' error if user ParseUser.currentUser() immediately after ParseUser.signUp() or ParseUser.login(). Added missing awaits in other places. * ParseUser was not updated in storage after a successful save() operation. Reason: no safeInStorage() after save() was called. Fix: calling saveInStorage() after save(). * Revert "Updated dependencies." This reverts commit dbbc5e830bbded10936bab3ae7f76030316a7553. --- lib/src/objects/parse_base.dart | 10 +++---- lib/src/objects/parse_installation.dart | 10 +++---- lib/src/objects/parse_user.dart | 38 +++++++++++++++---------- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/lib/src/objects/parse_base.dart b/lib/src/objects/parse_base.dart index 795f06391..424c3ee7a 100644 --- a/lib/src/objects/parse_base.dart +++ b/lib/src/objects/parse_base.dart @@ -45,6 +45,7 @@ abstract class ParseBase { if (value is ParseObject && value._areChildrenDirty(seenObjects)) { return true; } + return false; }); return false; } @@ -175,8 +176,7 @@ abstract class ParseBase { /// Saves in storage Future saveInStorage(String key) async { final String objectJson = json.encode(toJson(full: true)); - ParseCoreData().getStore() - ..setString(key, objectJson); + await ParseCoreData().getStore().setString(key, objectJson); } /// Sets type [T] from objectData @@ -240,8 +240,7 @@ abstract class ParseBase { await unpin(); final Map objectMap = parseEncode(this, full: true); final String json = jsonEncode(objectMap); - ParseCoreData().getStore() - ..setString(objectId, json); + await ParseCoreData().getStore().setString(objectId, json); return true; } else { return false; @@ -253,8 +252,7 @@ abstract class ParseBase { /// Replicates Android SDK pin process and saves object to storage Future unpin({String key}) async { if (objectId != null) { - ParseCoreData().getStore() - ..remove(key ?? objectId); + await ParseCoreData().getStore().remove(key ?? objectId); return true; } diff --git a/lib/src/objects/parse_installation.dart b/lib/src/objects/parse_installation.dart index dfec33f27..0f3a66145 100644 --- a/lib/src/objects/parse_installation.dart +++ b/lib/src/objects/parse_installation.dart @@ -127,7 +127,7 @@ class ParseInstallation extends ParseObject { /// Gets the locally stored installation static Future _getFromLocalStore() async { - final CoreStore coreStore = await ParseCoreData().getStore(); + final CoreStore coreStore = ParseCoreData().getStore(); final String installationJson = await coreStore.getString(keyParseStoreInstallation); @@ -204,17 +204,17 @@ class ParseInstallation extends ParseObject { } ///Subscribes the device to a channel of push notifications. - void subscribeToChannel(String value) { + Future subscribeToChannel(String value) async { final List channel = [value]; setAddAllUnique('channels', channel); - save(); + await save(); } ///Unsubscribes the device to a channel of push notifications. - void unsubscribeFromChannel(String value) { + Future unsubscribeFromChannel(String value) async { final List channel = [value]; setRemove('channels', channel); - save(); + await save(); } ///Returns an > containing all the channel names this device is subscribed to. diff --git a/lib/src/objects/parse_user.dart b/lib/src/objects/parse_user.dart index f2b99e2f5..05d574e48 100644 --- a/lib/src/objects/parse_user.dart +++ b/lib/src/objects/parse_user.dart @@ -100,7 +100,7 @@ class ParseUser extends ParseObject implements ParseCloneable { try { final Uri url = getSanitisedUri(_client, '$keyEndPointUserName'); final Response response = await _client.get(url, headers: headers); - return _handleResponse(_getEmptyUser(), response, ParseApiRQ.currentUser, + return await _handleResponse(_getEmptyUser(), response, ParseApiRQ.currentUser, _debug, _getEmptyUser().parseClassName); } on Exception catch (e) { return handleException( @@ -144,7 +144,7 @@ class ParseUser extends ParseObject implements ParseCloneable { }, body: body); - return _handleResponse( + return await _handleResponse( this, response, ParseApiRQ.signUp, _debug, parseClassName); } on Exception catch (e) { return handleException(e, ParseApiRQ.signUp, _debug, parseClassName); @@ -170,7 +170,7 @@ class ParseUser extends ParseObject implements ParseCloneable { keyHeaderRevocableSession: '1', }); - return _handleResponse( + return await _handleResponse( this, response, ParseApiRQ.login, _debug, parseClassName); } on Exception catch (e) { return handleException(e, ParseApiRQ.login, _debug, parseClassName); @@ -193,7 +193,7 @@ class ParseUser extends ParseObject implements ParseCloneable { } })); - return _handleResponse( + return await _handleResponse( this, response, ParseApiRQ.loginAnonymous, _debug, parseClassName); } on Exception catch (e) { return handleException( @@ -220,7 +220,7 @@ class ParseUser extends ParseObject implements ParseCloneable { 'authData': {provider: authData} })); - return _handleResponse( + return await _handleResponse( this, response, ParseApiRQ.loginWith, _debug, parseClassName); } on Exception catch (e) { return handleException(e, ParseApiRQ.loginWith, _debug, parseClassName); @@ -246,7 +246,7 @@ class ParseUser extends ParseObject implements ParseCloneable { final Response response = await _client.post(url, headers: {keyHeaderSessionToken: sessionId}); - return _handleResponse( + return await _handleResponse( this, response, ParseApiRQ.logout, _debug, parseClassName); } on Exception catch (e) { return handleException(e, ParseApiRQ.logout, _debug, parseClassName); @@ -259,7 +259,7 @@ class ParseUser extends ParseObject implements ParseCloneable { final Response response = await _client.post( '${_client.data.serverUrl}$keyEndPointVerificationEmail', body: json.encode({keyVarEmail: emailAddress})); - return _handleResponse(this, response, + return await _handleResponse(this, response, ParseApiRQ.verificationEmailRequest, _debug, parseClassName); } on Exception catch (e) { return handleException( @@ -273,7 +273,7 @@ class ParseUser extends ParseObject implements ParseCloneable { final Response response = await _client.post( '${_client.data.serverUrl}$keyEndPointRequestPasswordReset', body: json.encode({keyVarEmail: emailAddress})); - return _handleResponse( + return await _handleResponse( this, response, ParseApiRQ.requestPasswordReset, _debug, parseClassName); } on Exception catch (e) { @@ -289,19 +289,27 @@ class ParseUser extends ParseObject implements ParseCloneable { @override Future save() async { if (objectId == null) { - return signUp(); + return await signUp(); } else { - return super.save(); + final ParseResponse response = await super.save(); + if (response.success) { + await _onResponseSuccess(); + } + return response; } } + Future _onResponseSuccess() async { + await saveInStorage(keyParseStoreUser); + } + /// Removes a user from Parse Server locally and online Future destroy() async { if (objectId != null) { try { final Uri url = getSanitisedUri(_client, '$_path/$objectId'); final Response response = await _client.delete(url); - return _handleResponse( + return await _handleResponse( this, response, ParseApiRQ.destroy, _debug, parseClassName); } on Exception catch (e) { return handleException(e, ParseApiRQ.destroy, _debug, parseClassName); @@ -334,7 +342,7 @@ class ParseUser extends ParseObject implements ParseCloneable { static Future _getUserFromLocalStore( {ParseCloneable cloneable}) async { - final CoreStore coreStore = await ParseCoreData().getStore(); + final CoreStore coreStore = ParseCoreData().getStore(); final String userJson = await coreStore.getString(keyParseStoreUser); if (userJson != null) { @@ -351,8 +359,8 @@ class ParseUser extends ParseObject implements ParseCloneable { } /// Handles all the response data for this class - static ParseResponse _handleResponse(ParseUser user, Response response, - ParseApiRQ type, bool debug, String className) { + static Future _handleResponse(ParseUser user, Response response, + ParseApiRQ type, bool debug, String className) async { final ParseResponse parseResponse = handleResponse(user, response, type, debug, className); @@ -371,7 +379,7 @@ class ParseUser extends ParseObject implements ParseCloneable { return parseResponse; } else { final ParseUser user = parseResponse.result; - user?.saveInStorage(keyParseStoreUser); + await user?._onResponseSuccess(); return parseResponse; } } From e2fbe87d89b35d349fe714bbfd7635d0d3aadd73 Mon Sep 17 00:00:00 2001 From: Oleksandr Matsko Date: Wed, 14 Aug 2019 07:25:46 +0200 Subject: [PATCH 10/12] forceUpdate was ignored when setting ParseBase properties --- lib/src/objects/parse_base.dart | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/src/objects/parse_base.dart b/lib/src/objects/parse_base.dart index 424c3ee7a..5a01795da 100644 --- a/lib/src/objects/parse_base.dart +++ b/lib/src/objects/parse_base.dart @@ -187,15 +187,11 @@ abstract class ParseBase { void set(String key, T value, {bool forceUpdate = true}) { if (value != null) { if (_getObjectData().containsKey(key)) { - if (_getObjectData()[key] == value) { + if (_getObjectData()[key] == value && !forceUpdate) { return; } - if (forceUpdate) { - _getObjectData()[key] = value; - } - } else { - _getObjectData()[key] = value; } + _getObjectData()[key] = value; _unsavedChanges[key] = value; } } From f7639932c9cde3052b43a19d6b553f2dfe170752 Mon Sep 17 00:00:00 2001 From: Oleksandr Matsko Date: Wed, 14 Aug 2019 07:47:13 +0200 Subject: [PATCH 11/12] Setting objectData properties directly in parseJson function to prevent making decoded object properties dirty --- lib/src/objects/parse_base.dart | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/objects/parse_base.dart b/lib/src/objects/parse_base.dart index 5a01795da..4de4d7f99 100644 --- a/lib/src/objects/parse_base.dart +++ b/lib/src/objects/parse_base.dart @@ -121,23 +121,23 @@ abstract class ParseBase { if (key == parseClassName || key == '__type') { // NO OP } else if (key == keyVarObjectId) { - objectId = value; + _getObjectData()[keyVarObjectId] = value; } else if (key == keyVarCreatedAt) { if (keyVarCreatedAt is String) { - set(keyVarCreatedAt, _parseDateFormat.parse(value)); + _getObjectData()[keyVarCreatedAt] = _parseDateFormat.parse(value); } else { - set(keyVarCreatedAt, value); + _getObjectData()[keyVarCreatedAt] = value; } } else if (key == keyVarUpdatedAt) { if (keyVarUpdatedAt is String) { - set(keyVarUpdatedAt, _parseDateFormat.parse(value)); + _getObjectData()[keyVarUpdatedAt] = _parseDateFormat.parse(value); } else { - set(keyVarUpdatedAt, value); + _getObjectData()[keyVarUpdatedAt] = _parseDateFormat.parse(value); } } else if (key == keyVarAcl) { - this[keyVarAcl] = ParseACL().fromJson(value); + _getObjectData()[keyVarAcl] = ParseACL().fromJson(value); } else { - this[key] = parseDecode(value); + _getObjectData()[key] = parseDecode(value); } }); From 87b7f256fd3f58f53bba64c89df8d924123cf0d3 Mon Sep 17 00:00:00 2001 From: Oleksandr Matsko Date: Wed, 14 Aug 2019 07:48:05 +0200 Subject: [PATCH 12/12] Made forceUpdate false by default in ParseBase set method --- lib/src/objects/parse_base.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/objects/parse_base.dart b/lib/src/objects/parse_base.dart index 4de4d7f99..299666aa5 100644 --- a/lib/src/objects/parse_base.dart +++ b/lib/src/objects/parse_base.dart @@ -184,7 +184,7 @@ abstract class ParseBase { /// To set an int, call setType and an int will be saved /// [bool] forceUpdate is always true, if unsure as to whether an item is /// needed or not, set to false - void set(String key, T value, {bool forceUpdate = true}) { + void set(String key, T value, {bool forceUpdate = false}) { if (value != null) { if (_getObjectData().containsKey(key)) { if (_getObjectData()[key] == value && !forceUpdate) {