-
-
Notifications
You must be signed in to change notification settings - Fork 207
fix: Setting atomic operation on Parse Object returns operation instead of prospective value #860
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
Changes from 73 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
39a6068
feat: create ParseOperation class
Nidal-Bakir f890f2f
Merge branch 'master' into fix_parse_op
Nidal-Bakir 736b29a
create the base class for parse operation
Nidal-Bakir bc15757
remove the old parse operaion file
Nidal-Bakir 503e4d4
create ParseArray class
Nidal-Bakir d8c3c41
create Valuable interface and custom exception for parse operations
Nidal-Bakir 47b4970
create add operation class
Nidal-Bakir 35d9661
create AddUnique operation class
Nidal-Bakir 1b70548
create Remove operation class
Nidal-Bakir 1007b03
create increment/decrement operation class
Nidal-Bakir e2c6838
create add/remove relation operation class
Nidal-Bakir a45c463
create add/remove relation operation class
Nidal-Bakir 7940c21
update the source file to include the added files to the SDK
Nidal-Bakir 9783535
fix the increment operation
Nidal-Bakir 65033f9
fix the type cast in add relation operation
Nidal-Bakir 37d460a
rename the 'fromJson' function in parse array operation to 'fromFullJ…
Nidal-Bakir 6214c12
fix AddUnique operation not result the expected values when adding fo…
Nidal-Bakir eecf93d
fix _ParseArray is not a subtype of List
Nidal-Bakir f358273
introduce parse save state aware child mixin
Nidal-Bakir 9732977
account for operation while saving objects
Nidal-Bakir 0a07fe8
Merge branch 'master' into fix_parse_op
Nidal-Bakir d21bf90
remove unnecessary check and fromJson in testUnmergeableOperationShou…
Nidal-Bakir 8f5d4a9
fix: decoding from json in parse Array. unexpected requests when remo…
Nidal-Bakir b2aedd6
fix: parse_add_unique_operation not removing duplicate saved ParseObj…
Nidal-Bakir 71d70cc
introduce ParseRelation as dataType Like parseArray
Nidal-Bakir ed3601a
remove ParseMergeTool
Nidal-Bakir 45c7253
Merge branch 'master' into fix_parse_op
Nidal-Bakir 70f6341
remove parse_merge.dart file import from parse_server_sdk source file
Nidal-Bakir 307cedb
add onClearUnsaved function to _ParseSaveStateAwareChild interface an…
Nidal-Bakir cf0b0ce
implement add and remove relation operation
Nidal-Bakir f53b0e7
fix maybeMergeWithPrevious not accounting for previous _ParseRelation…
Nidal-Bakir 9c977ec
Unskip the skipped tests in relation tests
Nidal-Bakir 32812d5
fix the core files to account for the new ParseOperation, ParseArray,…
Nidal-Bakir ee3de9f
fix parse_encoder_test
Nidal-Bakir 7bb3f9a
fix: allow the array operations to be incremental in set mode
Nidal-Bakir 3d86d3c
style: rename forSet property to setMode
Nidal-Bakir 0150d3d
feat: create ParseNumber datatype to account for setMode and parallel…
Nidal-Bakir 989c7d2
feat: add onErrorSaving callback to parseSaveStateAwareChild interface
Nidal-Bakir 2b3a6e0
docs: add docs for ParseSaveStateAwareChild
Nidal-Bakir 7397d41
test: add test for setRedirectClassNameForKey query
Nidal-Bakir a043718
feat: convert the return type from object? to generic T in _Valuable …
Nidal-Bakir 22679f9
test: add tests for ParseArray
Nidal-Bakir 81cd8c6
test: add tests for ParseNumber
Nidal-Bakir d1fac20
fix: getRelation not storing the relation in the parent object
Nidal-Bakir 823899a
refactor: create function handler for each operation
Nidal-Bakir 08e0dad
refactor: create function handler for operations
Nidal-Bakir 9a09119
test: use setUpAll function to init the parseSDK once per test file r…
Nidal-Bakir 268687f
fix: ParseRelation getQuery construct a parent object rather than raw…
Nidal-Bakir 7819877
fix: _ParseRelationOperation toJson() for API Request uses value rath…
Nidal-Bakir 1c3da62
fix: _ParseRelation getting targetClass from 'className' json key rat…
Nidal-Bakir e86de80
test: add tests for ParseRelation
Nidal-Bakir beef0c6
fix: containsValue in parseBase not accounting for _Valuable objects
Nidal-Bakir a1acc28
test: add tests for ParseBase, improve array and relation tests
Nidal-Bakir 41944fe
test: add tests for fromJsonForManualObject in ParseBase
Nidal-Bakir cceea8f
test: add tests for empty value for API request in ParseRelation
Nidal-Bakir a6aa7cc
style: explicitly call toJson() for ParseGeoPoint and ParseFileBase i…
Nidal-Bakir d95f40f
docs: add documentation for _ParseOperation abstract class
Nidal-Bakir 8a8fe62
fix: unset not include parseError object in the ParseResponse in case…
Nidal-Bakir e239514
test: test for error from ParseNetworkResponse
Nidal-Bakir ad160ee
test: add test for when the user call getRelation on key holds value …
Nidal-Bakir fc1335d
test: add test for error from the server in update() function
Nidal-Bakir c6c6e97
docs: add documentation for _Valuable interface
Nidal-Bakir 33d6171
refactor: remove duplicate logic from parse operations
Nidal-Bakir 9ab4fa7
feat: add new function to ParseRelation addAll and removeAll that acc…
Nidal-Bakir bfd67e4
docs: add and fix some documentations in ParseBase
Nidal-Bakir 932f694
docs: add and fix some documentations in ParseObject
Nidal-Bakir 4fb5535
docs: add documentations for parse operations classes
Nidal-Bakir bc7224f
chore: bump the Dart sdk version to 5.0.0 and add CHANGELOG entry
Nidal-Bakir a8133e7
Update packages/dart/CHANGELOG.md
Nidal-Bakir d9548e2
add new version to changelog
mtrezza 6da8e1c
Merge branch 'master' into fix_parse_op
Nidal-Bakir 7a2c480
Merge branch 'master' into fix_parse_op
Nidal-Bakir b59caa1
Merge branch 'master' into fix_parse_op
mtrezza bf8b111
Update CHANGELOG.md
mtrezza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
part of flutter_parse_sdk; | ||
|
||
class _ParseArray implements _Valuable<List>, _ParseSaveStateAwareChild { | ||
_ParseArray({this.setMode = false}); | ||
|
||
bool setMode; | ||
|
||
List _savedArray = []; | ||
List estimatedArray = []; | ||
|
||
set savedArray(List array) { | ||
_savedArray = array.toList(); | ||
estimatedArray = array.toList(); | ||
} | ||
|
||
List get savedArray => _savedArray; | ||
|
||
_ParseArrayOperation? lastPreformedOperation; | ||
|
||
_ParseArray preformArrayOperation( | ||
_ParseArrayOperation arrayOperation, | ||
) { | ||
arrayOperation.mergeWithPrevious(lastPreformedOperation ?? this); | ||
|
||
lastPreformedOperation = arrayOperation; | ||
|
||
estimatedArray = lastPreformedOperation!.value.toList(); | ||
|
||
if (setMode) { | ||
lastPreformedOperation = null; | ||
} | ||
|
||
return this; | ||
} | ||
|
||
Object toJson({bool full = false}) { | ||
if (full) { | ||
return { | ||
'className': 'ParseArray', | ||
'estimatedArray': parseEncode(estimatedArray, full: full), | ||
'savedArray': parseEncode(_savedArray, full: full), | ||
'lastPreformedOperation': lastPreformedOperation?.toJson(full: full) | ||
}; | ||
} | ||
|
||
return lastPreformedOperation?.toJson(full: full) ?? | ||
parseEncode(estimatedArray, full: full); | ||
} | ||
|
||
factory _ParseArray.fromFullJson(Map<String, dynamic> json) { | ||
return _ParseArray() | ||
.._savedArray = parseDecode(json['savedArray']) | ||
..estimatedArray = parseDecode(json['estimatedArray']) | ||
..lastPreformedOperation = json['lastPreformedOperation'] == null | ||
? null | ||
: _ParseArrayOperation.fromFullJson(json['lastPreformedOperation']); | ||
} | ||
|
||
@override | ||
List getValue() { | ||
return estimatedArray.toList(); | ||
} | ||
|
||
_ParseArrayOperation? _lastPreformedOperationBeforeSaving; | ||
List? _estimatedArrayBeforeSaving; | ||
|
||
@override | ||
@mustCallSuper | ||
void onSaved() { | ||
setMode = false; | ||
_savedArray.clear(); | ||
_savedArray.addAll(_estimatedArrayBeforeSaving ?? []); | ||
_estimatedArrayBeforeSaving = null; | ||
|
||
if (_lastPreformedOperationBeforeSaving == lastPreformedOperation) { | ||
// No operations were performed during the save process | ||
lastPreformedOperation = null; | ||
} else { | ||
// remove the saved objects and keep the new added objects while saving | ||
if (lastPreformedOperation is _ParseRemoveOperation) { | ||
lastPreformedOperation?.valueForApiRequest | ||
.retainWhere((e) => _savedArray.contains(e)); | ||
} else { | ||
lastPreformedOperation?.valueForApiRequest | ||
.removeWhere((e) => _savedArray.contains(e)); | ||
} | ||
} | ||
|
||
_lastPreformedOperationBeforeSaving = null; | ||
} | ||
|
||
@override | ||
@mustCallSuper | ||
void onSaving() { | ||
_lastPreformedOperationBeforeSaving = lastPreformedOperation; | ||
_estimatedArrayBeforeSaving = estimatedArray.toList(); | ||
} | ||
|
||
@override | ||
@mustCallSuper | ||
void onRevertSaving() { | ||
_lastPreformedOperationBeforeSaving = null; | ||
_estimatedArrayBeforeSaving = null; | ||
} | ||
|
||
@override | ||
@mustCallSuper | ||
void onErrorSaving() { | ||
_lastPreformedOperationBeforeSaving = null; | ||
_estimatedArrayBeforeSaving = null; | ||
} | ||
|
||
@override | ||
@mustCallSuper | ||
void onClearUnsaved() { | ||
estimatedArray = savedArray; | ||
lastPreformedOperation = null; | ||
_lastPreformedOperationBeforeSaving = null; | ||
_estimatedArrayBeforeSaving = null; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.