Skip to content

Commit c97c508

Browse files
authored
Merge pull request #21 from ecency/feruzm/investigate-hive-operation-hanging-issue
Fix timer handling for hive transactions
2 parents f452e8c + 5251a49 commit c97c508

2 files changed

Lines changed: 19 additions & 22 deletions

File tree

lib/core/controllers/hive_transaction_controller.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ class HiveTransactionController {
2929

3030
void onSocketSignWait(SocketResponse data, SocketInputType type,
3131
String accountName, String authKey) {
32-
SocketWaitAction.call(
33-
data: data,
34-
socketInputType: type,
35-
listenersProvider: listenersProvider,
36-
isHiveKeyChainMethod: ishiveKeyChainMethod,
37-
accountName: accountName,
38-
authKey: authKey,
39-
timer: timer,
40-
onTimeOut: () => onServerFailure(message: LocaleText.emTimeOutMessage),
41-
resetListeners: resetListeners);
32+
timer = SocketWaitAction.call(
33+
data: data,
34+
socketInputType: type,
35+
listenersProvider: listenersProvider,
36+
isHiveKeyChainMethod: ishiveKeyChainMethod,
37+
accountName: accountName,
38+
authKey: authKey,
39+
onTimeOut: () => onServerFailure(message: LocaleText.emTimeOutMessage),
40+
);
4241
}
4342

4443
@protected

lib/core/socket/actions/socket_auth_wait.dart

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
11
import 'dart:async';
22

3-
import 'package:flutter/services.dart';
43
import 'package:waves/core/providers/transaction_listeners_providers.dart';
54
import 'package:waves/core/socket/models/socket_wait_model.dart';
65
import 'package:waves/core/socket/models/socket_response.dart';
76
import 'package:waves/core/utilities/act.dart';
87
import 'package:waves/core/utilities/enum.dart';
98

109
class SocketWaitAction {
11-
static void call(
12-
{required SocketResponse data,
13-
required SocketInputType socketInputType,
14-
required TransactionListenersProvider listenersProvider,
15-
required bool isHiveKeyChainMethod,
16-
required String accountName,
17-
required String authKey,
18-
required Timer? timer,
19-
required VoidCallback onTimeOut,
20-
required VoidCallback resetListeners}) {
10+
static Timer call({
11+
required SocketResponse data,
12+
required SocketInputType socketInputType,
13+
required TransactionListenersProvider listenersProvider,
14+
required bool isHiveKeyChainMethod,
15+
required String accountName,
16+
required String authKey,
17+
required VoidCallback onTimeOut,
18+
}) {
2119
String uuid = data.value;
2220
String jsonString =
2321
SocketWaitModel(accountName: accountName, uuid: uuid, authKey: authKey)
@@ -32,7 +30,7 @@ class SocketWaitAction {
3230
}
3331
listenersProvider.tickValueListener.value =
3432
listenersProvider.timeOutValueListener.value;
35-
timer = Timer.periodic(const Duration(seconds: 1), (tickValue) {
33+
return Timer.periodic(const Duration(seconds: 1), (tickValue) {
3634
if (listenersProvider.tickValueListener.value == 0) {
3735
tickValue.cancel();
3836
onTimeOut();

0 commit comments

Comments
 (0)