do not try to start analysis service when app goes to background
This commit is contained in:
parent
58e3912f86
commit
46374dfcc1
1 changed files with 14 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:ui';
|
||||||
|
|
||||||
import 'package:aves/model/covers.dart';
|
import 'package:aves/model/covers.dart';
|
||||||
import 'package:aves/model/entry/entry.dart';
|
import 'package:aves/model/entry/entry.dart';
|
||||||
|
@ -26,6 +27,7 @@ import 'package:aves/model/vaults/vaults.dart';
|
||||||
import 'package:aves/services/analysis_service.dart';
|
import 'package:aves/services/analysis_service.dart';
|
||||||
import 'package:aves/services/common/image_op_events.dart';
|
import 'package:aves/services/common/image_op_events.dart';
|
||||||
import 'package:aves/services/common/services.dart';
|
import 'package:aves/services/common/services.dart';
|
||||||
|
import 'package:aves/widgets/aves_app.dart';
|
||||||
import 'package:aves_model/aves_model.dart';
|
import 'package:aves_model/aves_model.dart';
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:event_bus/event_bus.dart';
|
import 'package:event_bus/event_bus.dart';
|
||||||
|
@ -498,11 +500,19 @@ abstract class CollectionSource with SourceBase, AlbumMixin, CountryMixin, Place
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startAnalysisService) {
|
if (startAnalysisService) {
|
||||||
await AnalysisService.startService(
|
final lifecycleState = AvesApp.lifecycleStateNotifier.value;
|
||||||
force: force,
|
switch (lifecycleState) {
|
||||||
entryIds: entries?.map((entry) => entry.id).toList(),
|
case AppLifecycleState.resumed:
|
||||||
);
|
case AppLifecycleState.inactive:
|
||||||
|
await AnalysisService.startService(
|
||||||
|
force: force,
|
||||||
|
entryIds: entries?.map((entry) => entry.id).toList(),
|
||||||
|
);
|
||||||
|
default:
|
||||||
|
unawaited(reportService.log('analysis service not started because app is in state=$lifecycleState'));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// explicit GC before cataloguing multiple items
|
// explicit GC before cataloguing multiple items
|
||||||
await deviceService.requestGarbageCollection();
|
await deviceService.requestGarbageCollection();
|
||||||
|
|
Loading…
Reference in a new issue