Set currentId as local variable

This commit is contained in:
DongHyun Kim 2024-01-24 04:14:44 +09:00
parent ff96c3c358
commit 4a5ac9aa8a
2 changed files with 6 additions and 4 deletions

View file

@ -8,7 +8,7 @@ import 'package:mangayomi/utils/reg_exp_matcher.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'crop_borders_provider.g.dart';
int currentId = 0;
int nextId = 0;
@Riverpod(keepAlive: true)
Future<Uint8List?> cropBorders(CropBordersRef ref,
@ -32,6 +32,8 @@ Future<Uint8List?> cropBorders(CropBordersRef ref,
return null;
}
final currentId = nextId;
nextId++;
final completer = Completer<Uint8List>();
CropBordersInput(
interactionId: currentId,
@ -44,7 +46,6 @@ Future<Uint8List?> cropBorders(CropBordersRef ref,
});
final image = await completer.future;
subscription.cancel();
currentId++;
return image;
}

View file

@ -1,9 +1,11 @@
import 'package:mangayomi/messages/boa_js.pb.dart';
import 'dart:async';
int currentId = 0;
int nextId = 0;
Future<String> evalJs(String script) async {
final currentId = nextId;
nextId++;
final completer = Completer<String>();
BoaInput(
interactionId: currentId,
@ -17,7 +19,6 @@ Future<String> evalJs(String script) async {
});
final response = await completer.future;
subscription.cancel();
currentId++;
return response;
}