Skip to content

Commit 35fa250

Browse files
committed
Release/1.0.24 - Fixed LiveQuery web
1 parent 89f731a commit 35fa250

File tree

10 files changed

+36
-28
lines changed

10 files changed

+36
-28
lines changed

lib/src/network/parse_http_client.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ class ParseHTTPClient extends BaseClient {
1717
/// Overrides the call method for HTTP Client and adds custom headers
1818
@override
1919
Future<StreamedResponse> send(BaseRequest request) {
20-
if (!identical(0, 0.0))
20+
if (!identical(0, 0.0)) {
2121
request.headers[keyHeaderUserAgent] = _userAgent;
22+
}
2223
request.headers[keyHeaderApplicationId] = data.applicationId;
2324
if ((_sendSessionId == true) &&
2425
(data.sessionId != null) &&

lib/src/network/parse_live_query.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,4 @@ class LiveQuery {
193193
await _webSocket.close();
194194
}
195195
}
196-
}
196+
}

lib/src/network/parse_live_query_web.dart

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import 'dart:convert';
22
// ignore: uri_does_not_exist
3-
import 'dart:html' as HTML;
3+
import 'dart:html' as html;
44

55
import '../../parse_server_sdk.dart';
66

7-
enum LiveQueryEvent { create, enter, update, leave, delete, error }
7+
enum LiveQueryEvent {
8+
create,
9+
enter,
10+
update,
11+
leave,
12+
delete,
13+
error
14+
}
815

916
class LiveQuery {
1017
LiveQuery({bool debug, ParseHTTPClient client, bool autoSendSessionId}) {
@@ -19,7 +26,7 @@ class LiveQuery {
1926
autoSendSessionId ?? ParseCoreData().autoSendSessionId ?? true;
2027
}
2128

22-
HTML.WebSocket _webSocket;
29+
html.WebSocket _webSocket;
2330
ParseHTTPClient _client;
2431
bool _debug;
2532
bool _sendSessionId;
@@ -65,10 +72,10 @@ class LiveQuery {
6572
final int requestId = _requestIdGenerator();
6673

6774
try {
68-
_webSocket = HTML.WebSocket(_liveQueryURL);
75+
_webSocket = html.WebSocket(_liveQueryURL);
6976
await _webSocket.onOpen.first;
7077

71-
if (_webSocket != null && _webSocket.readyState == HTML.WebSocket.OPEN) {
78+
if (_webSocket != null && _webSocket.readyState == html.WebSocket.OPEN) {
7279
if (_debug) {
7380
print('$_printConstLiveQuery: Socket opened');
7481
}
@@ -79,7 +86,7 @@ class LiveQuery {
7986
}
8087
}
8188

82-
_webSocket.onMessage.listen((HTML.MessageEvent e) {
89+
_webSocket.onMessage.listen((html.MessageEvent e) {
8390
final dynamic message = e.data;
8491
if (_debug) {
8592
print('$_printConstLiveQuery: Listen: $message');
@@ -170,7 +177,7 @@ class LiveQuery {
170177
}
171178

172179
Future<void> unSubscribe() async {
173-
if (_webSocket != null && _webSocket.readyState == HTML.WebSocket.OPEN) {
180+
if (_webSocket != null && _webSocket.readyState == html.WebSocket.OPEN) {
174181
_webSocket.sendString(jsonEncode(_unsubscribeMessage));
175182
if (_debug) {
176183
print('$_printConstLiveQuery: Socket closed');

lib/src/objects/parse_file.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class ParseFile extends ParseBase {
3737
String get url => super.get<String>(keyVarURL);
3838
set url(String url) => set<String>(keyVarURL, url);
3939

40-
@override
4140
String _path;
4241

4342
bool get saved => url != null;
@@ -85,7 +84,6 @@ class ParseFile extends ParseBase {
8584
}
8685

8786
/// Uploads a file to Parse Server
88-
@override
8987
Future<ParseResponse> save() async {
9088
return upload();
9189
}

lib/src/objects/parse_relation.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ParseRelation<T extends ParseObject> {
1515
QueryBuilder getQuery() {
1616
return QueryBuilder(ParseObject(_targetClass));
1717
}
18-
18+
1919
void add(T object) {
2020
if (object != null) {
2121
_targetClass = object.parseClassName;
@@ -33,9 +33,13 @@ class ParseRelation<T extends ParseObject> {
3333
}
3434

3535
Map<String, dynamic> toJson() =>
36-
<String, String>{'__type': keyRelation, 'className': _objects?.first?.parseClassName, 'objects': parseEncode(_objects?.toList())};
36+
<String, String>{
37+
'__type': keyRelation,
38+
'className': _objects?.first?.parseClassName,
39+
'objects': parseEncode(_objects?.toList())
40+
};
3741

3842
ParseRelation<T> fromJson(Map<String, dynamic> map) => ParseRelation<T>()
39-
.._objects = parseDecode(map['objects'])
40-
.._targetClass = map['className'];
41-
}
43+
.._objects = parseDecode(map['objects'])
44+
.._targetClass = map['className'];
45+
}

lib/src/objects/parse_user.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ class ParseUser extends ParseObject implements ParseCloneable {
106106
try {
107107
final Uri url = getSanitisedUri(_client, '$keyEndPointUserName');
108108
final Response response = await _client.get(url, headers: headers);
109-
return await _handleResponse(
110-
_getEmptyUser(), response, ParseApiRQ.currentUser,
111-
_debug, _getEmptyUser().parseClassName);
109+
return await _handleResponse(_getEmptyUser(), response,
110+
ParseApiRQ.currentUser, _debug, _getEmptyUser().parseClassName);
112111
} on Exception catch (e) {
113112
return handleException(
114113
e, ParseApiRQ.currentUser, _debug, _getEmptyUser().parseClassName);
@@ -277,9 +276,8 @@ class ParseUser extends ParseObject implements ParseCloneable {
277276
final Response response = await _client.post(
278277
'${_client.data.serverUrl}$keyEndPointRequestPasswordReset',
279278
body: json.encode(<String, dynamic>{keyVarEmail: emailAddress}));
280-
return await _handleResponse(
281-
this, response, ParseApiRQ.requestPasswordReset, _debug,
282-
parseClassName);
279+
return await _handleResponse(this, response,
280+
ParseApiRQ.requestPasswordReset, _debug, parseClassName);
283281
} on Exception catch (e) {
284282
return handleException(
285283
e, ParseApiRQ.requestPasswordReset, _debug, parseClassName);
@@ -364,8 +362,7 @@ class ParseUser extends ParseObject implements ParseCloneable {
364362

365363
/// Handles all the response data for this class
366364
static Future<ParseResponse> _handleResponse(ParseUser user,
367-
Response response,
368-
ParseApiRQ type, bool debug, String className) async {
365+
Response response, ParseApiRQ type, bool debug, String className) async {
369366
final ParseResponse parseResponse =
370367
handleResponse<ParseUser>(user, response, type, debug, className);
371368

lib/src/objects/response/parse_response_utils.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ bool isSuccessButNoResults(Response apiResponse) {
5858
results = decodedResponse;
5959
}
6060

61-
6261
if (results == null) {
6362
return false;
6463
}

lib/src/storage/core_store_sem_impl.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
part of flutter_parse_sdk;
22

3+
// ignore_for_file: deprecated_member_use
34
class CoreStoreSembastImp implements CoreStore {
45
CoreStoreSembastImp._internal(this._store);
56

lib/src/utils/parse_utils.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ String removeTrailingSlash(String serverUrl) {
6666
}
6767

6868
Future<ParseResponse> batchRequest(List<dynamic> requests,
69-
List<ParseObject> objects, {ParseHTTPClient client, bool debug}) async {
69+
List<ParseObject> objects,
70+
{ParseHTTPClient client, bool debug}) async {
7071
debug = isDebugEnabled(objectLevelDebug: debug);
7172
client = client ??
7273
ParseHTTPClient(

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ environment:
88
sdk: ">=2.2.2 <3.0.0"
99

1010
dependencies:
11+
http: ^0.12.0+2
1112
flutter:
1213
sdk: flutter
1314

1415
# Networking
1516
web_socket_channel: ^1.0.13
16-
http: ^0.12.0+2
1717

1818
#Database
19-
sembast: ^1.17.0
19+
sembast: ^2.0.1
2020
xxtea: ^2.0.2
2121
shared_preferences: ^0.5.3+2
2222

0 commit comments

Comments
 (0)