mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 23:39:30 +00:00
[mob] Reload location discovery section post cities load
This commit is contained in:
parent
04de72dafc
commit
3cd384a7ba
@ -13,4 +13,5 @@ enum LocTagEventType {
|
|||||||
add,
|
add,
|
||||||
update,
|
update,
|
||||||
delete,
|
delete,
|
||||||
|
dataSetLoaded,
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,9 @@ class LocationService {
|
|||||||
final Computer _computer = Computer.shared();
|
final Computer _computer = Computer.shared();
|
||||||
|
|
||||||
LocationService._privateConstructor();
|
LocationService._privateConstructor();
|
||||||
|
// If the discovery section is loaded before the cities are loaded, then we
|
||||||
|
// need to refresh the discovery section after the cities are loaded.
|
||||||
|
bool reloadLocationDiscoverySection = false;
|
||||||
|
|
||||||
static final LocationService instance = LocationService._privateConstructor();
|
static final LocationService instance = LocationService._privateConstructor();
|
||||||
|
|
||||||
@ -48,6 +51,9 @@ class LocationService {
|
|||||||
List<EnteFile> allFiles,
|
List<EnteFile> allFiles,
|
||||||
String query,
|
String query,
|
||||||
) async {
|
) async {
|
||||||
|
if (allFiles.isEmpty && query.isEmpty) {
|
||||||
|
reloadLocationDiscoverySection = true;
|
||||||
|
}
|
||||||
final EnteWatch w = EnteWatch("cities_search")..start();
|
final EnteWatch w = EnteWatch("cities_search")..start();
|
||||||
w.log('start for files ${allFiles.length} and query $query');
|
w.log('start for files ${allFiles.length} and query $query');
|
||||||
final result = await _computer.compute(
|
final result = await _computer.compute(
|
||||||
@ -225,8 +231,13 @@ class LocationService {
|
|||||||
await _computer.compute(parseCities, param: {"filePath": file.path});
|
await _computer.compute(parseCities, param: {"filePath": file.path});
|
||||||
final endTime = DateTime.now();
|
final endTime = DateTime.now();
|
||||||
_logger.info(
|
_logger.info(
|
||||||
"Loaded cities in ${(endTime.millisecondsSinceEpoch - startTime.millisecondsSinceEpoch)}ms",
|
"Loaded cities in ${(endTime.millisecondsSinceEpoch - startTime.millisecondsSinceEpoch)}ms, reloadingDiscovery: $reloadLocationDiscoverySection",
|
||||||
);
|
);
|
||||||
|
if (reloadLocationDiscoverySection) {
|
||||||
|
reloadLocationDiscoverySection = false;
|
||||||
|
Bus.instance
|
||||||
|
.fire(LocationTagUpdatedEvent(LocTagEventType.dataSetLoaded));
|
||||||
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
_logger.severe("Failed to load cities", e, s);
|
_logger.severe("Failed to load cities", e, s);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user