Skip to content

Commit 9508001

Browse files
authored
Merge pull request #38 from phillwiggins/develop
Develop
2 parents 57cbe71 + a135a4e commit 9508001

22 files changed

+8553
-667
lines changed

.idea/libraries/Dart_Packages.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Flutter_Plugins.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 419 additions & 516 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.0.6
2+
3+
BREAK FIX - Fixed ParseUser return type so now returns ParseResponse
4+
BREAK FIX - Changed query names to make more human readable
5+
Fixed pinning and unpinning
6+
17
## 1.0.5
28

39
Corrected save. Now formatted items correctly for saving on server

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Want to get involved? Join our Slack channel and help out! (http://flutter-parse
1313
To install, either add to your pubspec.yaml
1414
```
1515
dependencies:
16-
parse_server_sdk: ^1.0.5
16+
parse_server_sdk: ^1.0.6
1717
```
1818
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.
1919

@@ -174,11 +174,13 @@ var user = ParseUser().create("TestFlutter", "TestPassword123", "TestFlutterSDK
174174
Then have the user sign up:
175175

176176
```
177-
user = await user.signUp();
177+
var response = await user.signUp();
178+
if (response.success) user = response.result;
178179
```
179180
You can also logout and login with the user:
180181
```
181-
user = await user.login();
182+
var response = await user.login();
183+
if (response.success) user = response.result;
182184
```
183185
Also, once logged in you can manage sessions tokens. This feature can be called after Parse().init() on startup to check for a logged in user.
184186
```

example/lib/main.dart

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ class _MyAppState extends State<MyApp> {
122122

123123
void query() async {
124124
var queryBuilder = QueryBuilder<DietPlan>(DietPlan())
125-
..greaterThan(DietPlan.keyFat, 20)
126-
..descending(DietPlan.keyFat);
125+
..whereContains(DietPlan.keyName, "eto");
127126

128127
var apiResponse = await queryBuilder.query();
129128

@@ -138,22 +137,42 @@ class _MyAppState extends State<MyApp> {
138137

139138
// All return type ParseUser except all
140139
var user = ParseUser("TestFlutter", "TestPassword123", "[email protected]");
141-
user = await user.signUp();
142-
user = await user.login();
140+
var response = await user.signUp();
141+
if (response.success) user = response.result;
142+
143+
response = await user.login();
144+
if (response.success) user = response.result;
145+
143146
user = null;
147+
// Best practice for starting the app. This will check for a valid user
148+
user = await ParseUser.currentUser();
149+
await user.logout();
150+
user = await ParseUser.currentUser();
151+
152+
response = await user.getCurrentUserFromServer();
153+
if (response.success) user = response.result;
154+
155+
response = await user.requestPasswordReset();
156+
if (response.success) user = response.result;
144157

145-
// Best practice for starting the app. This will check for a
146-
user = ParseUser.currentUser();
147-
user = await user.getCurrentUserFromServer();
148-
user = await user.requestPasswordReset();
149-
user = await user.verificationEmailRequest();
158+
response = await user.verificationEmailRequest();
159+
if (response.success) user = response.result;
160+
161+
response = await user.save();
162+
if (response.success) user = response.result;
150163

151-
user = await user.save();
152164
var destroyResponse = await user.destroy();
153165
if (destroyResponse.success) print('object has been destroyed!');
154166

155167
// Returns type ParseResponse as its a query, not a single result
156-
await ParseUser.all();
168+
response = await ParseUser.all();
169+
if (response.success) user = response.result;
170+
171+
var queryBuilder = QueryBuilder<ParseUser>(ParseUser.forQuery())
172+
..whereStartsWith(ParseUser.keyUsername, 'phillw');;
173+
174+
var apiResponse = await queryBuilder.query();
175+
if (apiResponse.success) user = response.result;
157176
}
158177

159178
function() {

lib/parse.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'dart:async';
44
import 'dart:convert';
55
import 'dart:io';
66

7+
import 'dart:typed_data';
8+
import 'package:path/path.dart' as path;
79
import 'package:http/http.dart';
810
import 'package:meta/meta.dart';
911
import 'package:shared_preferences/shared_preferences.dart';
@@ -37,6 +39,8 @@ part 'src/objects/parse_response.dart';
3739

3840
part 'src/objects/parse_user.dart';
3941

42+
part 'src/objects/parse_file.dart';
43+
4044
part 'src/utils/parse_decoder.dart';
4145

4246
part 'src/utils/parse_encoder.dart';
@@ -45,6 +49,8 @@ part 'src/utils/parse_logger.dart';
4549

4650
part 'src/utils/parse_utils.dart';
4751

52+
part 'src/utils/parse_file_extensions.dart';
53+
4854
class Parse {
4955
ParseCoreData data;
5056
final ParseHTTPClient client = new ParseHTTPClient();

lib/src/base/parse_constants.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const String keyVarAcl = 'ACL';
2525
// Classes
2626
const String keyClassMain = 'ParseMain';
2727
const String keyClassUser = '_User';
28+
const String keyGeoPoint = 'GeoPoint';
29+
const String keyFile = 'File';
2830

2931
// Headers
3032
const String keyHeaderSessionToken = 'X-Parse-Session-Token';

lib/src/data/parse_core_data.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ part of flutter_parse_sdk;
33
/// Singleton class that defines all user keys and data
44
class ParseCoreData {
55
static ParseCoreData _instance;
6+
67
static ParseCoreData get instance => _instance;
78

89
/// Creates an instance of Parse Server
910
///
1011
/// This class should not be user unless switching servers during the app,
1112
/// which is odd. Should only be user by Parse.init
12-
static void init(appId, serverUrl, {debug, appName, liveQueryUrl, masterKey, sessionId}){
13-
_instance = ParseCoreData._init(appId, serverUrl);
14-
15-
if (debug != null) _instance.debug = debug;
16-
if (appName != null) _instance.appName = appName;
17-
if (liveQueryUrl != null) _instance.liveQueryURL = liveQueryUrl;
18-
if (masterKey != null) _instance.masterKey = masterKey;
19-
if (sessionId != null) _instance.sessionId = sessionId;
13+
static void init(appId, serverUrl,
14+
{debug, appName, liveQueryUrl, masterKey, sessionId}) {
15+
_instance = ParseCoreData._init(appId, serverUrl);
16+
17+
if (debug != null) _instance.debug = debug;
18+
if (appName != null) _instance.appName = appName;
19+
if (liveQueryUrl != null) _instance.liveQueryURL = liveQueryUrl;
20+
if (masterKey != null) _instance.masterKey = masterKey;
21+
if (sessionId != null) _instance.sessionId = sessionId;
2022
}
2123

2224
String appName;
@@ -28,8 +30,7 @@ class ParseCoreData {
2830
bool debug;
2931
SharedPreferences storage;
3032

31-
ParseCoreData._init(
32-
this.applicationId,
33+
ParseCoreData._init(this.applicationId,
3334
this.serverUrl);
3435

3536
factory ParseCoreData() => _instance;
@@ -38,15 +39,17 @@ class ParseCoreData {
3839
///
3940
/// This is generated when a users logs in, or calls currentUser to update
4041
/// their keys
41-
void setSessionId(String sessionId){
42+
void setSessionId(String sessionId) {
4243
this.sessionId = sessionId;
4344
}
4445

4546
void initStorage() async {
4647
storage = await SharedPreferences.getInstance();
4748
}
4849

49-
SharedPreferences getStore() => storage;
50+
Future<SharedPreferences> getStore() async {
51+
return storage != null ? storage : await SharedPreferences.getInstance();
52+
}
5053

5154
@override
5255
String toString() => "$applicationId $masterKey";

lib/src/enums/parse_enum_api_rq.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,13 @@ enum ParseApiRQ {
1616
requestPasswordReset,
1717
destroy,
1818
all,
19-
execute
19+
execute,
20+
upload,
21+
add,
22+
addAll,
23+
addUnique,
24+
remove,
25+
removeAll,
26+
increment,
27+
decrement
2028
}

0 commit comments

Comments
 (0)