-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
the connectRelay() has this code, returning true even when it's still connecting.
This is confusing and causes issues where you think it's connected while it's not.
We should refactor to using rxdart streams(behavior subjects) here to communicate state changes clearly to consuming functions.
I remember that we need the state of is connecting and has not failed yet
Future<Tuple<bool, String>> connectRelay({
required String dirtyUrl,
required ConnectionSource connectionSource,
int connectTimeout = DEFAULT_WEB_SOCKET_CONNECT_TIMEOUT,
}) async {
String? url = cleanRelayUrl(dirtyUrl);
if (url == null) {
updateRelayConnectivity();
return Tuple(false, "unclean url");
}
if (globalState.blockedRelays.contains(url)) {
updateRelayConnectivity();
return Tuple(false, "relay is blocked");
}
if (isRelayConnected(url)) {
Logger.log.t("relay already connected: $url");
updateRelayConnectivity();
return Tuple(true, "");
}
if (isRelayConnecting(url)) {
Logger.log.t("relay is already connecting: $url");
updateRelayConnectivity();
return Tuple(true, "relay is still connecting"); //<-- bad
}Reactions are currently unavailable