Skip to content

same fix for version 1.0.23 #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/network/parse_live_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class LiveQuery {
securityContext: ParseCoreData().securityContext);

_debug = isDebugEnabled(objectLevelDebug: debug);
_sendSessionId = autoSendSessionId ?? ParseCoreData().autoSendSessionId ?? true;
_sendSessionId =
autoSendSessionId ?? ParseCoreData().autoSendSessionId ?? true;
}

WebSocket _webSocket;
Expand Down Expand Up @@ -40,7 +41,6 @@ class LiveQuery {

// ignore: always_specify_types
Future subscribe(QueryBuilder query) async {

String _liveQueryURL = _client.data.liveQueryURL;
if (_liveQueryURL.contains('https')) {
_liveQueryURL = _liveQueryURL.replaceAll('https', 'wss');
Expand Down Expand Up @@ -101,7 +101,7 @@ class LiveQuery {
if (_debug) {
print('$_printConstLiveQuery: Done');
}
}, onError: (Error error) {
}, onError: (Object error) {
if (_debug) {
print(
'$_printConstLiveQuery: Error: ${error.runtimeType.toString()}');
Expand Down
21 changes: 10 additions & 11 deletions lib/src/objects/parse_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ abstract class ParseBase {
if (_dirty || _unsavedChanges.isNotEmpty) {
return true;
}
bool match = false;
_getObjectData().forEach((String key, dynamic value) {
if (value is ParseObject && value._areChildrenDirty(seenObjects)) {
return true;
match = true;
}
});
return false;
return match;
}

/// Returns [DateTime] createdAt
Expand Down Expand Up @@ -88,9 +89,8 @@ abstract class ParseBase {
map[keyVarUpdatedAt] = _parseDateFormat.format(updatedAt);
}

final Map<String, dynamic> target = forApiRQ
? _unsavedChanges
: _getObjectData();
final Map<String, dynamic> target =
forApiRQ ? _unsavedChanges : _getObjectData();
target.forEach((String key, dynamic value) {
if (!map.containsKey(key)) {
map[key] = parseEncode(value, full: full);
Expand All @@ -102,6 +102,7 @@ abstract class ParseBase {
map.remove(keyVarUpdatedAt);
map.remove(keyVarClassName);
//map.remove(keyVarAcl);
map.remove(keyVarObjectId);
map.remove(keyParamSessionToken);
}

Expand Down Expand Up @@ -172,11 +173,11 @@ abstract class ParseBase {
void operator []=(String key, dynamic value) {
set<dynamic>(key, value);
}

/// Saves in storage
Future<void> saveInStorage(String key) async {
final String objectJson = json.encode(toJson(full: true));
ParseCoreData().getStore()
..setString(key, objectJson);
ParseCoreData().getStore()..setString(key, objectJson);
}

/// Sets type [T] from objectData
Expand Down Expand Up @@ -240,8 +241,7 @@ abstract class ParseBase {
await unpin();
final Map<String, dynamic> objectMap = parseEncode(this, full: true);
final String json = jsonEncode(objectMap);
ParseCoreData().getStore()
..setString(objectId, json);
ParseCoreData().getStore()..setString(objectId, json);
return true;
} else {
return false;
Expand All @@ -253,8 +253,7 @@ abstract class ParseBase {
/// Replicates Android SDK pin process and saves object to storage
Future<bool> unpin({String key}) async {
if (objectId != null) {
ParseCoreData().getStore()
..remove(key ?? objectId);
ParseCoreData().getStore()..remove(key ?? objectId);
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/src/objects/parse_installation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ParseInstallation extends ParseObject {
_client = client ??
ParseHTTPClient(
sendSessionId:
autoSendSessionId ?? ParseCoreData().autoSendSessionId,
autoSendSessionId ?? ParseCoreData().autoSendSessionId,
securityContext: ParseCoreData().securityContext);
}

Expand Down Expand Up @@ -127,14 +127,14 @@ class ParseInstallation extends ParseObject {

/// Gets the locally stored installation
static Future<ParseInstallation> _getFromLocalStore() async {
final CoreStore coreStore = await ParseCoreData().getStore();
final CoreStore coreStore = ParseCoreData().getStore();

final String installationJson =
await coreStore.getString(keyParseStoreInstallation);
await coreStore.getString(keyParseStoreInstallation);

if (installationJson != null) {
final Map<String, dynamic> installationMap =
json.decode(installationJson);
json.decode(installationJson);

if (installationMap != null) {
return ParseInstallation()..fromJson(installationMap);
Expand Down
14 changes: 6 additions & 8 deletions lib/src/objects/parse_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ class ParseObject extends ParseBase implements ParseCloneable {
if (response != null) {
if (response.success) {
_savingChanges.clear();
}
else {
} else {
_revertSavingChanges();
}
return response;
Expand Down Expand Up @@ -163,9 +162,9 @@ class ParseObject extends ParseBase implements ParseCloneable {
final List<dynamic> requests = chunk.map<dynamic>((ParseObject obj) {
return obj._getRequestJson(obj.objectId == null ? 'POST' : 'PUT');
}).toList();
chunk.forEach((ParseObject obj) {
for (ParseObject obj in chunk) {
obj._saveChanges();
});
}
final ParseResponse response = await batchRequest(requests, chunk);
totalResponse.success &= response.success;
if (response.success) {
Expand All @@ -175,16 +174,15 @@ class ParseObject extends ParseBase implements ParseCloneable {
if (response.results[i] is ParseError) {
// Batch request succeed, but part of batch failed.
chunk[i]._revertSavingChanges();
}
else {
} else {
chunk[i]._savingChanges.clear();
}
}
} else {
// If there was an error, we want to roll forward the save changes before rethrowing.
chunk.forEach((ParseObject obj) {
for (ParseObject obj in chunk) {
obj._revertSavingChanges();
});
}
totalResponse.statusCode = response.statusCode;
totalResponse.error = response.error;
}
Expand Down
10 changes: 4 additions & 6 deletions lib/src/objects/parse_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ class ParseUser extends ParseObject implements ParseCloneable {

@override
dynamic clone(Map<String, dynamic> map) =>
ParseUser.clone(map)
..fromJson(map);
ParseUser.clone(map)..fromJson(map);

static const String keyEmailVerified = 'emailVerified';
static const String keyUsername = 'username';
Expand Down Expand Up @@ -273,9 +272,8 @@ class ParseUser extends ParseObject implements ParseCloneable {
final Response response = await _client.post(
'${_client.data.serverUrl}$keyEndPointRequestPasswordReset',
body: json.encode(<String, dynamic>{keyVarEmail: emailAddress}));
return _handleResponse(
this, response, ParseApiRQ.requestPasswordReset, _debug,
parseClassName);
return _handleResponse(this, response, ParseApiRQ.requestPasswordReset,
_debug, parseClassName);
} on Exception catch (e) {
return handleException(
e, ParseApiRQ.requestPasswordReset, _debug, parseClassName);
Expand Down Expand Up @@ -334,7 +332,7 @@ class ParseUser extends ParseObject implements ParseCloneable {

static Future<dynamic> _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) {
Expand Down