Skip to content

Fixed ignored forceUpdate and dirty ParseObject when deserialized from json (#251) #252

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

Closed
wants to merge 3 commits into from
Closed
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
24 changes: 10 additions & 14 deletions lib/src/objects/parse_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<DateTime>(keyVarCreatedAt, _parseDateFormat.parse(value));
_getObjectData()[keyVarCreatedAt] = _parseDateFormat.parse(value);
} else {
set<DateTime>(keyVarCreatedAt, value);
_getObjectData()[keyVarCreatedAt] = value;
}
} else if (key == keyVarUpdatedAt) {
if (keyVarUpdatedAt is String) {
set<DateTime>(keyVarUpdatedAt, _parseDateFormat.parse(value));
_getObjectData()[keyVarUpdatedAt] = _parseDateFormat.parse(value);
} else {
set<DateTime>(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);
}
});

Expand Down Expand Up @@ -184,18 +184,14 @@ abstract class ParseBase {
/// To set an int, call setType<int> 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<T>(String key, T value, {bool forceUpdate = true}) {
void set<T>(String key, T value, {bool forceUpdate = false}) {
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;
}
}
Expand Down