Skip to content
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

Disconnect node on Wallet Reset #94

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 0 additions & 2 deletions lib/screens/node_management_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ class _NodeManagementScreenState extends State<NodeManagementScreen> {
await NodeUtils.establishConnectionToNode(url);
}
} else {
isConnectionEstablished =
await NodeUtils.establishConnectionToNode(url);
if (isConnectionEstablished) {
await NodeUtils.closeEmbeddedNode();
}
Expand Down
1 change: 1 addition & 0 deletions lib/screens/splash_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class _SplashScreenState extends State<SplashScreen>
// after the user creates or imports a new wallet
kWalletInitCompleted = false;
await sl.get<NotificationsBloc>().addNotification(null);
NodeUtils.stopWebSocketClient();
if (sl<AutoReceiveTxWorker>().pool.isNotEmpty) {
sl<AutoReceiveTxWorker>().pool.clear();
}
Expand Down
12 changes: 8 additions & 4 deletions lib/utils/node_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,19 @@ class NodeUtils {
}
}

static stopWebSocketClient() {
try {
zenon!.wsClient.stop();
} catch (_) {}
}

static initWebSocketClient() async {
addOnWebSocketConnectedCallback();
var url = kCurrentNode ?? kLocalhostDefaultNodeUrl;
var url = kCurrentNode ?? '';
bool connected = false;
try {
connected = await establishConnectionToNode(url);
} on WebSocketException {
url = kLocalhostDefaultNodeUrl;
}
} catch (_) {}
if (!connected) {
zenon!.wsClient.initialize(
url,
Expand Down
Loading