mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 15:30:40 +00:00
[mob][photos] notify user if model download is paused
This commit is contained in:
parent
51cf793012
commit
eaf136d34f
@ -493,6 +493,13 @@ class MLService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void triggerModelsDownload() {
|
||||||
|
if (!areModelsDownloaded && !_downloadModelLock.locked) {
|
||||||
|
_logger.info("Models not downloaded, starting download");
|
||||||
|
unawaited(_ensureDownloadedModels());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _ensureDownloadedModels([bool forceRefresh = false]) async {
|
Future<void> _ensureDownloadedModels([bool forceRefresh = false]) async {
|
||||||
if (_downloadModelLock.locked) {
|
if (_downloadModelLock.locked) {
|
||||||
_logger.finest("Download models already in progress");
|
_logger.finest("Download models already in progress");
|
||||||
@ -504,7 +511,9 @@ class MLService {
|
|||||||
}
|
}
|
||||||
final goodInternet = await canUseHighBandwidth();
|
final goodInternet = await canUseHighBandwidth();
|
||||||
if (!goodInternet) {
|
if (!goodInternet) {
|
||||||
_logger.info("Cannot download models because user is not connected to wifi");
|
_logger.info(
|
||||||
|
"Cannot download models because user is not connected to wifi",
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.info('Downloading models');
|
_logger.info('Downloading models');
|
||||||
|
@ -27,6 +27,7 @@ import "package:photos/ui/components/title_bar_widget.dart";
|
|||||||
import "package:photos/ui/components/toggle_switch_widget.dart";
|
import "package:photos/ui/components/toggle_switch_widget.dart";
|
||||||
import "package:photos/ui/settings/ml/enable_ml_consent.dart";
|
import "package:photos/ui/settings/ml/enable_ml_consent.dart";
|
||||||
import "package:photos/utils/ml_util.dart";
|
import "package:photos/utils/ml_util.dart";
|
||||||
|
import "package:photos/utils/network_util.dart";
|
||||||
import "package:photos/utils/wakelock_util.dart";
|
import "package:photos/utils/wakelock_util.dart";
|
||||||
|
|
||||||
class MachineLearningSettingsPage extends StatefulWidget {
|
class MachineLearningSettingsPage extends StatefulWidget {
|
||||||
@ -257,6 +258,8 @@ class ModelLoadingState extends StatefulWidget {
|
|||||||
class _ModelLoadingStateState extends State<ModelLoadingState> {
|
class _ModelLoadingStateState extends State<ModelLoadingState> {
|
||||||
StreamSubscription<(String, int, int)>? _progressStream;
|
StreamSubscription<(String, int, int)>? _progressStream;
|
||||||
final Map<String, (int, int)> _progressMap = {};
|
final Map<String, (int, int)> _progressMap = {};
|
||||||
|
Timer? _timer;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_progressStream =
|
_progressStream =
|
||||||
@ -277,6 +280,9 @@ class _ModelLoadingStateState extends State<ModelLoadingState> {
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
_timer = Timer.periodic(const Duration(seconds: 10), (timer) {
|
||||||
|
setState(() {});
|
||||||
|
});
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,6 +290,7 @@ class _ModelLoadingStateState extends State<ModelLoadingState> {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
_progressStream?.cancel();
|
_progressStream?.cancel();
|
||||||
|
_timer?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -292,8 +299,25 @@ class _ModelLoadingStateState extends State<ModelLoadingState> {
|
|||||||
children: [
|
children: [
|
||||||
MenuSectionTitle(title: S.of(context).status),
|
MenuSectionTitle(title: S.of(context).status),
|
||||||
MenuItemWidget(
|
MenuItemWidget(
|
||||||
captionedTextWidget: CaptionedTextWidget(
|
captionedTextWidget: FutureBuilder(
|
||||||
title: _getTitle(context),
|
future: canUseHighBandwidth(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.hasData) {
|
||||||
|
if (snapshot.data!) {
|
||||||
|
MLService.instance.triggerModelsDownload();
|
||||||
|
return CaptionedTextWidget(
|
||||||
|
title: S.of(context).loadingModel,
|
||||||
|
key: const ValueKey("loading_model"),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return CaptionedTextWidget(
|
||||||
|
title: S.of(context).waitingForWifi,
|
||||||
|
key: const ValueKey("waiting_for_wifi"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return const CaptionedTextWidget(title: "");
|
||||||
|
},
|
||||||
),
|
),
|
||||||
trailingWidget: EnteLoadingWidget(
|
trailingWidget: EnteLoadingWidget(
|
||||||
size: 12,
|
size: 12,
|
||||||
@ -322,15 +346,6 @@ class _ModelLoadingStateState extends State<ModelLoadingState> {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getTitle(BuildContext context) {
|
|
||||||
// TODO: uncomment code below to actually check for high bandwidth
|
|
||||||
// final usableConnection = await canUseHighBandwidth();
|
|
||||||
// if (!usableConnection) {
|
|
||||||
// return S.of(context).waitingForWifi;
|
|
||||||
// }
|
|
||||||
return S.of(context).loadingModel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class MLStatusWidget extends StatefulWidget {
|
class MLStatusWidget extends StatefulWidget {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user