Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] refactor

laurenspriemdcac2332965b
diff --git a/mobile/lib/core/error-reporting/isolate_logging.dart b/mobile/lib/core/error-reporting/isolate_logging.dart
index 5521e0748d..5ac74b6303 100644
--- a/mobile/lib/core/error-reporting/isolate_logging.dart
+++ b/mobile/lib/core/error-reporting/isolate_logging.dart
@@ -49,9 +49,9 @@ class IsolateLogger {
}
/// WARNING: only call this from the main thread
- static void handLogStringsToMainLogger(Queue<String> logs) {
+ static void handLogStringsToMainLogger(List<String> logs) {
while (logs.isNotEmpty) {
- final logString = logs.removeFirst();
+ final logString = logs.removeAt(0);
final log = IsolateLogString.fromJsonString(logString);
SuperLogging.saveLogString(log.logString, log.error);
}
diff --git a/mobile/lib/services/machine_learning/ml_computer.dart b/mobile/lib/services/machine_learning/ml_computer.dart
index f027208758..f0e01d4c7d 100644
--- a/mobile/lib/services/machine_learning/ml_computer.dart
+++ b/mobile/lib/services/machine_learning/ml_computer.dart
@@ -114,8 +114,8 @@ class MLComputer {
logger.info("XXX logging from isolate is working!!!");
final Queue<String> logStrings =
isolateLogger.getLogStringsAndClear();
- final test = [List<String>.from(logStrings)];
- sendPort.send(test);
+ final logs = List<String>.from(logStrings);
+ sendPort.send({"data": true, "logs": logs});
break;
}
} catch (e, stackTrace) {
@@ -233,16 +233,17 @@ class MLComputer {
});
}
- Future<void> testLogging() async {
+ Future<bool> testLogging() async {
try {
- final test = await _runInIsolate(
+ final result = await _runInIsolate(
(
MLComputerOperation.testLogging,
{},
),
- ) as List<List<String>>;
- IsolateLogger.handLogStringsToMainLogger(Queue.from(test[0]));
- return;
+ ) as Map<String, Object>;
+ final logs = result['logs'] as List<String>;
+ IsolateLogger.handLogStringsToMainLogger(logs);
+ return result['data'] as bool;
} catch (e, s) {
_logger.severe("XXX Could not test logging in isolate", e, s);
rethrow;
diff --git a/mobile/lib/ui/settings/ml/ml_user_dev_screen.dart b/mobile/lib/ui/settings/ml/ml_user_dev_screen.dart
index 7c4d808592..1f75c95d5b 100644
--- a/mobile/lib/ui/settings/ml/ml_user_dev_screen.dart
+++ b/mobile/lib/ui/settings/ml/ml_user_dev_screen.dart
@@ -62,8 +62,8 @@ class MLUserDeveloperOptions extends StatelessWidget {
buttonType: ButtonType.neutral,
labelText: "Log something in isolate",
onTap: () async {
- await MLComputer.instance.testLogging();
- showShortToast(context, "Done");
+ final boolean = await MLComputer.instance.testLogging();
+ showShortToast(context, "Done: $boolean");
},
),
const SafeArea(