Skip to content

refactor: Update dependencies because of conflicts with uuid recent versions #1036

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
Update dependencies because of conflicts with uuid recent versions
  • Loading branch information
FoumaneDonald committed Mar 17, 2025
commit 9bc0d35867deb6d058d2148ebd97f81891a0525e
100 changes: 26 additions & 74 deletions packages/dart/lib/src/network/parse_live_query.dart
Original file line number Diff line number Diff line change
@@ -13,14 +13,7 @@ class Subscription<T extends ParseObject> {
T? _copyObject;
int requestId;
bool _enabled = false;
final List<String> _liveQueryEvent = <String>[
'create',
'enter',
'update',
'leave',
'delete',
'error'
];
final List<String> _liveQueryEvent = <String>['create', 'enter', 'update', 'leave', 'delete', 'error'];
Map<String, Function> eventCallbacks = <String, Function>{};

void on(LiveQueryEvent op, Function callback) {
@@ -40,14 +33,12 @@ class LiveQueryReconnectingController {
this._eventStream,
this.debug,
) {
final ParseConnectivityProvider? connectivityProvider =
ParseCoreData().connectivityProvider;
final ParseConnectivityProvider? connectivityProvider = ParseCoreData().connectivityProvider;
if (connectivityProvider != null) {
connectivityProvider.checkConnectivity().then(_connectivityChanged);
connectivityProvider.connectivityStream.listen(_connectivityChanged);
} else {
print(
'LiveQuery does not work, if there is no ParseConnectivityProvider provided.');
print('LiveQuery does not work, if there is no ParseConnectivityProvider provided.');
}
_eventStream.listen((LiveQueryClientEvent event) {
switch (event) {
@@ -106,13 +97,8 @@ class LiveQueryReconnectingController {
}

void _setReconnect() {
if (_isOnline &&
!_isConnected &&
_currentTimer == null &&
!_userDisconnected &&
retryInterval[_retryState] >= 0) {
_currentTimer =
Timer(Duration(milliseconds: retryInterval[_retryState]), () {
if (_isOnline && !_isConnected && _currentTimer == null && !_userDisconnected && retryInterval[_retryState] >= 0) {
_currentTimer = Timer(Duration(milliseconds: retryInterval[_retryState]), () {
_currentTimer = null;
_reconnect();
});
@@ -129,17 +115,14 @@ class LiveQueryReconnectingController {
class LiveQueryClient {
factory LiveQueryClient() => _getInstance();

LiveQueryClient._internal(this._liveQueryURL,
{bool? debug, bool? autoSendSessionId}) {
LiveQueryClient._internal(this._liveQueryURL, {bool? debug, bool? autoSendSessionId}) {
_clientEventStreamController = StreamController<LiveQueryClientEvent>();
_clientEventStream =
_clientEventStreamController.stream.asBroadcastStream();
_clientEventStream = _clientEventStreamController.stream.asBroadcastStream();

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

reconnectingController = LiveQueryReconnectingController(
() => reconnect(userInitialized: false), getClientEventStream, _debug);
reconnectingController = LiveQueryReconnectingController(() => reconnect(userInitialized: false), getClientEventStream, _debug);
}

static LiveQueryClient get instance => _getInstance();
@@ -148,8 +131,7 @@ class LiveQueryClient {
static LiveQueryClient _getInstance({bool? debug, bool? autoSendSessionId}) {
String? liveQueryURL = ParseCoreData().liveQueryURL;
if (liveQueryURL == null) {
assert(false,
'liveQueryUrl is not set. For how to setup Live Queries, see https://github.com/parse-community/Parse-SDK-Flutter/tree/master/packages/flutter#live-queries.');
assert(false, 'liveQueryUrl is not set. For how to setup Live Queries, see https://github.com/parse-community/Parse-SDK-Flutter/tree/master/packages/flutter#live-queries.');
liveQueryURL = "";
} else {
if (liveQueryURL.contains('https')) {
@@ -158,9 +140,7 @@ class LiveQueryClient {
liveQueryURL = liveQueryURL.replaceAll('http', 'ws');
}
}
LiveQueryClient instance = _instance ??
LiveQueryClient._internal(liveQueryURL,
debug: debug, autoSendSessionId: autoSendSessionId);
LiveQueryClient instance = _instance ?? LiveQueryClient._internal(liveQueryURL, debug: debug, autoSendSessionId: autoSendSessionId);
_instance ??= instance;
return instance;
}
@@ -197,8 +177,7 @@ class LiveQueryClient {

Future<dynamic> disconnect({bool userInitialized = false}) async {
parse_web_socket.WebSocket? webSocket = _webSocket;
if (webSocket != null &&
webSocket.readyState == parse_web_socket.WebSocket.open) {
if (webSocket != null && webSocket.readyState == parse_web_socket.WebSocket.open) {
if (_debug) {
print('$_printConstLiveQuery: Socket closed');
}
@@ -218,21 +197,16 @@ class LiveQueryClient {
});
_connecting = false;
if (userInitialized) {
_clientEventStreamController.sink
.add(LiveQueryClientEvent.userDisconnected);
_clientEventStreamController.sink.add(LiveQueryClientEvent.userDisconnected);
}
}

Future<Subscription<T>> subscribe<T extends ParseObject>(
QueryBuilder<T> query,
{T? copyObject}) async {
Future<Subscription<T>> subscribe<T extends ParseObject>(QueryBuilder<T> query, {T? copyObject}) async {
if (_webSocket == null) {
await _clientEventStream.any((LiveQueryClientEvent event) =>
event == LiveQueryClientEvent.connected);
await _clientEventStream.any((LiveQueryClientEvent event) => event == LiveQueryClientEvent.connected);
}
final int requestId = _requestIdGenerator();
final Subscription<T> subscription =
Subscription<T>(query, requestId, copyObject: copyObject);
final Subscription<T> subscription = Subscription<T>(query, requestId, copyObject: copyObject);
_requestSubscription[requestId] = subscription;
//After a client connects to the LiveQuery server,
//it can send a subscribe message to subscribe a ParseQuery.
@@ -272,8 +246,7 @@ class LiveQueryClient {
_connecting = true;

try {
parse_web_socket.WebSocket webSocket =
await parse_web_socket.WebSocket.connect(_liveQueryURL);
parse_web_socket.WebSocket webSocket = await parse_web_socket.WebSocket.connect(_liveQueryURL);
_webSocket = webSocket;
_connecting = false;
if (webSocket.readyState == parse_web_socket.WebSocket.open) {
@@ -293,23 +266,16 @@ class LiveQueryClient {

chanelStream?.sink.add(message);
}, onDone: () {
_clientEventStreamController.sink
.add(LiveQueryClientEvent.disconnected);
_clientEventStreamController.sink.add(LiveQueryClientEvent.disconnected);
if (_debug) {
print('$_printConstLiveQuery: Done');
}
}, onError: (Object error) {
_clientEventStreamController.sink
.add(LiveQueryClientEvent.disconnected);
_clientEventStreamController.sink.add(LiveQueryClientEvent.disconnected);
if (_debug) {
print(
'$_printConstLiveQuery: Error: ${error.runtimeType.toString()}');
print('$_printConstLiveQuery: Error: ${error.runtimeType.toString()}');
}
return Future<ParseResponse>.value(handleException(
Exception(error),
ParseApiRQ.liveQuery,
_debug,
!parseIsWeb ? 'IOWebSocketChannel' : 'HtmlWebSocketChannel'));
return Future<ParseResponse>.value(handleException(Exception(error), ParseApiRQ.liveQuery, _debug, !parseIsWeb ? 'IOWebSocketChannel' : 'HtmlWebSocketChannel'));
});
} on Exception catch (e) {
_connecting = false;
@@ -328,10 +294,7 @@ class LiveQueryClient {
}
//The connect message is sent from a client to the LiveQuery server.
//It should be the first message sent from a client after the WebSocket connection is established.
final Map<String, String> connectMessage = <String, String>{
'op': 'connect',
'applicationId': ParseCoreData().applicationId
};
final Map<String, String> connectMessage = <String, String>{'op': 'connect', 'applicationId': ParseCoreData().applicationId};

if (_sendSessionId) {
String? sessionId = ParseCoreData().sessionId;
@@ -350,8 +313,7 @@ class LiveQueryClient {
connectMessage['masterKey'] = masterKey;
}

String? parseInstallation =
(await ParseInstallation.currentInstallation()).installationId;
String? parseInstallation = (await ParseInstallation.currentInstallation()).installationId;
if (parseInstallation != null) {
connectMessage['installationId'] = parseInstallation;
}
@@ -381,12 +343,7 @@ class LiveQueryClient {
final Map<String, dynamic> subscribeMessage = <String, dynamic>{
'op': 'subscribe',
'requestId': subscription.requestId,
'query': <String, dynamic>{
'className': query.object.parseClassName,
'where': whereMap,
if (keysToReturn != null && keysToReturn.isNotEmpty)
'fields': keysToReturn
}
'query': <String, dynamic>{'className': query.object.parseClassName, 'where': whereMap, if (keysToReturn != null && keysToReturn.isNotEmpty) 'fields': keysToReturn}
};
if (_sendSessionId && ParseCoreData().sessionId != null) {
subscribeMessage['sessionToken'] = ParseCoreData().sessionId;
@@ -430,13 +387,9 @@ class LiveQueryClient {
final String? className = map['className'];
if (className != null) {
if (className == keyClassUser) {
eventCallback((subscription.copyObject ??
ParseCoreData.instance.createParseUser(null, null, null))
.fromJson(map));
eventCallback((subscription.copyObject ?? ParseCoreData.instance.createParseUser(null, null, null)).fromJson(map));
} else {
eventCallback((subscription.copyObject ??
ParseCoreData.instance.createObject(className))
.fromJson(map));
eventCallback((subscription.copyObject ?? ParseCoreData.instance.createObject(className)).fromJson(map));
}
}
} else {
@@ -451,8 +404,7 @@ class LiveQuery {
LiveQuery({bool? debug, bool? autoSendSessionId}) {
_debug = isDebugEnabled(objectLevelDebug: debug);
_sendSessionId = autoSendSessionId ?? ParseCoreData().autoSendSessionId;
client = LiveQueryClient._getInstance(
debug: _debug, autoSendSessionId: _sendSessionId);
client = LiveQueryClient._getInstance(debug: _debug, autoSendSessionId: _sendSessionId);
}

bool? _debug;
10 changes: 5 additions & 5 deletions packages/dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -24,25 +24,25 @@ dependencies:
# Networking
dio: ^5.7.0
http: ^1.2.0
web_socket_channel: ^2.4.3
web_socket_channel: ^3.0.2

#Database
sembast: ^3.6.0
sembast: ^3.8.2
sembast_web: ^2.2.0

# Utils
uuid: ^4.5.1
meta: ^1.16.0
path: ^1.9.0
mime: ^1.0.0
timezone: ^0.9.4
mime: ^2.0.0
timezone: ^0.10.0
universal_io: ^2.2.2
xxtea: ^2.1.0
collection: ^1.18.0
cross_file: ^0.3.3+8

dev_dependencies:
lints: ^4.0.0
lints: ^5.1.1

# Testing
build_runner: ^2.4.9
16 changes: 8 additions & 8 deletions packages/flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -25,29 +25,29 @@ dependencies:
flutter:
sdk: flutter

parse_server_sdk: ^6.4.0
# Uncomment for local testing
#parse_server_sdk:
# path: ../dart
# parse_server_sdk: ^8.0.0
# Uncomment for local testing
parse_server_sdk:
path: ../dart

# Networking
connectivity_plus: ^6.0.3

#Database
shared_preferences: ^2.2.3
sembast: ^3.6.0
shared_preferences: ^2.5.2
sembast: ^3.8.2
sembast_web: ^2.2.0

# Utils
path_provider: ^2.1.4
package_info_plus: ^5.0.1
package_info_plus: ^8.3.0
path: ^1.8.3

dev_dependencies:
flutter_test:
sdk: flutter

flutter_lints: ^4.0.0
flutter_lints: ^5.0.0
path_provider_platform_interface: ^2.1.2
plugin_platform_interface: ^2.1.8